I have develeped EJB which references some 3rd party jars.
Initially I was keeping these JAR files in EAR (which contains the EJB JAR Project). I have a requirement where I need to move these JARS from EAR and should keep these dependent JAR files within the EJB JAR.
Can we keep JAR files in EJB JAR and if yes where and how to refer them in EJB Project.
Thanks in advance.
JBoss will pick jars that are included in ejb jar files. However, I am not really sure if it is something forced by the spec. Class loading wise also this will be a little bit tricky. As in case of JBoss, depending on how class loading is configured you may or may not get ClassCastExceptions or ClassNotFoundExceptions. I would seriously avoid this. I would put these jar files in a shared lib directory if the classes are not holding a state.
Let me put the question in simple way,
I am trying to test the concept of ‘Jar within a Jar’ by creating an independent EJB application.
To test, I have included ‘commons-lang-2.1.0.jar’ within the EJB JAR Project in a lib folder.
And I am using the ToStringBuilder class provided by commons-lang-2.1.0.jar’
I have updated the Manifest.mf file as :
But at runtime, still it is failing giving following error :
I am not sure if you insist on making it work as "Jar within a Jar"
This is what I would do.
Explode the commons lang jar during build and package it back in EJB JAR file. This will work in all app servers without any environment change. More ever this wont mess up your server classpath as things remain neatly packaged.
Give it a try.