Solved

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

Posted on 2008-09-29
7
878 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
AWS New EC2 Instance and EBS Storage 2 70
ip / url redirect 13 68
mapAB Challlenge 35 123
Redirect to HTTPS results in Infinite LOOP 4 83
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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.

914 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

19 Experts available now in Live!

Get 1:1 Help Now