Solved

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

Posted on 2008-09-29
7
876 Views
Last Modified: 2013-11-24
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
0
Comment
Question by:pmrenaud
  • 3
  • 2
  • 2
7 Comments
 
LVL 10

Expert Comment

by:Nellios
ID: 22611922
Just copy the ejb-jar inside WEB-INF/lib of the war archive and you are ok.
0
 

Author Comment

by:pmrenaud
ID: 22614400

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
 
LVL 10

Accepted Solution

by:
Nellios earned 125 total points
ID: 22640067
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:pmrenaud
ID: 22650385
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
 
LVL 59

Assisted Solution

by:Kevin Cross
Kevin Cross earned 125 total points
ID: 22801229
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
 

Author Comment

by:pmrenaud
ID: 22801423
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
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 22801436
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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now