JBoss Community

How to package EJB interface for JBoss AS 7

created by David Phan in EJB3 Development - View the full discussion

I'm migrating to JBoss AS 7 from JBoss AS 5.  I've read JBoss AS 7 Class Loading mechanism and although I feel I understood it, I have a hard time packaging my jar and war for JBoss AS 7.  Here is the scenario:

 

1. I have an EJB interface named IRepository

 

2. And an EJB class that implements that interface, named Repository

 

3. This EJB will be looked up, using JNDI, as a local bean by a web application which is packaged as a separate .war file.

 

4. I'm also using Maven for building and packaging my .jar and .war files

 

 

The questions I have are:

 

1. Should I package IRepository in a .jar (say irepository.jar) separate from the jar that contains Repository EJB class?

 

- If I do this I believe I can reference irepository.jar as a dependency in my .war file's MANIFEST.  This is fine, except that it increases the number of Maven projects I have by 1 to build irepository.jar

 

2. Should I package IRepository and Repository EJB in the same jar (say repositoryejb.jar) AND NOT including this jar in my .war (using Maven 'provided' scope)?

 

- If I do this and I put repositoryejb.jar in modules/.../main JBoss 7 doesn't display JNDI information about this EJB, which makes me believe that my web app may not be able to look up this EJB

 

- If I just deploy repositoryejb.jar in the standalone/deployments directory, JBoss 7 displays JNDI information about this EJB.  But how do I specify that my .war depends on repositoryejb.jar?  Basically, my .war does not know what IRepository is to cast a looked up EJB to a variable within my web app

 

3. Should I package IRepository and Repository EJB in the same jar AND including this jar in my .war (using Maven 'compiled' scope)?

 

- This would ensure that my web app can cast a looked up EJB to IRepository.  But when I deploy my .war to JBoss AS 7 it discovers a different EJB (in war scope) and provides different JNDI information. This is just not clean.

 

 

It seems that the answer is straight forward, but maybe my head is stuck in the sand that I can see a good answer.  Thanks in advance for the help.

Reply to this message by going to Community

Start a new discussion in EJB3 Development at Community