Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

putting a lib jar file in an ear file  RSS feed

 
paul wheaton
Trailboss
Posts: 22523
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jar file that has a bunch of stuff in it that my ejb's need and my servlets need. My first thought was to simply put it in the ear file. Didn't work. So then I updated application.xml to include a "module" tag that had a "java" element. That didn't work either.
How do I do this?
 
wei wu
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1> put these classes in whichever ejb-jar file which uses these classes.
or you can
2> use Class-Path in ejb-jar's and war's manifest files. But i never succeeded.
 
Seetesh Hindlekar
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi wei,
What utility u use to create a war/ear file? I mean Ant or IDE like Eclipse.
Let me know regarding the same.
Seetesh
 
wei wu
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
create ejb-jar and war is very easy, i just use jar -cvf command.
 
Roland Barcia
author
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When putting a jar in the EAR, the J2EE compliant way for a WAR and an EJB-JAR to see that jar is to add the jar name to the MANIFEST of the EJB-JAR and the MANIFEST of the WAR. This should be enough. This works with WebSphere
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
"My first thought was to simply put it in the ear file." This is what we do and it works fine.
What IDE are you using? Are you getting the errors at compile time or runtime? If runtime, some IDEs have a different build and runtime path.
 
paul wheaton
Trailboss
Posts: 22523
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A guy I work with is working on a jboss book. Since I was porting my stuff to jboss I asked him and came up with a really spiffy approach - at least for jboss.
Put all your jars into one jar. I named my jar lib.jar. And then put it in the ear file at lib/lib.jar. Then pop the following into application.xml:

Cake!
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure works on JBoss... however this is a non-standard solution that I guarantee will not work in other Application Servers. The standard J2EE solution as defined in the J2EE 1.3 spec is to use a Class-Path MANIFEST entry.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this stuff portable, or specific to various containers that happen to allow it? Is there a spec that specifically talks about this?
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I mentioned above the J2EE 1.3 Specification directly addresses this issue and the portable solution is to use a Class-Path MANIFEST entry to specify dependencies. This is actually one of the least understood parts of J2EE deployment...
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you still need to include an application-client.xml DD for lib files to have the utilizing modules successfully deploy? Or can you only include them when the lib JAR has ejb-refs or resource-refs of its own? I seem to recall JBoss freaking out whenever a "java" module doesn't have any application-client DDs (although I've obviously never messed around with one that was included as part of another's classpath).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!