Packaging libraries in EAR
Hello,
My J2EE app uses an external library, let's call it ExtLibrary. So, MyApp.ear contains MyEJBs.jar and ExtLibrary.jar.
My EJB produces ClassNotFoundException because it doesn't find a class located in ExtLibrary.jar.
Where should I place the ExtLibrary.jar in the EAR?
What should I do to link MyEJBs.jar with ExtLibrary.jar?
Thanks for your help,
Gerald
This packaging issue is covered in the J2EE platform spec (section 8.2 Optional Package Support), located here: http://java.sun.com/j2ee/1.4/download.html#platformspec
The basic idea is to use the Class-Path attribute in the manifest file of your EJB archive to point at your library jar (all packaged in the same application archive - ear file). J2EE platforms must support this feature. There are some good examples in the platform spec that demonstrate this feature.
Similar Messages
-
JAVA application packaged as an EAR
we are upgrading our system to Oracle 12i and we have a custom java application that access the Oracle API. As part of this upgrade we have to deploy our JAVA application packaged as an EAR file to OC4J that comes with Oracle EBS. All we need is sequence of steps/ some document that will help us deploy our JAVA application(EAR file) to OC4J server.
1. Can we create another instance of OC4j in Oracle 12i(12.1.3)?
2. Will there be any integrity issue if we deploy ear file to Oacore/Forms/OAFM oc4j instance integrated with R12? or Do we need to create a new instance?
3. I was told by the support engineer that there is no EM console for oc4j integrated with R12, so is there any script provided by oracle to do any ear deployment?1. Can we create another instance of OC4j in Oracle 12i(12.1.3)?
2. Will there be any integrity issue if we deploy ear file to Oacore/Forms/OAFM oc4j instance integrated with R12? or Do we need to create a new instance?I do not think it is supported -- Please log a SR to confirm with Oracle support.
3. I was told by the support engineer that there is no EM console for oc4j integrated with R12, so is there any script provided by oracle to do any ear deployment?Please see (Deploying a New Forms .ear File in Oracle Applications Release 12 [ID 397174.1]).
Thanks,
Hussein -
Packaging & deploying an ear file
I am trying to write a script to package and deploy our application from a source-code directory structure. The script is named build.cmd and I've tried to model it off of the build.cmd script that ships with the sample PetStore application. I've attached the build.cmd file.
I can get the script to work, except for the part where it tries to pre-compile JSP's. However, when I try to login to the "Login" servlet, I get the following error:
java.lang.NoClassDefFoundError: com/edeploy/util/EdeployConfig
at com.edeploy.pers.Login.defaultAction(Login.java:67)
at com.edeploy.pers.Login.doPost(Login.java:48)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:208)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:1127)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:1529)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
This is even though the EdeployConfig.class file is packaged in the .ear. I think it has something to do with the web.xml file in the war file - but
I can't get it to work.
The web.xml file is as follows:
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<display-name>WebTier</display-name>
<description>no description</description>
<servlet>
<servlet-name>Login</servlet-name>
<display-name>LoginServlet</display-name>
<description>no description</description>
<servlet-class>com.edeploy.pers.Login</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/pers/Login</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>EdeployConfig</servlet-name>
<display-name>EdeployConfig</display-name>
<description>no description</description>
<servlet-class>com.edeploy.util.EdeployConfig</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>EdeployConfig</servlet-name>
<url-pattern>com/edeploy/util/EdeployConfig</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>120</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>/edeploy.html</welcome-file>
</welcome-file-list>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/util/ErrorHandler.jsp</location>
</error-page>
<resource-ref>
<res-ref-name>jdbc/DBConn</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>default</realm-name>
<form-login-config>
<form-login-page>edeploy.html</form-login-page>
<form-error-page>/pers/LoginFailed.jsp</form-error-page>
</form-login-config>
</login-config>
<env-entry>
<env-entry-name>serverType</env-entry-name>
<env-entry-value>WebLogic Server 6.0</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
</web-app>
[att1.html]
[build.cmd]I am trying to write a script to package and deploy our application from a source-code directory structure. The script is named build.cmd and I've tried to model it off of the build.cmd script that ships with the sample PetStore application. I've attached the build.cmd file.
I can get the script to work, except for the part where it tries to pre-compile JSP's. However, when I try to login to the "Login" servlet, I get the following error:
java.lang.NoClassDefFoundError: com/edeploy/util/EdeployConfig
at com.edeploy.pers.Login.defaultAction(Login.java:67)
at com.edeploy.pers.Login.doPost(Login.java:48)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:208)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:1127)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:1529)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
This is even though the EdeployConfig.class file is packaged in the .ear. I think it has something to do with the web.xml file in the war file - but
I can't get it to work.
The web.xml file is as follows:
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<display-name>WebTier</display-name>
<description>no description</description>
<servlet>
<servlet-name>Login</servlet-name>
<display-name>LoginServlet</display-name>
<description>no description</description>
<servlet-class>com.edeploy.pers.Login</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/pers/Login</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>EdeployConfig</servlet-name>
<display-name>EdeployConfig</display-name>
<description>no description</description>
<servlet-class>com.edeploy.util.EdeployConfig</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>EdeployConfig</servlet-name>
<url-pattern>com/edeploy/util/EdeployConfig</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>120</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>/edeploy.html</welcome-file>
</welcome-file-list>
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/util/ErrorHandler.jsp</location>
</error-page>
<resource-ref>
<res-ref-name>jdbc/DBConn</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>default</realm-name>
<form-login-config>
<form-login-page>edeploy.html</form-login-page>
<form-error-page>/pers/LoginFailed.jsp</form-error-page>
</form-login-config>
</login-config>
<env-entry>
<env-entry-name>serverType</env-entry-name>
<env-entry-value>WebLogic Server 6.0</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
</web-app>
[att1.html]
[build.cmd] -
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?
% -
Could you help me how to work with libraries in Developer Studio? I haven't found explanation in help.sap.com
I have EJB jar that packages into ear. All libraries from build classpath are included into ear. But I don't what to include all libraries.
How to set up which libraries I want to include into ear and add reference on it in order my EJB could work with these libraries?
I don't want to deploy this libraries separatelly.
Message was edited by: Denis IvanovHi, Denis!
You have to reference the libraries in ejb-jar.xml & ejb-j2ee-engine.xml, after the build open the jar-file with Winzip and remove the redundant files out of the archive.
Regards,
Thomas -
Java Proxy - Libraries in EAR File
Hello
I am developing some Java Proxies with the NWDS. For these mappings i need to reference some jars required by the Java Proxies
aii_proxy_xirt.jar
aii_msg_runtime.jar
aii_utilxi_misc.jar
guidgenerator.jar
does anyone know how to include these libraries in NWDS so that they don't appear in the EAR archive, because every time I build the EAR these libraries are also put into the ear (but they should not be there because they are available on the J2EE engine, and if they are left inside the EAR classloading problems appear). And it is exhausting to always 'repair' the EAR before deploying.
regards
franz
Message was edited by:
Franz FernerHello
I also tried using NWDI 7.1 (is this the one based on eclipse 3.x??)
but i have some problems developing xi java proxies because there is no content assist available for the function 'EJB Candidates' as in previous versions of NWDS
regards franz -
Q:<WWSD-7> Could we deploy the SOAP package not using the ear, instead could we
put all the related Java code to jar file and the rest of the code to the war
files? The reason I asked is because we do not deploy our applciation in ear format.
A:<WWSD-7> EAR files are general packaging structures that can contain war, EJB
jar, rar and regular jar files. The wsgen task provided expects an output file
to be an ear file. If you are going to utilize another format you will be resonpsible
for building the appropriate web application components. It can be done but you
will have to do more work and not use the provided wsgen task. As far as web services
in general are concerned, the actual business processing can be done by any component
just as long as there is a servlet that understands the SOAP requests and responses.
It is BEA expectation that EJBs are supposed to be you core business components
so these will be the operations most likely to be exposed as web srevices.Hello Erik,
I was looking into the thread , it seems you have found out the solution .
Could you look into this thread and provide some insight for the same ? I am currently facing the problem as mentioned in the link below.
CAF-EJB
Regards,
Ronniee -
Using pacman to search for packages - libraries no more used / needed
Is there a way to use pacmant to "clean out" the system, by searcing and deleting all packages and libraries no more needed nor used by anything?
Are you looking for options different from these? http://bbs.archlinux.org/viewtopic.php?id=88987
I don't think there's a completely automatic way. At least, not a way that I would trust.
Last edited by drcouzelis (2010-01-22 16:42:31) -
Netbeans 4.1 packaging libraries
I just started using netbeans 4.1 from 3.6 and I have trouble adding
external 3rd party classes/jars/resources into my jar distribution. I
can add them the the libraries for the project, but it doesnt add the
needed classes into the dist/myprogram.jar. Anyone know how to add that? In 3.6 I could manually mount the jar and add the classes I needed from within it directly to the distribution.The default project run settings in NB 4.1 use the "compile-time libraries" before they check recently compiled sources. If you have an old version of the file you are trying to run in a .jar file somewhere in your compile-time libraries NetBeans will use that file. If that old file does not have a main method you will get the error you mentioned.
You will be able to compile your class because when compiling NetBeans will work on changed files and only access the compile-time libraries when needed.
The new project will have no old .jars in its path so you will not run into this conflict.
I would first try to remove the old copy of your file from the compiling sources path.
If you can't remove the file try reordering the project�s libraries listed under project properties -> libraries-> �run� tab so that your �compiling sources� are listed before your "classpath for compiling sources"
-Mark -
Packaging an ADF ear (for weblogic) file through maven
Is anyone familiar with how to do this? Is there already an existing plugin that works...? Or should I just use the assembly plugin and manually create all the web logic files needed?
I take it that this is either uncommon, rare, or nonexistent?
-
Hi,
At present, we create a single enterprise archive (.ear) containing all utility packages (3rd party, framework) (jars) and EJB deployments. Our current .ear file is approximately 14MB.
During a recent investigation to resolve a JNI DLL reloading issue, we discovered that when loading new classes for an application, the runtime environment looks for classes in the following locations (in the following order): the bootstrap classpath, installed extensions (lib/ext directory of the JRE) and the classpath.
It has been suggested that the utility and 3rd party jars are not packaged within the EAR, but are copied to the lib/ext directory of the JRE.
The new .ear file is approximately 2MB. The advantages of this approach is that the EAR deployment is more lightweight and is thus more manageable by the application server.
A further advantage is that the jars are in a single location. That is, if a jar is required by more than more EAR, it resides in a single location.
Are there any negatives or performance impacts of this approach?
Any information or suggestions would be highly appreciated.
Regards,
Rennay DorasamyThe only real negatives are:
1) You can't change the libraries without restarting the java process (WLS in this case)
2) Your extensions must be isolated and not refer to any classes in the classpath or application.
FWIW, WLS 9 includes a new feature application libraries:
http://e-docs.bea.com/wls/docs90/programming/libraries.html
-- Rob -
Sharing common libraries and ejbs between multiple ears
Hi
I have been going through various articles at O'Reilly and discussions at serverside
(some outdated) on the packaging options in J2EE.
http://www.onjava.com/pub/a/onjava/2001/06/26/ejb.html?page=2
http://www.onjava.com/pub/a/onjava/2001/07/25/ejb.html
http://www2.theserverside.com/home/thread.jsp?thread_id=7530
I am still undecided as to what is the best way to package and deploy
- a set of EJBs (Stateless Session beans) and
- utility libraries
that need to be shared by multiple ears.
We have a set of components - 4 session ejbs and 15 utility classes like log4java,
xerces, custom utilities etc... which need to be shared by all applications running
on the server (in a clustered environment).
There are over 22 applications and these will be packaged in individual ear files.
If we choose to put the common EJBs and utilities in each of the application's
ear, then for every change to this common library all the applications will need
to be repackaged and redeployed, which obviously is not desirable.
If we choose to use the 'Class-Path' option in manifest file, from what I understand
the path to be specified is a relative path within the ear i.e. the path cannot
point to archives outside the .ear file, which does not serve our purpose. Am
I right in this understanding?
What is the best way to package and deploy these common components under these
circumstances?
Has anybody tried something like this before?
Would appreciate your comments on this.
Thank you."Kumar" <[email protected]> wrote in message
news:[email protected]...
In My opinion,
I would be packaging the all utilities into a single jar file and be using
in the application server class path directly. whenever I want to change
this jar file I can change at one shot and package this jar file and keepit
in the classpath again. This works very well, if and only if each EAR file
is not using its own version of a libary of utility jar file. All earfiles
should be using a single and common library.In this case when you update the .jar file, you would have to restart the
server. I am not aware of any good solution which alleviates this.
>
If I include this utility jar file into all ear files, the following arethe
difficulties we need to handle in the future.
- What if utility library has been changed frequently, it leads to
re-package all .ears and re-deployment
- Unnecessarily adding a copy of a single jar file to all ear files,
increases complexity
- Any new application needed to be deployed, again which uses utility, we
need add the utility jar file to ear file
- There is no logical separation and simplicity
Thanks
Kumar
"Kiran P" <[email protected]> wrote in message
news:[email protected]...
Hi
I have been going through various articles at O'Reilly and discussions
at
serverside
(some outdated) on the packaging options in J2EE.
http://www.onjava.com/pub/a/onjava/2001/06/26/ejb.html?page=2
http://www.onjava.com/pub/a/onjava/2001/07/25/ejb.html
http://www2.theserverside.com/home/thread.jsp?thread_id=7530
I am still undecided as to what is the best way to package and deploy
- a set of EJBs (Stateless Session beans) and
- utility libraries
that need to be shared by multiple ears.
We have a set of components - 4 session ejbs and 15 utility classes likelog4java,
xerces, custom utilities etc... which need to be shared by allapplications running
on the server (in a clustered environment).
There are over 22 applications and these will be packaged in individualear files.
If we choose to put the common EJBs and utilities in each of theapplication's
ear, then for every change to this common library all the applicationswill need
to be repackaged and redeployed, which obviously is not desirable.
If we choose to use the 'Class-Path' option in manifest file, from what
I
understand
the path to be specified is a relative path within the ear i.e. the pathcannot
point to archives outside the .ear file, which does not serve our
purpose.
Am
I right in this understanding?
What is the best way to package and deploy these common components underthese
circumstances?
Has anybody tried something like this before?
Would appreciate your comments on this.
Thank you. -
So maybe I'm a bit confused as to the purpose of shared libraries in EARs, they work perfect for us in our web apps - using 10.3 btw. We were expecting a similar behavior in the EAR modules (the libraries 'become/act as' part of the ear/lib directory), however it seems that what actually happens is the WAR (we deploy the shared libs as a war) becomes part of the EAR, causing issues if referenced from more than one EAR, but also, as a WAR, not allowing EAR modules and contained JAR files access at the shared libraries.
Is there a way to replicate the behavior of the shared library in the WAR inside the EAR? Is there a reason shared libs act this way in the EAR (part of spec maybe), seems counter intuitive, and certainly not at all helpful.I'm referencing shared libraries from an EAR, but the shared library needs to be packaged as an EAR to get the behavior you're after.
Typically this would involve creating an EAR with shared jars in the APP-INF/lib folder. The shared library EAR will require at least one module - an empty jar will suffice. Weblogic 9.2 used to have a few EAR shared libraries in BEA_HOME/weblogic92/common/deployable-libraries - can't see them in my 10.3 install.
Referencing a WAR shared library from an EAR has the effect of including that web app in the EAR - you might use this if you had a common web app that was shared across several applications.
Davin. -
Help to solve problem with packaging log4j in a EAR file
Hi All
i struggle hard to create a EAR composed of EJB JARs and WARs and the programs
in these JARs and WARs use log4j to log msg. Because i want all J2EE apps to have
their own version of log4j library, i package log4j.jar in the EAR file. Below
is my EAR package structure
EJB1.jar
EJB2.jar
SharedUtilities.jar
log4j.jar
log4j.properties
WEBAPP1.war
WEBAPP2.war
META-INF/manifest.mf
For both EJB1.jar and EJB2.jar's META-INF/manifest.mf, there is a below entries
Manifest-Version: 1.0
Class-Path: SharedUtilities.jar log4j.jar
However, my program always hit below runtime error.
[java] Caused by: javax.ejb.TransactionRolledbackLocalException: EJB Exception:
: java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
But the program in EJB1.jar and EJB2.jar seem to have no such problem in loading
classes in SharedUtilities.jar. The problem can be eliminated if i put log4j.jar
at system classpath. Can anybody provide me with info on how to package a log4j
library within a EAR package ?
In addition, where should i put the log4j.properties so that it will be at search
path of log4j and automatically loaded by log4j lib
regards
DannyHi Slava Imeshev
I am a bit confused about your reply. As said, the log4j.jar was packaged in my
ear file. If the log4j.jar was not packaged in ear file, how come the ejb classloader
can locate it.
Secondly, if log4j.jar is included in system classpath, the ejb also can load
log4j classes by system classloader. No "NoClassDeffound" exception is thrown.
regards
dso
"Slava Imeshev" <[email protected]> wrote:
"dso" <[email protected]> wrote in message
news:[email protected]...
Hi Slava Imeshev
thanks for your response. I am a bit confused about your answer.
i can't understand why u said the classloader COULD loadorg/apache/log4j/PropertyConfigurator.
According to the error msg, it said
" java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator".
Seemingly,
this class in log4j.jar could not be located. But as i said in lastquestion,
i seemed to have properly
edit the "META-INF/manifest.mf" in EJB1.jar and EJB2.jar to includelog4j.jar
in "Class-path" attribute. And my EJB classes have no problem in loadingclasses
in SharedUtilities.jar. Would u please elaborate on it in more details?
Sure. NoClassDefFoundError means that a DEPENDING class
can not be loaded. If the classloader were not able to load the class
itself, it would give you ClassNotFoundException.
Just make sure that you don't have the same packages in
the ear and in the class path so that you don't have classes
loaded by system classloader trying to load classes loaded
by ejb classloaders.
regards
dso
"Slava Imeshev" <[email protected]> wrote:
First, this error means that classloader was able to load
org/apache/log4j/PropertyConfigurator, but cold not load
one of depending classes. I'd inspect the CLASSPATH
to see if there are any log4 classes there.
Second, you can package your log4.properties into
log4.jar itself.
Regards,
Slava Imeshev
"dso" <[email protected]> wrote in message
news:[email protected]...
Hi All
i struggle hard to create a EAR composed of EJB JARs and WARs and
the
programs
in these JARs and WARs use log4j to log msg. Because i want all
J2EE
apps
to have
their own version of log4j library, i package log4j.jar in the EARfile.
Below
is my EAR package structure
EJB1.jar
EJB2.jar
SharedUtilities.jar
log4j.jar
log4j.properties
WEBAPP1.war
WEBAPP2.war
META-INF/manifest.mf
For both EJB1.jar and EJB2.jar's META-INF/manifest.mf, there is
a below
entries
Manifest-Version: 1.0
Class-Path: SharedUtilities.jar log4j.jar
However, my program always hit below runtime error.
[java] Caused by: javax.ejb.TransactionRolledbackLocalException:EJB
Exception:
: java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
But the program in EJB1.jar and EJB2.jar seem to have no such problemin
loading
classes in SharedUtilities.jar. The problem can be eliminated if
i
put
log4j.jar
at system classpath. Can anybody provide me with info on how to
package
a
log4j
library within a EAR package ?
In addition, where should i put the log4j.properties so that it
will
be at
search
path of log4j and automatically loaded by log4j lib
regards
Danny -
Ear files and third-party packages
Hi all.
I don't know where to put a third-party .jar package into an ear file. Does it have to go under the META-INF folder, or maybe it has to go at the same folder as ejb jars go? I read the J2EE specs, but it doesn't make up my mind.
Thanks very much.In meta-inf folder change application.xml
in <application>
add here u'r application jar and third party jar
eg
<module><ejb>test.jar</ejb></module>
<module><ejb>test1.jar</ejb></module>
</application>
put u'r all jar files ( application and third party jars )in parent folder.
Maybe you are looking for
-
How to use one ResultSet many times in a jsp page ?
Hi all, I have .jsp page and I have used it to get data from DB and display them to users. So I have to get data from DB in number of places in this particular jsp. I thought that it is better to have one ResultSet for entire page and once it is done
-
Extension of connecting mater and child tables
Initial Question: Need help in SQL : I have master table name called : AA Data is having : Date Display Name ===================== 10/3/2009 Q3 2009 1/3/2010 Q4 2009 1/13/2010 Q1 2010 4/4/2009 Q1 2009 7/4/2009 Q2 2009 I have Child Table =============
-
I'm following the steps to unload a zip file with the directory structure intact. The initial upload succeeded and I can retrieve the zipped file correctly, but when I try to unzip it within Portal I receive this log error: ORA-01422: exact fetch ret
-
Blending options, fx, effects, copy, CS4
Hi. In PS CS4 In my layers palette, I used to be able to have an effect (ex. drop shadow) on a layer & drag that effect onto another layer so the layers would have the exact same effect. In CS4 when I drag an effect, I lose that effect from that laye
-
Hello, i have just built a custom component in multisim. All is well and good until i place the component then set it so i can see pin names. The pin names overlap the chip itself so i was wondering if there was a way to moves the pin name, or justif