aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Accessing EJB s remote interface through seperate web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Accessing EJB s remote interface through seperate web application" Watch "Accessing EJB s remote interface through seperate web application" New topic
Author

Accessing EJB s remote interface through seperate web application

Sandareka Fernando
Greenhorn

Joined: Nov 06, 2008
Posts: 13
Hi,
I'm trying to call a session bean through a separate web application. If that session bean does not have references to any other beans it works fine. But when there is a call to another session bean in the first one (using @EJB annotation) it gives the following error:


Deploying application in domain failed; Error loading deployment descriptors for module [TestM] -- Cannot resolve reference Unresolved Ejb-Ref com.cp.interfaces.RCPInterfaceBean/ticketReservationBean@jndi: @null@com.cp.reservation.TicketReservationLocal@SReservationession@null
Deployment errort:
The module has note been deplokyed.


Following is the code i used



If somebody knows the reason for this please help me. Thanks in advance.
Reza Rahman
author
Ranch Hand

Joined: Feb 01, 2005
Posts: 580
    
    5
Sandareka,

What application server are you using? Are RCPInterfaceBean and TicketReservationLocal on the same server? If not, you need to use either the DD or @EJB.mappedName to specify which server/ear the referenced EJB resides in (very rare scenario; typically all remote EJBs reside on the same server while clients reside on another). Alternatively you can use JNDI to connect to the remote server and do a look-up.

However, there are still a few application servers that require DDs/mapped name in addition to @EJB to work.

Regards,
Reza


Independent Consultant — Author, EJB 3 in Action — Expert Group Member, Java EE 6 and EJB 3.1
Sandareka Fernando
Greenhorn

Joined: Nov 06, 2008
Posts: 13
Hi Reza,

Sorry for incomplete info.I'm using GlassFish V2 with netbeans6.1. Both EJB s reside in the same server. When the Both client .war and ejb.jar is in same EAR then this problem does not occur. It only arise when I use a separate web application as client (in netbeans) to access the EJB module. I tried with @EJB(mappedname="") also. But it didn't work.I'm not much familiar with using JNDI names and EJB references. So I'm not sure about the JNDI name I used in mappedname. Is it the same as the fully qualified path to the bean? or can it be different?

Do I have to add EJB reference to sun-web.xml of web application?

regards,
Sandareka.
Reza Rahman
author
Ranch Hand

Joined: Feb 01, 2005
Posts: 580
    
    5
Sandareka,

I see, this should be easily solvable.

Try using @Remote instead of @Local. The alternative is to use the Sun DD. GlassFish does resolve cross-app EJBs, but they decided to not allow @EJB to resolve automatically for local EJBs. The rational was that this is not done often enough (which is true for the most part). Here is a reference that might help: https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html.

Regards,
Reza
Sandareka Fernando
Greenhorn

Joined: Nov 06, 2008
Posts: 13
Thanks Reza.. It's working now when i used @Remote instead of @local.

I have another small problem. I used @Local there since it is called inside the EJB module. Is that means I can not use any Local interfaces in my application (at least for internal references)? According to what i have designed, there are several more Local interfaces for EJBs. Is it OK (in terms of design perspective) if i change all those to Remote interfaces?
[ November 09, 2008: Message edited by: Sandareka Fernando ]
Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
Hello Reza,

I think it's a good thing that I found this thread, because I stumbled upon the same problem, with the latest version of NetBeans and GlassFish. Could you be so kind of showing me how a Descriptor for a web-app that invokes a Local Ejb would look like in GlassFish ?

I understand it's something like the following: (in web.xml)



But still it does not work. Do you know If I have to include the fully qualified names in these xml descriptors (like dot.com.NonRMILocal) or just the class name?

Then I invoke the Local Interface of my EJB from a web app deployed to the same server like this:



the moduleId of the deployed EJB is StateLessLocalBean

So, when I try to deploy my web-app I get the following Error:

Deploying application in domain failed; Error loading deployment descriptors for module [CallLocalEjbApp] -- Error: Unresolved <ejb-link>: StateLessLocalBean

Do you know What am I doing wrong? Could my descriptor be corrected?

Reza, You have helped me in the past, I hope you could give some insights this time around.
Thanks in advance,

Sincerely,

Jose
Reza Rahman
author
Ranch Hand

Joined: Feb 01, 2005
Posts: 580
    
    5
Jose,

I don't have code handy beyond the link posted above since this is rarely done. Please take a close look here: https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html. They do have detailed examples, including inter-module local and remote EJB look-ups.

It is probably best to post on the GlassFish forums if you have problems after reading the FAQ and the GlassFish docs.

Regards,
Reza
Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339
Hello Reza,

Ok, I understand, I'm trying to figure it out by myself right now. So far, not so good, But I think I'll follow your advice: If nothing else can be done, I'll try and see what the guys at the Glassfish Forum have to say about that.

Take Care,
And
Good Luck !

Jose
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing EJB s remote interface through seperate web application