Discussions

EJB design: Problem in creating jar file for EJB

  1. Problem in creating jar file for EJB (2 messages)

    I am trying to create a jar file containing EJB Home,EJB remote,EJB bean,client files and deployment descriptor.My EJB Home,remote and bean classes are in C:\EJB and my client classes and deployment descriptor are in C:\EJBClient.These folder contains both java and classs files.Now to jar these files I am issuing following command :

    C:\>jar cfm test.jar EJB\*.java EJBClient\*.java EJB\ejb-jar.xml

    then it gives following error:

    java.io.IOException:invalid header field
    at java.util.jar.Attributes.read(Attributes.java:383)
    at java.util.jar.Manifest.read(Manifest.java:167)
    at java.util.jar.Manifest.<init>(Manifest.java:52)
    at sun.tools.jar.Main.run.(Main.java:124)
    at sun.tools.jar.Main.run.(Main.java:904)

    Please tell me whats wrong with the syntax.
  2. The "m" switch in "cfm" indicates that you are using your own manifest rather than allowing the jar tool to create the manifest. The jar tool therefore expects the first parameter after "cfm" to be a manifest file, but you are putting the jar name.

    Also, the jar code should operate on .class files, not .java files, so you need to compile your Java code before using jar.

    Change your operations as follows:

    set CLASSPATH=bin;[add j2ee jars to your classpath]
    javac -d bin EJB\*.java
    javac -d bin EJBClient\*.java
    jar cf test.jar bin\* EJB\ejb-jar.xml
  3. Thanks Paul,
     It worked.