I have a ear which contains EJB's and war file and this ear is deployed in weblogic server
Now I have a jar which is a dependency for classes inside and outside war.
When I include this dependency in app/lib and web-inf/lib and deployed it in weblogic server I get an exception saying class not found. Now when I exclude the jar from App-INF removing the EJB which is dependent on this jar and deploy it . It works fine.
Is there any way I put dependency in APP-INF and WEB-INf and still this works fine.
You want your JAR to be present on APP-INF/lib level of the EAR.
This way, the WAR will automatically see the JAR as well. You should then not need your JAR within the WAR.
Otherwise, search for "Optional Package" here and with Oracle.
You can deploy your JAR and have the EAR and WAR refer to it.
Related
We have a weblogic ear which has dependency with a third party jar. We don't want to keep this jar inside of the ear. Is there any other better way or better place to keep this jar and load it only at the ear class loader.
I personally would package the third party jar into the ear. You have a couple of other options...
Add the jar file into your weblogic domain lib directory, this will put it on the classpath for every server:
<domain folder> -> lib
A better way would be to edit your server classpath to also include the third party jar. Login to your admin console and edit:
Servers -> server_name -> Server Start tab -> Classpath
Keep in mind this will put the jar on the classpath for all apps running on that particular server. If that is not desirable you can look into preferring the jar(s) in your ear file over those on the classpath like:
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>org.xml.sax.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
I have an EAR with the following structure
myWar1.war
WEB-INF/lib/myJar.jar
myWar2.war
I want myWar2.war to be able to load myJar.jar.
In JBoss 7/EAP 6.x you can add a dependency like this in jboss-deployment-structure.xml
<sub-deployment name="myWar2.war">
<dependencies>
<module name="deployment.myEar.ear.myWar1.war" />
</dependencies>
</sub-deployment>
I don't know of a WAS equivalent. I have tried adding a class path entry in myWar2.war's manifest file but WAS seems to ignore it.
If I have a manifest entry such as
Class-Path: myWar1.war/WEB-INF myWar1.war/WEB-INF/lib myWar1.war/WEB-INF/lib/myJar.jar
myWar1.war/WEB-INF and myWar1.war/WEB-INF/lib are added to the module class path but myWar1.war/WEB-INF/lib/myJar.jar is not
I know I can turn the jar into a utility jar at the EAR root level but would prefer not to. It's an established application (the second war is new) I don't want to mess around with it too much. If I can solve the dependency with a class path entry that would be ideal.
This is not possible. JARs in WEB-INF/lib are considered to be local classpaths to myWar1.war, and you can't reference JARs from another WAR. Your only option is to move the JAR to the EAR (either the lib/ directory, or to another directory and add Class-Path to the META-INF/MANIFEST.MF of both WARs).
I have a EAR -
This EAR contains multiple WAR
Inside these WAR files there is a common JAR which is getting downloaded within each WAR file.
I want to remove this common JAR file into a shared Library. Also i want the latest version of JAR file everytime i rebuild my WAR, I am using Tomcat in Dev and Websphere min production.
We are using IVY for dependency management, Now. I have removed the common jar from the war file, but i dont know how to access the latest version of jar and download it in the shared library everytime i restart my server.
Can anyone help on this.?
http://ant.apache.org/ivy/history/latest-milestone/ivyfile/dependency.html
You'll need to add a dependency to your ivy.xml file, something along the lines of:
<dependency org="com.orgname" name="jarname" rev="latest.release"/>
Is this a JAR file you make yourself, or is it publicly available? If you make it yourself, you will have to publish it in a repository somewhere in your system.
i have EAR and an EJB project. I noticed eclipse (sts) creates and earContent folder so I assume this is where I need to add external jars.
I added my hibernate and log4j jars on this folder but my EJB classes cannot resolve Logger class and hibernate classes.
What's the correct way of adding these jars? or should I just add them to the EJB build path?
Add jars to ear project EarContent folder
In Eclipse Right click ejb project, Properties
Deployment Assembly - Manifest Entries - Add
Choose your jars to add, OK
OK
jars now added to manifest in ejb project, should work.
I'm looking at this in a project for the first time, I'd be very surprised if there wasn't a better solution to this that doesn't require Maven. The Java EE Tools - Update EAR Libraries option looks particularly suspicious, but doesn't seem to do the above. Note I'm on Helios still.
Add those jars under folder EarContent/lib directly , then all is done.
I.E., EarContent/lib/foo.jar will work but EarContent/lib/dir/foo.jar won't.
I have been working on this problem for one whole day but in vain without any effective solution.
I have an ear file packaged with an ejb and a handful of jar files (including hibernate and the other dependent jar files).The ejb is stateless and enabled as a web service.
The ear file has been packaged using maven and has the below structure
ear->projectrelatedejb.jar
->hibernate.jar
->otherdependent. jar
->META-INF/application.xml
->META-INF/manifest.mf
The application.xml and manifest file are automatically generated by maven when I do a package.
When I deploy this ear file on glassfish it gets deployed with the ejb methods being accessible using web services. However when accessing the application (using soapui),
the ejb methods that perform some database functionality using hibernate throw java.lang.NoClassDefFoundError for the hibernate api during runtime.
It is obvious from the error that the hibernate jars are not on the classpath during runtime but since the jars are within the ear Glassfish should have
added it to the application classpath.
I tried various options like adding the classpath entries to the manifest.mf during the package (by using the element addClasspath with the maven-ear-plugin) which didn't do any good.Also with Glassfish we cannot add the dependent jars as modules to the application.xml unless the jars are application client jars
(Glassfish wouldn't deploy the ear file if the application.xml has the dependent jars declared as modules).
I also tried placing the jars in the lib directory within the ear (which isn't actually required) and with the manifest Class-Path header referencing the jars in the lib directory which also didn't fix the problem.
The quick and dirty fix which I can do to get this working is to place the hibernate and the other the dependent jars in Glassfish's lib directory.However,this is a bad practice
and I am somewhat reluctant to do it.
I would really appreciate if someone can provide me with a working solution to this problem.I have gone through the net looking for this problem
but couldn't find any solution.
Wondering if its a bug with glassfish or does glassfish need something special to reference the jars in an ear.
Thanks in advance.
I found a similar problem which is discussed here: http://www.tricoder.net/blog/?p=59.
Simply put, try putting the libraries in EAR/lib directory and according to JEE5 spec, glassfish will add them to class path automatically.
I used Server Library option to deploy application JARs and it worked for me.
Right click on your EAR-> Properties -> Libraries-> Add Library -> Create -> give name and change type in Library Type to Server Libraries then add JARs that should be deployed and confirm.
I work with NetBeans 7.0.1 and GlassFish server 3.1
When you say you added classpath entries to manifest.mf, which manifest.mf do you refer to? The one in ear-root/META-INF/manifest.mf ? Try adding a META-INF/MANIFEST.MF to your ejb module with Class-Path entries!