Solved

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

Posted on 2008-09-29
7
882 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Systems talking to each other 5 130
Public IP Address Amazon Servers 2 56
eclipse apache tomcat admin console 52 97
hibernate example using maven 12 42
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
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.

770 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