Reputation: 105
at time i try to add third party libraries in a EJB-JAR. So far it seems to me, that it is not possible, but i am not sure, and why it is not possible.
I want to create single EJB-JARs and WARs, without put them together in one EAR.
Arjan Tijms shows in Java EE - EAR vs separate EJB+WAR three ways, and to clearify it, i want option 2.
My own research comes mostly to questions with following answers J2EE: How to package 3rd party JARs into an EJB jar?, but i don't want an EAR file.
On the oracle site itself shows following packaging for an EJB-JAR: EJB packaging, which don't have a own lib directory like a WAR. I already tried to put the libary in the root directory (Using eclipse + JBoss 7). My first question is, is it possible to add extra libaries into a EJB-JAR, like in a WAR file? This confuses me, because it is possible to deploy a simple EJB-JAR to a application server, but it seems you cannot add third party libaries. For me a EAR seems mostly "overkill", because it have for me no real advantage and second, if i put a library into a EAR, different EJB-JARs connot use different versions from third party libraries. I want the EJB-JAR complete independent from other EJB-JARs and WARs. I only created a additional simple jar project that contains the interfaces, that have to be implemented, and is added to each EJB project and the WAR project. That brings me to question 2: Have i use to an EAR, if yes, why? It seems to me that i missing something oder don't understand yet.
Upvotes: 2
Views: 7258
Reputation: 131
Jars aren't supposed to contain jars.
I would just package the EJBs into a WAR (either directly in WEB-INF/classes or as separate ejb-jars in WEB-INF/lib), put the 3rd party libs into WEB-INF/lib and call it a day. Your approach is pretty limiting. You won't be able to inject your EJBs, and you would have to use a remote lookup.
Upvotes: -1
Reputation: 4604
You can put third party JARs in a lib/
folder in the EAR and add
<library-directory>lib</library-directory>
to your application.xml
.
Upvotes: 3