Solved

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

Posted on 2008-09-29
7
886 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
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
exchange 2010 turning off 3des ciphers 2 303
servlet requestdispatcher include and forward differences 1 39
ejb on wildfly 5 30
SequenceInputStream example 3 19
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
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.

856 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