Updates from January, 2009 Toggle Comment Threads | Keyboard Shortcuts

  • Subinkrishna Gopi 4:16 pm on January 29, 2009 Permalink |
    Tags: , jar, , , ,   

    Running an executable JAR from command-line 

    An “executable JAR” is nothing but a JAR in which the entry point of execution is defined. That definition can be given in its manifest file (META-INF/Manifest.mf).

    The general structure of a JAR file:


    The manifest file should contain the details of the JAR file. It keeps the attribute as key-value pairs.

    The structure of a manifest file:

    Main-Class: com.package.MyJavaFile
    Specification-Title: "My Classes"
    Specification-Vendor: "Sun Microsystems, Inc."
    Implementation-Version: "build01"
    Implementation-Vendor: "Sun Microsystems, Inc."

    If the executable JAR is dependent on any other JAR, we need to specify it in the Manifest itself (even though there is an option to do it while invoking the application thru java -cp).

    Class-Path: aJar.jar anotherJar.jar

    I had some problems in building a JAR file using the conventional jar -cvf command. Whatever I do, it was not picking my custom manifest (I’m very bad). So, I used ANT to build a JAR.

    ANT file to build a JAR:

    <project name="Demo" default="build.jar.file">
      <target name="build.jar.file">
        <jar destfile="myJar.jar" basedir=".">
            <attribute name="Main-Class" value="com.package.MyJavaFile" />
            <attribute name="Class-Path" value="aJar.jar anotherJar.jar" />
        <copyfile dest="/path/to/deploy" src="myJar.jar"/>
    • use ANT or Eclipse IDE to build the JAR

    Running the JAR from the command-line:

    $ java -jar myJar.jar [optional parameters]

    External Links:
    http://java.sun.com/docs/books/tutorial/deployment/jar/ – Packaging tutorial from Sun

    • Subinkrishna G 5:27 pm on January 29, 2009 Permalink

      In the ANT build file I’ve mentioned only two attributes – Class-Path & Main-Class. These two are the most important attributes in this scenario. So using the “attribute” tag in “manifest” we can define all the other attributes too.

    • Mathew Varghese 2:22 pm on February 13, 2009 Permalink

      Add-on: If we don’t want to keep dependent JARs external, we can bundle within our target JAR. Use zipfileset ANT task.

      <zipfileset src="firstJar.jar" includes="**/*.java **/*.class"/>

      Read more: http://ant.apache.org/manual/CoreTypes/zipfileset.html

  • Subinkrishna Gopi 5:02 pm on January 22, 2009 Permalink |
    Tags: , , , , , , ,   

    A Jboss 5 issue 


    Me and my colleague Venu were working on some Jboss 5 stuff  (infact migrating from Jboss 4 to 5) when we got the following exception.


    ERROR [my.package.name] doSomething() Ex: javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.ejb3.remoting.IsLocalInterceptor; local class incompatible: stream classdesc serialVersionUID = -3758782076801249473, local class serialVersionUID = 337700910587744646]

    javax.naming.CommunicationException [Root exception is java.io.InvalidClassException: org.jboss.ejb3.remoting.IsLocalInterceptor; local class incompatible: stream classdesc serialVersionUID = -3758782076801249473, local class serialVersionUID = 337700910587744646]

    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:725)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:590)
    at javax.naming.InitialContext.lookup(InitialContext.java:351)

    .. .. ..

    Caused by: java.io.InvalidClassException: org.jboss.ejb3.remoting.IsLocalInterceptor; local class incompatible: stream classdesc serialVersionUID = -3758782076801249473, local class serialVersionUID = 337700910587744646

    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:546)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1552)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)

    We are trying to connect to another server which is running on Jboss 4 and trying to access a remote EJB (session bean). Till now I’ve no clear idea about this whole issue. If any of you can put some light to this issue, please.

    I will update this place once we tackle the issue.

    Update 1:
    I found some useful information here: https://jira.jboss.org/jira/browse/EJBTHREE-749

    The problem seems to be mismatching SerialVersionUID in org.jboss.ejb3.remoting.IsLocalInterceptor of  jboss-ejb3-client.jar.

    Update 2: 28-Jan-2009
    This issue has been fixed from Jboss-4.2.2 GA onwards. So all those who are using versions lesser than 4.2.2 are more likely to get this issue.

    Find the JIRA post by Venu here: https://jira.jboss.org/jira/browse/EJBTHREE-1696

  • Subinkrishna Gopi 10:13 am on January 22, 2009 Permalink |
    Tags: , , , , , , , ,   

    Tips – Web UI Design 

    Smashing Magazine planet-ajaxian-small

    I’ve been a huge fan of “simple web design” & usability. And I’m a regular reader of Smashing Magazine & Ajaxian. Today I got a chance to walk thru a couple of very nice articles – “12 Useful Techniques For Good User Interface Design” & “10 Useful Web Application Interface Techniques” in Smashing Magazine.

    More and more applications these days are migrating to the Web. Without platform constraints or installation requirements, the software-as-a-service model looks very attractive. Web application interface design is, at its core, Web design; however, its focus is mainly on function. To compete with desktop applications, Web apps must offer simple, intuitive and responsive user interfaces that let their users get things done with less effort and time.

    In the past we didn’t cover web applications the way we should and now it’s time to take a closer look at some useful techniques and design solutions that make web-applications more user-friendly and more beautiful. This article presents the first part of our extensive research on design patterns and useful design solutions in modern web applications. Below you’ll find a collection of 10 useful interface design techniques and best practices used in many successful web-applications.

    Have a nice read.

  • Subinkrishna Gopi 11:03 am on January 21, 2009 Permalink |
    Tags: , , , ,   

    Disabling HttpUnit script loading 

    Those who work with HttpUnit (for testing or development needs) might have faced issues with scripts (and its loading). This situation is more obvious if we are working on a third party web site which will be loading numerous script files from different domains (or sub-domains), sometimes thru a secured channel. The one possible exception is:

    java.lang.RuntimeException: Error loading included script: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

    Even if we are setting the following,


    it will not avoid the above situation as the problem is with the file itself (either an invalid URL or an invalid certificate).

    One possible solution is to modify the HttpUnit code so that it can avoid loading the script itself. The right place will be com.meterware.httpunit.ParsedHTML.getScript(). Change the method body to:

    private String getScript( Node scriptNode )
       String scriptLocation = NodeUtils.getNodeAttribute
          (scriptNode, "src", null);
       if (null != scriptLocation)
          System.out.println("Blocking script from: " +
       return (null);

    This is how the actual code look like:

    private String getScript(Node scriptNode)
       String scriptLocation = NodeUtils.getNodeAttribute
          (scriptNode, "src", null);
       if (scriptLocation == null)
          return NodeUtils.asText(scriptNode.getChildNodes());
             return getIncludedScript(scriptLocation);
          catch (IOException e)
             throw new RuntimeException("Error loading included script: "
                 + e);
       return (null);

    We were working on a crawler where we used HttpUnit as a supporting API, and JavaScript was never an important factor for our process. And because of this tweak we were able to improve the performance by 4 times approx.

    Be very careful while modifying the source code. And do it at your own risk.

  • Subinkrishna Gopi 5:50 pm on January 19, 2009 Permalink |  

    I’m back! 

    I wanted to write a lot in this blog. But I was not able to contribute a lot. If you ask me why, hmm…. I was very lazy, may be.

    But now I have a better website, subin.co.in (now version 2 beta). And your comments are always welcome.

    Also, I welcome Mathew to my blog. He is a cool Java guy, a friend and my work-mate.

Compose new post
Next post/Next comment
Previous post/Previous comment
Show/Hide comments
Go to top
Go to login
Show/Hide help
shift + esc