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

Similar Messages

  • 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);

  • Startup class not found if included in a jar inside the ear

    I have written a startup class, i have packed it in a jar file(along with some
    other classes). This jar is then packed in side an ear file.(This way i get one
    single distribution file). I have added the startup class in the config.xml using
    weblogic console.But at start up weblogic is unable to find the class. How to
    tell weblogic about the location of the class(classpath) which is inside the ear
    file. Error i get is as follows
    <Aug 21, 2003 8:07:23 PM IST> <Emergency> <WebLogicServer> <BEA-000342> <Unable
    to initialize the server: weblogic.t3. srvr.FatalStartupException: Can't start
    server due to startup class failure WISORCODES_SERVER - with nested exception:
    [java.lang.ClassNotFoundException: com.wisor.common.wisorcodes.rmi.WisorCodesServer]>
    *************************************************************************** The
    WebLogic Server did not start up properly. Exception raised: 'weblogic.t3.srvr.FatalStartupException:
    Can't start server due to startup class failure WISORCODES_ SERVER - with nested
    exception: [java.lang.ClassNotFoundException: com.wisor.common.wisorcodes.rmi.WisorCodesServer]'
    Reason: weblogic.t3.srvr.FatalStartupException: Can't start server due to startup
    class failure WISORCODES_SERVER - wi th nested exception: [java.lang.ClassNotFoundException:
    com.wisor.common.wisorcodes.rmi.WisorCodesServer] ***************************************************************************

    Shirish:
    Classes that are scoped in the application are only visible within the
    application, not to the system classloader.
    If you want to have startup classses scoped inside an EAR then you need to
    use Application lifecycle listeners to actually activate these startup
    classes. Application lifecycle listeners are a replacement for startup
    classes.
    You can check out an example of this in 8.1:
    $BEA_HOME/weblogic81/samples/server/examples/src/examples/splitdir/helloWorl
    dEar
    Docs for it are:
    $BEA_HOME\weblogic81\samples\server\examples\src\examples\splitdir\helloWorl
    dEar\javadoc\index.html
    Check out:
    $BEA_HOME\weblogic81\samples\server\examples\src\examples\splitdir\helloWorl
    dEar\META-INF\weblogic-applcation.xml
    <weblogic-application>
    <listener>
    <listener-class>examples.splitdir.hello.startup.ApplicationStartup</listener
    -class>
    </listener>
    </weblogic-application>
    and
    $BEA_HOME\weblogic81\samples\server\examples\src\examples\splitdir\helloWorl
    dEar
    /appStartup/examples/splitdir/hello/startup/ApplicationStartup.java
    Now if you have a "startup class" that needs to be accessible for the entire
    Server for a set of applications, I suggest just writing a single EAR with a
    dummy web-app (I think you may need a dummy module) and an applicaiton
    lifecycle listener, and have this EAR deploy before any other apps.
    Cheers
    mbg
    "Shirish" <[email protected]> wrote in message
    news:[email protected]...
    >
    I have written a startup class, i have packed it in a jar file(along withsome
    other classes). This jar is then packed in side an ear file.(This way iget one
    single distribution file). I have added the startup class in theconfig.xml using
    weblogic console.But at start up weblogic is unable to find the class. Howto
    tell weblogic about the location of the class(classpath) which is insidethe ear
    file. Error i get is as follows
    <Aug 21, 2003 8:07:23 PM IST> <Emergency> <WebLogicServer> <BEA-000342><Unable
    to initialize the server: weblogic.t3. srvr.FatalStartupException: Can'tstart
    server due to startup class failure WISORCODES_SERVER - with nestedexception:
    >
    >
    [java.lang.ClassNotFoundException:com.wisor.common.wisorcodes.rmi.WisorCodesServer]>
    >
    The
    WebLogic Server did not start up properly. Exception raised:'weblogic.t3.srvr.FatalStartupException:
    Can't start server due to startup class failure WISORCODES_ SERVER - withnested
    exception: [java.lang.ClassNotFoundException:com.wisor.common.wisorcodes.rmi.WisorCodesServer]'
    Reason: weblogic.t3.srvr.FatalStartupException: Can't start server due tostartup
    class failure WISORCODES_SERVER - wi th nested exception:[java.lang.ClassNotFoundException:
    com.wisor.common.wisorcodes.rmi.WisorCodesServer]***************************************************************************
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >

  • Referencing a jar inside another jar

    Hi All,
    If there is a jar "B" inside jar "A", how to include jar "B" in the manifest's classpath of jar "A"??
    Regards,
    P

    let me know if you figure out the answer to this question. I am working on a executible jar and I reference lib/somJar.jar on my manifest file. I thought that it was working because it was loading, but when I tried to move the jexeutible jar it no longer worked. Well I found that it was loading the information from the directory, which was teh same directory that I used to jar the files rather than the actuall jar file.

  • 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)

  • Using JMX to read ejb manifest jar and ejb-jar.xml in ejb jar inside ear

    Hello,
    I have an ear deployed on weblogic console. I need to check contents of manifest file and ejb-jar.xml of a jar that is present in the deployed ear.
    Currently I am using below code to access jar inside ear deployed :
    Hashtable env = new Hashtable(5);
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    env.put(Context.PROVIDER_URL,
    url);
    env.put(Context.SECURITY_PRINCIPAL, user);
    env.put(Context.SECURITY_CREDENTIALS, password);
    Context ctx = new InitialContext(env);
    mBeanHome = (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
    String type = "EJBComponentRuntime";
    Set beans = mBeanHome.getMBeansByType(type);
    try{
    for(Iterator it=beans.iterator();it.hasNext();)
    EJBComponentRuntimeMBean rt = (EJBComponentRuntimeMBean)it.next();
    if(rt.getParent().getName().equals("xxx")){
    System.out.println(rt.getName());
    l.add(rt.getName());
    Here xxx is the ear. Now I need to get inside the jar (represented) by variable rt and access its manifest file,ejb-jar.xml
    Does anyone have an idea how to do this?
    regards
    Sameer

    Isn't it possible to put them there manually? :)

  • 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

  • Where to put Third Party Jars in an .ear file

    Where to put Third Party Jar files in an .ear file so that they can be packaged along with the entire application and thus bypass the trouble of putting the third party .jars inside the application server lib directory and set the class path.

    Just put them in the root of your EAR. You can specify them in the classpath of your EJB JAR's manifest.

  • 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!

  • Property (config) files inside an EAR

    I would like to deploy the configuration files for my application inside an EAR
    file so I do not have to modify the classpath for my server (WLS 8.1 sp2).
    My quesion is can I make all the property files available to all the EAR components
    (WAR and JAR) by putting them somewhere in the EAR or do they need to be on the
    class path?

    They don't need to be in the classpath.
    If you're on 8.1, then placing the properties file in the
    APP-INF/classes directory would make it accessible for anything in the
    EAR. I'd probably use an ApplicationLifecycleListener to read it when
    the app deployed.
    If you're using < 8.1, I'd use either a ServletContextListener or a
    load-on-startup servlet in a "fake" webapp to read the file.
    Let me know if you need more details.
    -- Rob
    Pete wrote:
    I would like to deploy the configuration files for my application inside an EAR
    file so I do not have to modify the classpath for my server (WLS 8.1 sp2).
    My quesion is can I make all the property files available to all the EAR components
    (WAR and JAR) by putting them somewhere in the EAR or do they need to be on the
    class path?

  • 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 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

  • JARs inside my JAR

    Hi Folks,
    I'm creating a JAR file for my application. My app uses another JAR file and I want to package it inside my jar.
    I tried to use "Path-Class" attribute in MANIFEST.MF file but without success.
    Any help would be appreciate.
    TIA.
    Romualdo Rubens de Freitas

    I wonder how you missed to recognize that jars DO contain jars for four years, as you subscribed in 2001.
    Of course the standard class loader cannot handle jars in jars, but many solutions do exist for this problem. (It was really a problem, since almost all java applications are required to ship with jars inside jars).
    The best solution I encountered, is the fat_jar plugin for eclipse. If you are not an eclipse user try ONEJar.
    Being silent is sometimes better than to provide non-solutions for problems for which solutions exist.

  • 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.

Maybe you are looking for