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

Similar Messages

  • How To Access a jar file present outside the war file through a jnlp

    Aoa
    I m new to this forum
    I m having problem with my jnlp file
    i want to know is there any way to access a jar file through jnlp.The problem is that my jnlp file is present in the war file
    and i want to know how to acess a jar file through this jnlp.The scenerio is as below
    I m using ear file on jboss.Its hirerchy is as
    -PAN-war.war
    -launch.jnlp
    -PAN-app-client.jar
    my jnlp file is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://localhost:8080/" href="PAN/launch.jnlp">
    <information>
    <title>PanEmirates</title>
    <vendor>M Fazal Ur Rehman</vendor>
    <description>PanEmirates</description>
    <description kind="short">PanEmirates</description>
    <homepage href=""/>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.5+"/>
    <jar href="PAN-app-client.jar" download="eager"/>
    <jar href="lib/javafxrt.jar" main="true" download="eager" />
    <jar href="lib/Filters.jar" download="eager"/>
    <jar href="lib/javafx-netbeans-fxuserlib.jar" download="eager"/>
    <jar href="lib/swing-layout-1.0.3.jar" download="eager"/>
    </resources>
    <application-desc main-class="net.java.javafx.FXShell">
    <argument>pan.Main</argument>
    </application-desc>
    </jnlp>
    when i run launch.jnlp file it says unable to download resource http://localhost:8080/PAN/PAN-app-client.jar
    how to access this jar file
    Any help or comment would be highly appreciated
    Regards
    M Fazal Ur Rehman

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

  • How to use Connection Pool in ADF ear file creaion from jDev 10.1.3

    Hi,
    We are developing big application in ADF with 10 different modules. We are creating ear file with data source setting.
    How to use connection pool while creating ear file from jDev. Connection pool is alreday created in Application Server 10g.
    What all the setting we need do to make use of connection pool while creating ear file jDev.
    Thanks

    User,
    If you are using ADF Business Components, you can right-click each application module, select "configurations" and edit the configuration you are using. On the initial page of the configuration dialog, you can specify to use either a JDBC URL or a Datasource - you just need to choose Datasource and then provide the name by which to access it.
    John

  • Difference between .jar, .war and .ear file

    Hi,
    I am pretty new to J2EE technology.
    I would like to know what is the difference between .jar, .war and .ear files and how they are deployed on webserver.
    Thanks,

    Files with a .jar extension or JAR files, are essentially just a collection of files compressed using the ZIP/ZLIB compression format.
    JAR (short for Java Archive) files were introduced in the early days of Java as a means to conveniently package and distribute Java applications and components. Since then, a number of additions to the Java platform have followed suit. The introduction of the EAR file is one such addition.
    An EAR (Enterprise Archive) file is a JAR file that contains a J2EE application.
    A J2EE application is a group of Web modules that collectively perform as a single entity.
    A Web Module is an entity consisting of one or more resources such as HTML files, Java class files, XML files, etc. Web Modules are packaged in Web Archive (WAR) files.
    Looking at it from a top-down view, EAR files contain JAR files and WAR files. Packaging resources in WAR files, JAR files and eventually EAR files, makes it easy to reuse and reassemble components as new J2EE applications and distribute them to new environments.
    For example, Tomcat deals only with WAR files.
    So, in order to auto-deploy a Web application to a Tomcat environment, you must place an application's WAR file in the appropriate directory or use Tomcat's deployment tools to manually deploy the file.
    If you already have an EAR file that contains the WAR file, you can extract the WAR file and use it as is. If you do not have the EAR file or the WAR file, you can use any number of compliant tools to create the WAR file. Tomcat is a servlet/JSP container available from the jakarta.apache.org site.

  • How do I convert an war file to ear file, deploying weblogic apps

    Problem Description: I have a war file from a legacy application that needs to be migrated to weblogic. To migrate this application to weblogic, we need a ear file. Reading weblogic doc. it says we needs to use ant utility on an exploded web content application folder/ directory to create the ear file. I need to covert the existing war file to ear file , if it is doable or create one from the scratch. I need to know how to do that in weblogic. Please let me know if you have any hints .
    Thanks

    HI,
    Please try the following to convert your WAR file into an EAR exploded archieve:
    *1).* Create a Directory in your file system.
    Example:
    /home/apps/MyFirstEAR
    *2).* Place the WAR file inside the above Directory. (Suppose your WAR file name is test.war)
    Example:
    /home/apps/MyFirstEAR/test.war
    *3).* Now create a "META-INF" directory inside "/home/apps/MyFirstEAR" directory
    *4).* Now create an "application.xml" file like following inside "/home/apps/MyFirstEAR/META-INF" directory:
    <?xml version="1.0" encoding="UTF-8"?>
    <application xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.4">
    <description>Test EAR Example</description>
    <display-name>TestEAR Example</display-name>
    <module>
    <web>
    <web-uri>test.war</web-uri>
    <context-root>test</context-root>
    </web>
    </module>
    </application>
    *5).* Your EAR is ready now you can deploy the "MyFirstEAR" directory in the WebLogic Server.
    NOTE: if you want to place the "test.war" file also as an exploaded format content inside the EAR then you need to extract the test.war file and then in place of the test.war you can have "test" directory at the same place.
    You need to change the "application.xml" file like below in that case:
    <?xml version="1.0" encoding="UTF-8"?>
    <application xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.4">
    <description>Test EAR Example</description>
    <display-name>TestEAR Example</display-name>
    <module>
    <web>
    <font color=red> <web-uri>test</web-uri> </font><br>
    <context-root>test</context-root>
    </web>
    </module>
    </application>
    For more information on an EAR application structure you can refer to : http://middlewaremagic.com/weblogic/?p=1952
    Thanks
    Jay SenSharma
    http://middlewaremagic.com/weblogic (Middleware Magic Is Here)

  • 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

  • How to include external .js file into .ear file using NetBean 5.5.1?

    is it possible to include external .js file into .ear file using NetBean 5.5.1? if not, then where should I placed the external .js file and how to write the src="xxx" element? (that is , how to write the path of "xxx"?)
    I am using JBOSS 4.2.2 GA as server
    thx!!

    Even this is also not possible because, the code in that package is developed by DWR and i am just adding it to my lib folder and importing the respective classes. In the same manner i need to include the *.js* file in the JSP.It took me about 3 minutes reading through the [DWR Getting Started|http://getahead.org/dwr/getstarted] page to learn that you don't have to do any of that. Perhaps you should read that page?

  • 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

  • Difference between .war file and .ear file

    Hi,
    what is the difference between .war file and .ear file ?
    Please let me know with appropriate explanation.

    War file means web application archive. It is archived file having a collection of JSP, servlets and static pages that together costitute a web application. It contains one WEB-INF directory which will have a file named web.xml which defines the structure of the web application.
    On the other side EAR file is Enterprise application archive. It is file having packaged content of one or more modules into a single archive so that the deployment of all the modules can be done simultaneously on the application server. It also contains XML files called deployment descriptors which gives the details of the deployment method. This deployment descriptor will be present in the folder META-INF folder.
    So the main difference betwwen the two is that Ear file is having collection of various modules to be deployed on the application server while the WAR file is used to deploy the web applications.

  • How to access ejb jar in ear package from other war web package?

    How to access ejb in jar packed in ear package from other war web package?

    Typically you would just look the EJB Home up in JNDI. If you're
    looking for example code, the medrec example in WLS 8.1 or petstore has
    plenty of webapps calling EJBs.
    -- Rob
    CottonXu wrote:
    How to access ejb in jar packed in ear package from other war web package?

  • 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 PAR file from EAR file

    Hi,
       I have created an Web Dynpro Application . When i deploy it in Remote J2EE Engine, it will deploy as EAR file. It then runs as normal Web Application in Web browser. My requirement is to create an iView for my Web dynpro appn in EP. That is possible only by creating a PAR file. so How to create an PAR file from EAR in NWDS(NetWeaver Developer Studio).
    How to access the EAR file in NWDS or J2EE ?
    Thanks in Advance ,
    By
    Saravanan

    Hi,
    To create a iview,
    log on to portal, New iView and select SAP webdynpro iview.
    It will ask for namespace which is usually , local/Project Name
    and application name is the name of the application.
    We dont have to create par file for this requirement

  • How to access the content in the configuration files

    Hi, Folks,
    To make it easy, the questions can be like this:
    how to access the content in web.xml in a web application?
    Through ServletConfig and context?
    how to access the content in ejb-jar.xml in an ejb?
    initial context?
    Thanks

    There is no documented way to delete data stored in archived log files: you can only remove the archived log files if needed.

  • How to access variables declared in java class file from jsp

    i have a java package which reads values from property file. i have imported the package.classname in jsp file and also i have created an object for the class file like
    classname object=new classname();
    now iam able to access only the methods defined in the class but not the variables. i have defined connection properties in class file.
    in jsp i need to use
    statement=con.createstatement(); but it shows variable not declared.
    con is declared in java class file.
    how to access the variables?
    thanks

    here is the code
    * testbean.java
    * Created on October 31, 2006, 12:14 PM
    package property;
    import java.beans.*;
    import java.io.Serializable;
    public class testbean extends Object implements Serializable {
    public String sampleProperty="test2";
        public String getSampleProperty() {
            return sampleProperty;
    }jsp file
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.sql.*,java.util.*"%>
    <html>
    <head>
    <title>Schedule Details</title>
    </head>
    <jsp:useBean id="ConProp" class="property.testbean"/>
    <body>
    Messge is : <jsp:getProperty name="msg" property="sampleProperty"/>
    <%
      out.println(ConProp.sampleProperty);
    %>
    </body>
    </html>out.println(ConProp.sampleProperty) prints null value.
    is this the right procedure to access bean variables
    thanks

Maybe you are looking for