Invoking JAR within an EAR

I am having trouble invoking my project which is packaged in a jar and the jar is then packaged in an ear file.
I need to deploy this big ear file onto an AIX server. No single jar file can be deployed onto the server so I have no option but to include my batch project into the ear file, however, when I try to invoke my main within this jar (within the ear), the class can't be found! Can anyone help me with this? Thanks!

oh also I forgot to mention that I am invoking my program via shell script.
My script invokes the main function, so my first problem is not being able to 'see' that main function in my ear.I did, however, defined my ear file inside the classpath and used the classpath option when calling my programs. Thanks!

Similar Messages

  • Loading applet for a jar within an ear

    Hi,
    Apologies if my question sounds ignorant, this is the first time i'm playing with applets.
    I'm trying to load an applet from a JAR (applet.jar) which contains all the files specific to the applet. The applet.jar resides within an ear (application.ear) which is deployed on JBoss.
    The applet related stuff is in the package com.dms.applet (which makes up the applet.jar)
    My index.html resides in a war file (webapp.war), which essentially contains a bunch of servlets. Index.html is a two frame page, which tries to load the applet in one frame and a servlet in another (servlets work fine).
    My <APPLET> tag for the frame in which the applet is displayed (is another html file - applet.html) looks something like this:
    <html><body>
    <APPLET
         code="com.dms.applet.NavigationApplet.class"
         codebase=./"
         archive="applet.jar, application.ear"
         width=200
         height=500
    >
    </APPLET></body></html>
    however, the applet always fails to load, i get the following exception when i open the java console:
    java.lang.ClassNotFoundException:
    com.dms.applet.NavigationApplet.class
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: open HTTP connection failed.
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 10 more
    load: class com.dms.applet.NavigationApplet.class not found.
    java.lang.ClassNotFoundException:
    com.dms.applet.NavigationApplet.class
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: open HTTP connection failed.
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 10 more
    It seems evident that the applet class loader can't find my applet.class and hence can't load it. I guess that its something wrong with my <APPLET> tag, but can't quite seem to get my finger on it. Do i need to explicitly tell the class loader to look for it in the applet.jar which is in the applicatin.ear?
    Any help would be very much appreciated.
    Thanks in advance
    EnterpriseJavaBones

    Hi,
    I managed to fix this problem. For those who mite come across the same issue in the future, this is how i did it.
    I put the applets code in the war file under an applet dir. That the the index.html is in the root (of the war dir) and the applets code is in a /applet dir.
    Hence the codebase simply reads, codebase="applet/"
    Cheers
    EnterpriseJavaBones

  • Referencing an optional package in a jar inside an ear

    UPDATE: We no longer need this as the third-party will change their shared-library ear to a jar for use on other application servers.
    We have no trouble deploying an ear containing a jar as a shared library, and then referencing the classes in it from another application by specifying the appropriate <library-ref> in weblogic-application.xml.
    In some installations, that shared library is not required, and indeed may not be present. In that case, the <library-ref> is unresolved, and the application will not deploy. We would like to avoid having two versions of our application - one with the <library-ref> and one without.
    If we add the Extension-Name property to the manifest of the jar mentioned above, and deploy the jar (not the ear) as a shared library, our application can reference classes in that jar. The problem is that the library ear (containing the jar) comes from a third party, and we cannot extract out the jar. And the "optional package" mechanism does not appear to work for jars within ears. We've specified the Extension-Name from the library ear ( the one from the library jar is not visible) in the Extension-List of the application. There is no complaint that the optional package is unresolved, but accessing the classes gives ClassNotFoundException.
    I did not find any documentation that optional package jars within an ear should be visible to other deployment units, but it seems odd that the third party would package them such that they can only be referenced with the <library-ref> (i.e. on WLS).
    http://download.oracle.com/docs/cd/E12840_01/wls/docs103/programming/libraries.html
    http://java.sun.com/j2ee/verified/packaging.html
    Edited by: mikereiche on Nov 11, 2011 4:34 PM

    The JarInputStream class is used to read the contents of a JAR file from any input stream.
    InputStream input=getResourceAsStream("/input.xml");
    JarInputStream jis
    =new JarInputStream(input);

  • Deploying jars within a single (exploded) ear

    Our project currently uses 8.1 SP3 with split deployment structure.
    Currently the project is split into multiple ears deployed on a single (managed) server. It is my understanding that calls made across ear's even on the same server (jvm) need to be marshalled and unmarshalled using pass by value.
    We are trying to consolidate all our EJBs and Web apps into a single .ear so that we can take advantage of call-by-reference. We also have a requirement of being able to deploy "groups" of EJBs (within a single jar) and/or a web app. Deploying a single ear for the entire project would be one extreme, as it would be painful to deploy individual modules within the ear. On the other hand, using an exploded ear would be too "granular" a way of deploying our changes (we have many EJBs, etc.).
    Is it possible to deploy an exploded ear consisting of jar and war files ? I am in the process of trying this and was looking for feedback. The idea is of being able to deploy parts of the app, such as a .jar or a .war file. Can wlpackage create an exploded ear using .jar and .war files instead of modules consisting of .java/.jsp, etc. files? Thanks for your help!

    There is a classpath issue. Normally ejbs are loaded on top of the ears classpath, so whenever you redeploy them, you have to redeploy the webapps, too. In 8.1 you can build your custom class loader hierarchy. Take a look at http://e-docs.bea.com/wls/docs81/programming/classloading.html#1065667
    -Kai

  • How to share dependant jars across rars & ears / avoid classcast exceptions

    <b>How can one share dependant jars between a ear application and a resource adapter and avoid getting a ClassCastException? </b>
    <P>
    In some appservers(such as Oracle) the resource adapter is the parent of your ear classloader, so a single instance multiple classloader problem doesn't occur. But in some appservers such as BEA Weblogic this isn't the case. Not sure why BEA decided to make resource adapter class loader seperate and not the parent of ear loader...
    <P>
    If I bundle the resource adapter specific classes in the corresponding module archive file, I will get a class cast exception, becos I will have a <i>single instance and multiple class loader situation</i> (assuming resource adapters uses its own classloader).
    <P>
    Second question related to the above: Web logic documentation recommends that we bundle the common files in APP-INF direcotory for embedded resource adapter apps. If I start bundling the resource adapter in an ear file, for every ear app we will have a rar bundled. What about the JNDI names? won't you have to rename the resource adapter differently for each ear so that there is no jndi name clash? Doesn't this defeat the purpose of having one common connector for all apps?
    <P>
    Here is a detailed description of what I want:
    Let say you have a ear file. Let's say there is a common.jar shared between your ear application (say the ejb module uses it), and your resource adapter.
    <P>
    In the case of Oracle's OC4J I can see there won't be any problem of having this common.jar part of the resource adapter(RA). When the RA class loader loads the rar, it makes sure the common.jar files are accessible in the chain of all class loaders it is a parent of. So, the ear loader, ejb loader etc...will have visibility -> hence no class cast exception.
    <p>
    But what do clients do when they want to have their ear deployable across multiple appservers not just oc4j. BEA recently changed their class loader structure...their resource loader is no longer parent of the ear, so the ejb app in the ear doesn't have visibility into common.jar packaged with rar. So, the only solution was to bundle the common.jar file with the ear. But this causes problems, because we can have a situation where certain object instances (that are not serialized or copied) can be shared across class loaders. This ends up in the single instance multiple class loader situation->hence classcastexception.
    <p>
    The only solution I found was to make the common.jar file a shared library. That way only one copy of the class files are there for both the rar and the ear and its visibility is there not only for rar but for ear since it is loaded by the system class loader or shared library class loader (if ther eis one such).
    <P>
    Please convey best practise recommendation.
    Sudhakar

    Pete <[email protected]> wrote:
    Is there a way to have a non-EJB jar at the EJB classloader level ? Sure, just add it to the Class-Path: manifest entry in your ejb.jar.
    Dimitri

  • How to access a jar file in EAR file?

    I have a EAR file which contains EJB.jar file and util.jar file. Outside of EAR, I mean in client side, I need to reference util.jar file. How can I access it?
    EAR structure is
    |--+META-INF/
    |--|---application.xml
    |--|---manifest.mf
    |--EJB.jar
    |--|---+MEAT-INF/
    |--|---|--- deployment descriptors...
    |--|---|--- manifest.mf
    |--|--- EJB classes
    |--Util.jar
    Util.jar must be executed in server side. If I just add Util.jar in client program's classpath, when client program is executed, serverside Util.jar is executed? Or what else I should do in the client program to reference server-side Util.jar?

    Excellent question. I don't see any client-jar in your EAR file structure. So I am assuming you are writing a separate client application which will talk to the ejbs deployed as part of this EAR. You need to do the following:
    Write another EAR file with the following structure:
    ear:
    META-INF/application.xml
    util.jar
    client.jar
    client.jar should have a META-INF/MANIFEST.MF and that should contain Class-Path:util.jar and value for Main-Class attribute.
    Now deploy this new ear to your application server and execute it using Application Client Container that comes with your app server.
    If you don't want to write another EAR file, then bundle th client.jar in your original EAR file.
    Points to note are:
    you have to repackage util.jar again inside this ear file.
    For portability reason, you should use Class-Path manifest entry in client.jar. Refer to http://java.sun.com/j2ee/verified/packaging.html and J2EE platform spec section #8.2.
    Hope this helps,
    Sahoo

  • How to Create a jar war or ear--Probelms in deploying

    I have the following dir structure. I am using Struts 1.1 and weblogic 7.0
    APP
    +jsp
    +WEB-INF
    + ---lib
    +--- classes
    +----com
    --ap
    --action
    --beans
    --handler
    --service
    --client
    --ejb
    --valueobject
    1> Do I need to create a ear file since i want both the ejb (under service folder) and war as reusable components. Whenever we have a EJB component do we always need to have an EAR file??
    2> Whats the best way to create the jar, war or ear file. I am facing great difficulty in deploying the war.Do we need to set any classpath before we create the war and jar files except for the deployment descriptors.I have created the ejb descriptors correctly through ejbc.
    3>I have kept struts.jar,log4j.jar under lib folder. However when i create the ear and try to deploy it under weblogic it deploys the war file but gives error in deploying the jar which has the ejb. I have aslo validated the jar using ejbc.
    It gives error indicating that it requires struts.jar in classpath. If we give the classpath of struts.jar at system leve the Application deploys with ease..Can anyone tell whats the error.The jar does not use any strust component .
    4>Also the valueobject which has some beans which are used to populate the jsp through Actionformbean. Is it ok if we give refrences in both ejb jar and war?
    ie while creating jar and war folder have the valueobject in both the files or will it lead to any errors..
    Thanks in Advance
    ....

    Yes, I have tried that. But, as the server is running and the jars are in use, it throws and EditFailedException

  • Jar, War or Ear file ?

    Hi,
    I am a total newbie in J2EE technology.
    I am currently using Sun One Application. Using the sample application, it produces all the Jar, War and Ear files.
    My understanding is Jar is produced to be a library-like usage.
    War is for web application.
    And Ear is for what?? oops EJB? Can someone tell me?
    Anyway, my concern is, if I am to produce Ear, war, or Jar file after deploy, I have problems doing the testing. Let's say I want to modify the Jsp file, then I have to use ant to compile all, undeploy the instance and deploy again.
    Any better way?

    your jar files contain your EJBs, your WAR file contains your web application (JSPs, servlets and support) and these are all bundled into your EAR file. All of these files are just zip-formatted archives, you can look at them all via the jar tool (or something like WinZip, if you are so inclined). Each of these will contain a descriptor file (in XML format) - check out the J2EE spec on it.
    Lee

  • Changing values in property file inside a jar in an ear

    Hi,
    I have an application that contains EJB. The environment values needed for initial context of the ejb is kept in a .properties file. I have created an ear of the application. Inside the ear there is a jar which contains the .properties file. I need to deploy the ear to different environments. However before deploying I need some kind of script to change the values in the .properties file inside the jar in the ear.
    Can anyone provide some help/pointers about how can I achieve it (Using ANT/WLST)

    WLST does not have any capability to update a JAR.
    WLS 10.3 (still in tech preview) has the ability to override properties
    files inside the jar with an external properties file. This would allow you
    to deploy the same ear to different environments, and then only deploy a
    different properties file in the plan directory.
    <Rishi Shah> wrote in message news:[email protected]..
    Hi,
    I have an application that contains EJB. The environment values needed for
    initial context of the ejb is kept in a .properties file. I have created an
    ear of the application. Inside the ear there is a jar which contains the
    .properties file. I need to deploy the ear to different environments.
    However before deploying I need some kind of script to change the values in
    the .properties file inside the jar in the ear.
    Can anyone provide some help/pointers about how can I achieve it (Using
    ANT/WLST)

  • How many Ways jar files from ear file on a jboss can be downloaded on clien

    Aoa
    How many Ways jar files from ear file on a jboss can be downloaded on client side
    like jnlp etc..
    Regards
    M Fazal Ur Rehman

    First, you need to be able to boot from the Recovery HD:
    Boot Using Command+R keys:
      1. Restart the computer.
      2. Immediately after the chime press and hold down the
          "COMMAND" and the "R" keys together.
      3. Release the keys when the Utilities Menu appears.
    Once at the Utilities Menu select Terminal from the Utilities menu in the screen's menubar. Now, you need to know where these new files are located. You move to any location using the 'cd' command such as cd /Users/user_name/Documents, then press RETURN. Replace user_name with your actual username. Next you need to do a directory listing to see if your files are in that location, Documents. Use ls -al to do a directory listing of the files and folders in Documents. If you find your new files there, then connect an external drive or flash drive. You will need to know the name you have assigned to this drive. It needs to be already formatted. Copy your files using cp /Documents/filename /Volumes/volname/filename. Replace volname and filename with those that apply. Press RETURN.
    Or take it to your local Apple Store and see if they can do the chore for you.

  • Invoke jar main method in java code

    hi
    i have a jar that has a usage like this
    java -jar helper.jar arg1 arg2 etc...i want to invoke this helper main method in my java code.i've tried using reflection but it didn't quite work...
    String[] args = new String[]{"arg1","arg2"};
    Class c = Class.forName("com.helper.MainClass");
    Method mainMethod = c.getMethod("main", args.getClass());
    int mods = mainMethod.getModifiers();
    if(mainMethod.getReturnType() != void.class || !Modifier.isStatic(mods) || !Modifier.isPublic(mods)) {
         throw new NoSuchMethodException("main");
    mainMethod.invoke(null, args);
    Exception in thread "main" java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at Test.callJarMain(Test.java:50)
    at Test2.main(Test.java:34)thoughts???

    phychem wrote:
    i want to use this jar in a non-static way.
    public void useJar(String args[]){
    //somehow invoke jar method here...
    Sorry, I still don't get it. I don't know what you mean by a non-static way of using jars. The main method for launching an application is static so if you call that method, you will be using a static method. I don't know what you mean by a "jar method" either. Methods are inside classes. So far, all I can guess is you want to invoke a method in a class that happens to be inside a jar. Since people do this all the time without reflection, I don't see the problem.

  • Spring Packaging within an EAR

    Can Spring be packaged within the ear?

    boucha01 wrote:
    Can Spring be packaged within the ear?Sure, why not?
    Know how to create an EAR?
    Which Java EE app server are you using?
    %

  • Include my jars in a ear

    Hi, i'm using servicegen ant tag to create an ear from my webservice.
    Everything is ok, but i don't know how to include into the ear file the other
    jar i use?.
    If i put this jars in the wls classpath, my webservice works fine, but i want
    to put the jars into the ear and just deploy it.
    I'm using jdk 1.3.1, WLS 7.0
    Thanks.
    Alana

    Hi Alana,
    wspackage will help you do this, see:
    http://edocs.bea.com/wls/docs81/webserv/anttasks.html#1091121
    Hope this helps,
    Bruce
    Alana wrote:
    >
    Hi, i'm using servicegen ant tag to create an ear from my webservice.
    Everything is ok, but i don't know how to include into the ear file the other
    jar i use?.
    If i put this jars in the wls classpath, my webservice works fine, but i want
    to put the jars into the ear and just deploy it.
    I'm using jdk 1.3.1, WLS 7.0
    Thanks.
    Alana

  • Referencing a jar inside an ear

    Hi,
    I have a program where I need to get a reference to a jar inside an ear
    file. For example, I have this variable set:
    $WL_HOME/config/mydomain/applications/test.ear and I want to set a variable
    for a jar inside this ear.
    Does anyone know the best way to do that?
    Thanks

    When you say "set a variable", do you mean read an XML or properties file
    and modify it and write it back?
    It is relatively simple using the java.util.zip / java.util.jar packages.
    Editing XML is a little harder; I would suggest relying on something like
    JDOM or the libs from The Mind Electric.
    Peace,
    Cameron Purdy
    Tangosol Inc.
    Tangosol Coherence: Clustered Coherent Cache for J2EE
    Information at http://www.tangosol.com/
    "Diane Curley" <[email protected]> wrote in message
    news:[email protected]..
    Hi,
    I have a program where I need to get a reference to a jar inside an ear
    file. For example, I have this variable set:
    $WL_HOME/config/mydomain/applications/test.ear and I want to set avariable
    for a jar inside this ear.
    Does anyone know the best way to do that?
    Thanks

  • Jars within Jar

    Hello All,
    I have written a custom ant task and have made a jar and placed it in Ant's lib directory. The jar file has some dependencies which are jar files them selves (jdom.jar,commons-lang.jar and javagit.jar to be exact). It also has a dependency on ant.jar but I have not included that in the application's jar file.When I execute the custom ant task, I get an error "ClassNotFoundException" for classes that are being used in the Custom Ant Task class (except for Classes in ant.jar).When I extract the dependencies and then create a jar file (no jars within the jar file), it works fine !
    Here is the METAINF file when the dependencies are extracted
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.1
    Created-By: 11.0-b15 (Sun Microsystems Inc.)
    Class-Path: . (in case of jars --> jdom.jar javagit.jar commons-lang.jar)
    1. How come I am not getting any errors for classes in ant.jar ?
    2. Can any one kindly explain why the JRE can't find the files from with in the dependencies as jar files as opposed to dependencies as extracted files ?
    3. Is there a way to create a jar file with dependencies as jar files and how to configure it so that the runtime can find the files from within the jar files ?
    Waiting for a favorable response.
    Kind Regards.

    Put the dependency jars file in to "C:\pogram Files\Jre1.6/lib/ext folder.It will load automatically during execution

Maybe you are looking for