Ears, wars, support jars, and CLASSPATH

I am trying to migrate an application from WLS 5.1 to 6.1. There are 25
EJB jars with an equal number of support jars, most of which are referenced
by multiple EJBs. There are also a large number of jsps, and html pages.
I have tried packaging an ear that contains the 25 ejb jars, a war file
containing the web pages. I have attempted to include the support jars in
the ear as well.
In all attempts, the only way I get class references sastisfied is to
include all the jars on the system CLASSPATH. But this defeats the purpose
of packaging, since none of the components referenced in the system
CLASSPATH will be re-deployable.
The online documents refer to separate class loaders and classpaths for the
war and ejbs, but no detail as to how classes are found by the loaders.
Unless I put all the jars into the CLASSPATH, jsp pages cannot reference the
EJBs, and EJBs are unable to reference other EJBs.

Thanks,
Now if I could just get Webgain Visual Cafe to allow me to include the
Classpath entries in the generated manifests for the EJB jars.
"Gregory Gerard" <[email protected]> wrote in message
news:3ba24da1$[email protected]..
You need to mangle all the Manifest files within the EAR and EJB-JARs and
WAR to get the right thing to happen. Check out this PDF on Sun's site:
http://java.sun.com/j2ee/j2ee-1_3-pfd4-spec.pdf
section 8.1.1.2
I don't entirely understand all the restrictions and formatting -- Ihaven't
found an example ear file out there that implements a non-trivial case.
greg
"Carl Lawstuen" <[email protected]> wrote in message
news:3ba21d8e$[email protected]..
I am trying to migrate an application from WLS 5.1 to 6.1. There are
25
EJB jars with an equal number of support jars, most of which arereferenced
by multiple EJBs. There are also a large number of jsps, and htmlpages.
I have tried packaging an ear that contains the 25 ejb jars, a war file
containing the web pages. I have attempted to include the support jarsin
the ear as well.
In all attempts, the only way I get class references sastisfied is to
include all the jars on the system CLASSPATH. But this defeats thepurpose
of packaging, since none of the components referenced in the system
CLASSPATH will be re-deployable.
The online documents refer to separate class loaders and classpaths forthe
war and ejbs, but no detail as to how classes are found by the loaders.
Unless I put all the jars into the CLASSPATH, jsp pages cannot referencethe
EJBs, and EJBs are unable to reference other EJBs.

Similar Messages

  • Jars and classpath

    Hi All,
    I have a command line program which access database and somehow connects to a servlet running in Tomcat.
    Originally, the root directory has 2 sub-directories: the classes and the lib. The classes directory contains config files, like database name, port no... The lib dir contains all the jar files needed by my program to run.
    Honestly, it run using: java -cp /path/to/dir/jar1.jar;/path/to/dir/jar2.jar,....
    But the program uses many jar files, more or less 20 jar files, and many config files. And Its not convenient to run the program using the command above.
    So, I made a manifest file, manifest.mnf, and saved it under the classes dir:
    Manifest-Version: 1.0
    Main-Class: ManualSend
    Class-Path: ..\lib\bsiclient.jar
    ..\lib\msh.jar
    ..\classes\dbojects.properties
    ..\classes\config.xml
    ..\classes\jndi.properties
    ..\classes\log4j.properties
    ..\classes\msh_client.properties.xml
    ..\classes\sql.properties
    ..\lib\activation.jar
    ..\lib\avalon-framework-4.1.4.jar
    ..\lib\batik.jar
    ..\lib\bsi.jar
    ..\lib\bcmail-jdk13-115.jar
    ..\lib\commons-beanutils.jar
    ..\lib\commons-codec-1.2.jar
    ..\lib\commons-collections-3.1.jar
    ..\lib\commons-logging.jar
    ..\lib\commons-configuration-1.0.jar
    ..\lib\commons-digester.jar
    ..\lib\commons-lang-2.0.jar
    ..\lib\cos.jar lib\dom.jar
    ....etc.
    The ManualSend class is in bsiclient.jar. It used the default package.
    I run it in classes dir: jar -cvfm test.jar
    java -jar test.jar
    I got an error, saying:
    Error in building: \classes\test.jar!\msh_client.properties.xml (The filename, directory name, or volume label sntax is incorrect).
    I can't figure it out, so for the meantime, i just changed the '..\classes\' part of my manifest to '.\'
    I'm not happy with that. I want it to run from my root directory, using /lib and /classes subdirectories.
    Is there a way to do that? Really i'm confused with these classpath thing.
    Please, any comments, opinions, suggestions.... even violent reactions are greatly appreciated. I haven't received any feedbacks with any of my previous post in all of forums.
    Thanks,

    thanks Peter,
    I've attempted that approach before. But as i've said my program needs a lot of jar files, plus a number of config files. If i write them on one single Class-Path line, i got an error saying 'commands too long lines', or something like that.
    The manifest works fine. I am able to run the program using that manifest. But I'm not happy with that. Actually the program was based on a Tomcat webapp. I am actually doing a command-line version of it.
    So it Tomcat WEB-INF, classes and lib directories were separated. I am looking for a way to use these 2 separate directories. What I would like to find out is how to run my program, outside of the WEB-INF classes and lib directories, and at the same time could access all the jars and config files in them.
    As of the moment I had no luck of doing that. I had to run the program inside classes folder, and make a copy of lib folder inside the classes folder.
    Do you have any more suggestions, opinions? Please.

  • Packaging of EAR / WAR / EJB-JAR

    Hello,
    I have a big application to do.
    So, one solution should be to use an EAR for one module, containing the WAR for the web-tier and the EJB-JAR for the business-tier.
    It would be better doing like this than creating a big WAR, in order to avoid to deploy a big WAR when a modification is done in one module.
    What about the problem of the session ?
    In fact, I have to declare a context-root for one EAR.
    And at each context-root is created an object HttpSession on the server.
    So, I have some questions about this :
    - How can I configure my WARs in order to use only one HttpSession object for every WARs ?
    - Can I put multiple WARs in one EAR ? If yes, what about the context-root ? This solution would resolve the session problem.
    Thanks in advance.
    bgOnline

    Hello,
    I have a big application to do.
    So, one solution should be to use an EAR for one
    module, containing the WAR for the web-tier and the
    EJB-JAR for the business-tier.
    It would be better doing like this than creating a
    big WAR, in order to avoid to deploy a big WAR when a
    modification is done in one module.Are you using local EJBs or remote EJBs? The only way for a war to talk to a local EJB is to package the war along with the ejb-jar in an EAR file because they need to be collocated. You can not simply bundle EJB classes in a war file.
    If you are using remte EJBs, then you can package the EJB client view classes along with the servlets and JSPs in the war file and deploy the war separately. But again your war will be one big war.
    If your EJBs are just entity beans, then Java EE 5 (see http://weblogs.java.net/blog/ss141213/archive/2005/12/using_java_pers.html) allows you some nice options.
    >
    What about the problem of the session ?
    In fact, I have to declare a context-root for one
    EAR.
    And at each context-root is created an object
    HttpSession on the server.
    So, I have some questions about this :
    - How can I configure my WARs in order to use only
    one HttpSession object for every WARs ?
    There is no standard way to do this. Relying on any application server specific feature can only make your app non-portable. So I strongly recommend you not to do this.
    - Can I put multiple WARs in one EAR ?Of course you can.
    If yes, what about the context-root ? This solution would resolve
    the session problem.Can't be solved using any standard way. So I suggest you stick to one big war, if that's what your business requirement is.To speed up development-deployment-test cycle, any appserver allows a rapid deployment option where in you can deploy incremental changes to server. Use this facility during development. DON'T sacrifice portability of your app by using any product specific configuration that you may not find any where else.
    Thanks,
    Sahoo

  • Javac with a  Jar and classpath

    I am trying to figure out how do I make Javac see the thinlet.class in the thinlet.jar.
    I have developed an XUL xml interface and a java program that calls the interface shown below:
    //package thinlet.demo;
    import thinlet.*;
    public class UI extends Thinlet
    { public UI () throws Exception {add(parse("UI.xml"));}
    public static void main(String[] args) throws Exception
    {    new FrameLauncher("UI", new UI(), 600, 600);  }}
    when I do the normal compile, I get an error:
    UI.java:4: cannot find symbol
    symbol: class Thinlet
    public class UI extends Thinlet {
    ^
    UI.java:7: cannot find symbol
    symbol : method parse(java.lang.String)
    location: class thinlet.demo.UI
    add(parse("UI.xml"));
    ^
    UI.java:12: cannot find symbol
    symbol : class FrameLauncher
    location: class thinlet.demo.UI
    new FrameLauncher("UI", new UI(), 600, 600);
    ^
    3 errors
    This thinlet class should be in the thinlet.jar that I have added the directory to the path, the directory and jarfile name to the System CLASSPATH and it couldn't see it. So finally I tried putting the thinlet.jar in the same directory to no avail. I've searched the web for some time an cannot find anything that specifically speaks to compiling a program that has parent classes in a Jar.
    Any help is definitely appreciated.

    What's with the commenting out of the package statement?
    Where are things located?
    Read this before posting anything more:
    [How Classes are Found|http://java.sun.com/javase/6/docs/technotes/tools/findingclasses.html]

  • Jar and classpath with space in folder name?

    Hi, all.
    Just for fun: what if I have a jar file that is dependant on the other jar file which is placed in folder with space in its name? How would I link it in manifest file?
    Thanks.

    Havae you tried quoting the Class-Path value?

  • How to deploy ear file with jar file and war file with different names

    Hi,
    As part of weblogic migration from WL 6.1 sp3 to WL 10, Iam facing some problem.
    Problem:
    I have one ear file(abc.ear) to deploy which contains one jar file(xyz.jar) and one war file(pqr.war).
    In config.xml file of WL 6.1, it was mentioned as :
    <Application Deployed="true" Name="abc" Path="./config/mydomain/applications/abc.ear">
    <EJBComponent Name="xyz" Targets="myserver" URI="xyz.jar"/>
    <WebAppComponent Name="pqr" Targets="myserver" URI="pqr.war"/>
    </Application>.
    The above is working fine.
    But in config.xml file WL10,I cannot mention the same.
    I need to have different application anmes for ear,jar and war.If I deploy as a ear file,the jar and war files are deployed with the same ear file name.
    I tried the following options:
    1) Deploying as a ear file by adding <sub-deployments>
    2) Deploying both war and jar seperately which is not recommended in my application.
    Please provide the content I should place in the config.xml so that everything works fine correctly.
    Any help is appreciated.

    Hi,
    As part of weblogic migration from WL 6.1 sp3 to WL 10, Iam facing some problem.
    Problem:
    I have one ear file(abc.ear) to deploy which contains one jar file(xyz.jar) and one war file(pqr.war).
    In config.xml file of WL 6.1, it was mentioned as :
    <Application Deployed="true" Name="abc" Path="./config/mydomain/applications/abc.ear">
    <EJBComponent Name="xyz" Targets="myserver" URI="xyz.jar"/>
    <WebAppComponent Name="pqr" Targets="myserver" URI="pqr.war"/>
    </Application>.
    The above is working fine.
    But in config.xml file WL10,I cannot mention the same.
    I need to have different application anmes for ear,jar and war.If I deploy as a ear file,the jar and war files are deployed with the same ear file name.
    I tried the following options:
    1) Deploying as a ear file by adding <sub-deployments>
    2) Deploying both war and jar seperately which is not recommended in my application.
    Please provide the content I should place in the config.xml so that everything works fine correctly.
    Any help is appreciated.

  • Are JDev autogenerated paths needed to create ear, war and jar files ?

    Hi
    We want to create ear, war and jar files from Ant build script generated from JDeveloper 11.1.1.7.
    We also like to use ojdeploy with it.
    In the process of creating build.xml files from projects, we see these paths.
    We also have standalone Weblogic installed with ADF runtime 11.1.1.7
    Questions:
    1- Do we need these path ids to generate ear, jar, war files properly and then deploy the ear to our standalone Weblogic so that our webapp can run ok ?
    2- Why are they generated, if they are not needed
    From research, it appears that we don't need these paths except to keep ant targets of init, compile, exec etc with ojdeploy.
    3- Is that true ?
    We are afraid that because no paths are listed in the build.xml, then when we deploy the ear app, it cant use the ADF runtime on the standalone WLS.
    Thanks in advance for answering.
    Sincerely
    eg of paths generated below:
      <path id="library.SOA.Designtime"/>
      <path id="library.SOA.Runtime"/>
      <path id="library.BPEL.Runtime"/>
      <path id="library.Mediator.Runtime"/>
      <path id="library.MDS.Runtime">
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.mds_11.1.1/mdsrt.jar"/>
      </path>
      <path id="library.BC4J.Service.Runtime">
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.adf.model_11.1.1/adfbcsvc.jar"/>
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.adf.model_11.1.1/adfbcsvc-share.jar"/>
        <pathelement location="{oracle.middleware}/oracle_common/modules/commonj.sdo_2.1.0.jar"/>
        <pathelement location="{oracle.middleware}/modules/org.eclipse.persistence_1.1.0.0_2-1.jar"/>
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.webservices_11.1.1/wsclient.jar"/>
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.web-common_11.1.1.jar"/>
      </path>
      <path id="library.TopLink">
        <pathelement location="{oracle.middleware}/modules/com.oracle.toplink_1.0.0.0_11-1-1-5-0.jar"/>
        <pathelement location="{oracle.middleware}/modules/org.eclipse.persistence_1.1.0.0_2-1.jar"/>
        <pathelement location="{oracle.middleware}/modules/com.bea.core.antlr.runtime_2.7.7.jar"/>
        <pathelement location="{oracle.middleware}/modules/javax.persistence_1.0.0.0_2-0-0.jar"/>
      </path>
      <path id="library.Oracle.Rules"/>
      <path id="classpath">
        <path refid="library.SOA.Designtime"/>
        <path refid="library.SOA.Runtime"/>
        <path refid="library.BPEL.Runtime"/>
        <path refid="library.Mediator.Runtime"/>
        <path refid="library.MDS.Runtime"/>
        <path refid="library.BC4J.Service.Runtime"/>
        <path refid="library.TopLink"/>
        <path refid="library.Oracle.Rules"/>
      </path>

    There are two different things here. Using ant to build the class files and then building an ear from the class files and other resources.
    The building part needs the libraries if you use javac as compiler. Building an ear file only needs the path to the jar files which are packed into the ear.
    In this sense you need the pages you see in the build.xml.
    Then Jdev offers another way: ojdeploy. This tool is a Jdev without a gui.
    You can use this tool and build the classes for each project of a workspace and to build build war and ear file. This is just like you click the rebuild button for each project and then the deploy the projects and application. If you use this approach you don't need the generated path ids as the whole build process is done inside Jdev as it's done on your developer pc.
    Timo

  • Building ear, jar and war

    Do I need a special tool to build the ear, jar and war files necessary for a J2EE application?
    And where can I find such tools?

    you don't need a special tool, with the jdk you have a command jar who make special file. The syntax is jar -cvf name.jar <directory>. jar only display you the correctly syntax.
    For the ejb.jar you have to respect the tree of the application with the directory meta-inf
    For the project.war you do hace the web-inf directory with web.xml
    For the project.ear you have to add the .jar and the .war into and a dirctory meta-inf with the fila application.xml
    If you find this too difficult some products like Jdevelopper make this very correctly

  • EAR has WAR has JAR in WEB-INF\lib NoClassDefFoundError

    What a nightmare.
    I found approximately 40 forums on this topic (and there are probably more), but noone has the definitive answer!
    Here's the problem....
    My servlet uses a utility class that resides in some other jar. That jar is then placed into the WEB-INF\lib directory of the WAR which in turn goes into the EAR. This is supposed to be all that is needed in order for the utility class to be found on the classpath.
    In fact, if you run the war in Tomcat as a standalone WAR it does in fact find it.... its when in an EAR deloployed to app server that the problem arises.
    I have had no luck with using any combination of putting the jar ANYWHERE in the EAR or WAR no matter if I specify the Class-Path: in the manifest(s) or not.
    I thought maybe that I was missing some config in the application.xml or web.xml but I couldn't find anything to support that.
    Maybe its dependent on the app server? I am using Orion, but the same problem can be found on J2EE RI release 1.3
    Work arounds:
    1. Simply put the utility jar in the lib directory of the server you're using
    2. Add an ejb module to the application.xml naming the utility jar as the ejb jar. Of course this is NOT an EJB jar and error messages/warnings will appear accordingly, but on Orion at least, it will load the classes needed... hooray!!
    Anyone got a definitive answer?

    What did you do to resolve this issue .. I'm having the exact same problem.
    What a nightmare.
    I found approximately 40 forums on this topic (and
    there are probably more), but noone has the definitive
    answer!
    Here's the problem....
    My servlet uses a utility class that resides in some
    other jar. That jar is then placed into the
    WEB-INF\lib directory of the WAR which in turn goes
    into the EAR. This is supposed to be all that is
    needed in order for the utility class to be found on
    the classpath.
    In fact, if you run the war in Tomcat as a standalone
    WAR it does in fact find it.... its when in an EAR
    deloployed to app server that the problem arises.
    I have had no luck with using any combination of
    putting the jar ANYWHERE in the EAR or WAR no matter
    if I specify the Class-Path: in the manifest(s) or
    not.
    I thought maybe that I was missing some config in the
    application.xml or web.xml but I couldn't find
    anything to support that.
    Maybe its dependent on the app server? I am using
    Orion, but the same problem can be found on J2EE RI
    release 1.3
    Work arounds:
    1. Simply put the utility jar in the lib directory of
    the server you're using
    2. Add an ejb module to the application.xml naming the
    utility jar as the ejb jar. Of course this is NOT an
    EJB jar and error messages/warnings will appear
    accordingly, but on Orion at least, it will load the
    classes needed... hooray!!
    Anyone got a definitive answer?

  • Adding a jar to the classpath of an executable jar (mixing -jar and -cp)

    Hello,
    frankly I hesitated over posting this to "New to Java"; my apologies (but also, eternal gratefulness) if there is an ultra-simple answer I have overlooked...
    I integrate a black-box app (I'm not supposed to have the source) that comes packaged as an executable jar (with a Manifest.MF that specifies the main class and a bunch of dependent jars), along with a few dependent jars and a startup script. Long story short, the application code supports adding jars in the classpath, but I can't find a painless way to add a jar in its "classpath".
    The app's "vendor" (another department of my customer company) has a slow turnaround on support requests, so while waiting for their suggestion as to how exactly to integrate custom jars, I'm trying to find a solution at the pure Java level.
    The startup script features a "just run the jar" launch line:
    java -jar startup.jarI tried tweaking this line to add a custom jar in the classpath
    java -cp mycustomclasses.jar -jar startup.jarBut that didn't seem to work ( NoClassDefFound at the point where the extension class is supposed to be loaded).
    I tried various combination of order, -cp/-classpath, using the CLASSPATH environment variable,... and eventually gave up and devised a manual launch line, which obviously worked:
    java -cp startup.jar;dependency1.jar;dependency2.jar;mycustomclasses.jar fully.qualified.name.of.StartupClassI resent this approach though, which not only makes me have to know the main class of the app, but also forces me to specify all the dependencies explicitly (the whole content of the Manifest's class-path entry).
    I'm surprised there isn't another approach: really, can't I mix -jar and -cp options?
    - [url http://download.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html]This document (apparently a bible on the CLASSPATH), pointed out by a repited forum member recently, does not document the -jar option.
    - the [url http://download.oracle.com/javase/tutorial/deployment/jar/run.html]Java tutorial describes how to use the -jar option, but does not mention how it could play along with -cp
    Thanks in advance, and best regards,
    J.
    Edited by: jduprez on Dec 7, 2010 11:35 PM
    Ahem, the "Java application launcher" page bundled with the JDK doc (http://download.oracle.com/javase/6/docs/technotes/tools/windows/java.html) specifies that +When you use [the -jar] option, the JAR file is the source of all user classes, and other user class path settings are ignored+
    So this behavior is deliberate indeed... my chances diminish to find a way around other than specifying the full classpath and main class...

    I would have thought that the main-class attribute of the JAR you name in the -jar option is the one that is executed.Then I still have the burden of copying that from the initial startup.jar's manifest. Slightly less annoying than copying the whole Class-path entry, but it's an impediment to integrating it as a "black-box".
    The 'cascading' behavior is implicit in the specification
    I know at least one regular in addition to me that would issue some irony about putting those terms together :o)
    Anyway, thank you for confirming the original issue, and merci beaucoup for your handy "wrapper" trick.
    I'll revisit the post markers once I've actually tried it.
    Best regards,
    Jérôme

  • Classloading [EAR] - [webapp.war+ejb.jar]

    Hi.
    I've got a problem with the classloader hierarchy in WL 6.0.
    When I deploy my war/ejb application as an EAR, everything works fine.
    But I want (for several reasons) to deploy
    EJB jars and WebApp wars (or exploded Web Apps) seperately.
    WL 6.0 EJB classloader doesn't export remote/home interfaces and
    helper classes,
    so my web app can't find them.
    When I include that interfaces/classes in my Web App, I get
    occasionally ClassCastExceptions (I assume depending on classloader
    caching).
    Is there a way to configure the classloader hierarchy, or do you have
    any other solution for this?
    Thanks,
    Roman

    Hello,
    I have a big application to do.
    So, one solution should be to use an EAR for one
    module, containing the WAR for the web-tier and the
    EJB-JAR for the business-tier.
    It would be better doing like this than creating a
    big WAR, in order to avoid to deploy a big WAR when a
    modification is done in one module.Are you using local EJBs or remote EJBs? The only way for a war to talk to a local EJB is to package the war along with the ejb-jar in an EAR file because they need to be collocated. You can not simply bundle EJB classes in a war file.
    If you are using remte EJBs, then you can package the EJB client view classes along with the servlets and JSPs in the war file and deploy the war separately. But again your war will be one big war.
    If your EJBs are just entity beans, then Java EE 5 (see http://weblogs.java.net/blog/ss141213/archive/2005/12/using_java_pers.html) allows you some nice options.
    >
    What about the problem of the session ?
    In fact, I have to declare a context-root for one
    EAR.
    And at each context-root is created an object
    HttpSession on the server.
    So, I have some questions about this :
    - How can I configure my WARs in order to use only
    one HttpSession object for every WARs ?
    There is no standard way to do this. Relying on any application server specific feature can only make your app non-portable. So I strongly recommend you not to do this.
    - Can I put multiple WARs in one EAR ?Of course you can.
    If yes, what about the context-root ? This solution would resolve
    the session problem.Can't be solved using any standard way. So I suggest you stick to one big war, if that's what your business requirement is.To speed up development-deployment-test cycle, any appserver allows a rapid deployment option where in you can deploy incremental changes to server. Use this facility during development. DON'T sacrifice portability of your app by using any product specific configuration that you may not find any where else.
    Thanks,
    Sahoo

  • Ear or war or jar not created

    1. when I build the examples, it builds the class files but does not create
    ear or war files....
    2. how do I stop the default service and run the example server... the
    beasvc is not in the service list...... just have to kill in the task
    manager??
    Thx

    Java ARchive (JAR) files contain Java classes and Enterprise JavaBeans.
    Web Application Archive (WAR) files contain servlet Java code, libraries used by the servlets and possibly static content such as HTML files and JPEGs.
    Enterprise Application Archive (EAR) files contain JAR files (EJBs) and WAR files (Servlets).
    I hope that answers your question. :)
    For more detailed information have a look at the Enterprise JavaBeans Specification and the Servlet Specification:
    http://java.sun.com/products/ejb/docs.html
    http://java.sun.com/products/servlet/2.2/

  • Extracted ear/war/jar file location in JBoss

    How can I find out in runtime where JBoss extracted my ear/war/jar file?
    I have a file inside my ear/war/jar file and I need to know the location of the file. I know that it is in the tmp/deploy directory but I need the exact application temporary name.

    You can take out the common classes and bundle them in a jar library that can be bundled directly in APP-INF/lib (or library directory defined by <library-directory> in applicaton.xml if you are using JEE5 / WLS 10). Is it possible to do this re-arragement?

  • List the contents of jar, ear, war files

    Hi All,
    It has been several years since I have worked in java and now I am trying to get caught back up :-).
    My question is: Is there a standard utility that can dump/list the contents of the packaging files: jar, ear, war?
    Thanks in advance!

    You can use winzip. OR you can use the jar command provided in JDK.
    jar -tvf <<your archive (jar, war, ear)>>

  • Putting unix utility visible version info into ear, war, jar files?

    I would like to be able to use some unix utility (or java itself without a separate program) to display my version information for jar-like artifacts: ear, war, jar.
    In other words, when I build one of these things, I'd like to put my SVN version, date, user name, and maybe some other stuff into it in a way that can be read without a custom program. This needs to be done as part of the ant build (without requiring a custom java program).
    For example, one approach would be "strings | grep <special-string>" if I could put something, somewhere in the file that had this as 8-bit character encoding.
    For jars, making the jar executable and having the main print it out works, but I don't think that's do-able for ears and wars, and it would be desirable to have a consistent approach.
    Anyone already doing this?
    Ideas?

    For example, I don't think you can specify a mainline in the manifest of an ear or war.
    They have pretty strictly defined formats, and I don't want to risk violating a standard by tinkering outside the standard.Possible, but you can always run it as java -cp myWar.war my.utility.Version.
    There may be another possibility, but I'm unable to find any reference though:
    In my early Java days, I used to work on a system where there was a Unix utility (called something like +"ident"+) that was able to extract version and description info stuffed in a .so file (under which "standard" or proprietary format was the info stored, I don't know).
    I used to see it work on individual Java .class files too (from memory we had to put a String constant name "VERSION" in the class) and maybe jar files (I'm unsure).
    One of my co-workers at that time had described that as a standard tool, but "ident" turns up nothing of that kind on Google... And I've never since encountered any description of the "VERSION" constant naming convention...
    I was young and naive, I hope I were not bluffed by some alias in a custom setup... :o(
    Edited by: jduprez on Feb 18, 2010 11:30 AM
    OK a bit more reserah turned up [that man page|http://man-wiki.net/index.php/1:ident]. Apparently ident is part of RCS (installed along with CVS), and works by grepping the target file for patterns such as "$keyword: text $" (which is RCS/CVS keyword substitution pattern). Now that it mentions it, I remeber that that's what we put into our VERSION constant's value ("$version : ...$", or something of that kind).
    So:
    1) it's not so standard after all, you have to install the rcs package on the target host (regardless of whether you use RCS for configuration management, which would probably be a bad idea nowadays)
    2) you have to put such formatted strings somewhere in your code or configuration files (easy with Ant, if not genuinely through Subversion)
    3) To have it work on jar, war, ear, files, you have to make sure that the file is not compressed (otherwise the pattern might not appear in clear). I don't know whether that's easy to configure using Ant's jar, war, ear tasks.
    A bit of a hassle compared to stuffing your own utility class and using java -cp...

Maybe you are looking for