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).
Related
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.
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 am trying to build an RPM from my Maven project. I have 5 different modules and each one has its own pom.xml, In the root I have one pom.xml which builds all modules (Typical Maven Setup). When I build an RPM, I want to include a directory that is not part of the maven directories. Its above a directory [from the root folder that contains my maven modules]. What is the best way to include that in my RPM? or rather what is the best way to refer to a directory with out hardcoding the path? I am confused about ${baseDir} and what it refers to?
Thank you.
${project.basedir} refers to the root of the project, ie where the pom.xml is, so you could use that in <systemPath>${project.baseDir}/../../dirYouWant</systemPath>
In general though, Maven best-practices would frown about relying on the relative paths around your projects from being there. Instead, I suggest deploying those files as there own project to your maven repository (as a zip, jar, whatever), and then getting them as part of your rpm build. Depending on what plugin you are using to build your RPM, you can unpack those files automatically.
Try this
<dependency>
...groupid,artifactid etc..
<scope>system</scope>
<systemPath>path/to/your/jar</systemPath>
</dependency>
Did you mean you want to add another project to your maven build being level above?
you can do it like this :
in your parent pom :
<modules>
<module>../projectdirectory</module>
</modules>
in your projectdirectory pom :
<parent>
<groupId>...</groupId>
<artifactId>...parent...</artifactId>
<version>...</version>
<relativePath>../parentProject/pom.xml</relativePath>
</parent>
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 a maven-managed project with some modules.
One module contains some native codes inside "src/main/resources/native" directory.
Second module packages all related modules to a WAR file.
Here comes the question : How to copy the "native/" directory (and its sub-directories) in first module to WEB-INF/native directory in the second module ?
I found a copy resources plugin , but it seems not what I want. (It copies directory inside the same module , but I want cross-module copy)
This is doable with dependency:unpack (that I would bind on the prepare-package phase) and the appropriate excludes/includes . See the Unpacking specific artifacts example.
The goal of modules in maven is to spearate them from each other. I am afraid there will be no satisfactory solution inside maven as this goes against the grain.
A solution could be to create a war archive with your resources and depend on that to build your final war.
I use for a project for example the camel-web resources by adding a dependency :
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-web</artifactId>
<version>${camel.version}</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
The war resources are merged with my web resources.