How to make visible a ejb-jar file to a war file?

Hi Experts,
I've created a bean project which use a JSP/Servlet client and EJB objects (sessionBean). From them, i've created a war and a ejb-jar...
but i'm having a problem. The war file seems unable to see the ejb-jar once deployed. In fact the only way to get ejb-jar visible from the war is to add it into the classpath of the war file. But i didn't see any example or tutorial who talk about adding the ejb-jar into the class path of the war. Would it be a question of web.xml or ejb-jar.xml??

thks Mart
pmrenaudAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
NelliosConnect With a Mentor Commented:
When you are using ejbs the ejb jar needs to be in two places:
a) the server
b) the client (so that the client has access to the ejb interfaces)

In your cases both client and server are on the same machine. You still need to expose the interfaces to your client which is the war. It doesn't matter that both live on the same server. You need to treat the ejb jar like any other jar that your war needs.

I hope this make sense for you,
Good luck

0
 
NelliosCommented:
Just copy the ejb-jar inside WEB-INF/lib of the war archive and you are ok.
0
 
pmrenaudAuthor Commented:

It's not clear to my mind! I mean, I'm using MyEcipse which is deployed 2 files. A war file and a ejb jar file into the autodeploy of the glassfish server.  Why should i deployed a ejb jar (in this case the name is BeanProjectEJB.jar) file into a glassfish server AND adding this file into the classpath of war project (in this case the name is BeanProjectWeb.war).

BeanProjectEJB.jar -- com.session
                                |- ClientSession.java
                                |- ClientSessionHome.java
                                |- ClientSessionRemote.java

BeanProjectWeb.war -- com.session
              |                      |- Controller.java
              |- WEB-INF/lib
                                |- BeanProjectEJB.jar

All this seems to be very tricky...

any help would be appreciate.

Thks
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
pmrenaudAuthor Commented:
Yeah,

but if the ejb jar is (also) on the client... there is change for the war to use the local ejb (in WEB_INF/lib) instead of the ejb jar located on the remote server?

thks
0
 
Kevin CrossConnect With a Mentor Chief Technology OfficerCommented:
Nellios is correct.  If you are really worried about it, as stated, the client only needs to know about the public interfaces, so you can have a JAR of just the public interfaces under the WAR as suggested, but I agree with Nellios --- at least I have always had to do this way also.  
0
 
pmrenaudAuthor Commented:
hmmm,

okay.... that's means i only need to create a jar which contain the interface of the ejb session class and include it into the classpath of the war??!?
0
 
Kevin CrossChief Technology OfficerCommented:
That is my understanding, but like most I usually put the entire JAR; however, you will be able to quickly tell if needs more classes as you should get messages indicating the exact class that cannot be found in classpath.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.