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: @firstname.lastname@example.org.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.
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.
Independent Consultant — Author, EJB 3 in Action — Expert Group Member, Java EE 6 and EJB 3.1
Joined: Nov 06, 2008
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?
Joined: Feb 01, 2005
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.
Joined: Nov 06, 2008
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 ]
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,
It is probably best to post on the GlassFish forums if you have problems after reading the FAQ and the GlassFish docs.
Joined: May 28, 2007
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.
Good Luck !
subject: Accessing EJB s remote interface through seperate web application