cancel
Showing results for 
Search instead for 
Did you mean: 

EJB lookup problem.

Former Member
0 Kudos

I'm migrating a J2ee aplication from JBoss. I've got a web aplication that needs call a remote EJB that is packaged in the same application (ear). This is the ejb reference in my web.xml:

<ejb-ref>

<ejb-ref-name>ejb/SecuritySSession</ejb-ref-name>

<ejb-ref-type>Session</ejb-ref-type>

<home>com.ieci.tecdoc.isicres.ejb.session.security.SecuritySHome</home>

<remote>com.ieci.tecdoc.isicres.ejb.session.security.SecuritySRemote</remote>

<ejb-link>Isicres-ServerV.2.0.jar#SecuritySSession</ejb-link>

</ejb-ref>

Isicres-ServerV.2.0.jar is the EJB module of my application. I've got this code in the ejb-jar.xml:

<session>

<ejb-name>SecuritySSession</ejb-name>

<home>com.ieci.tecdoc.isicres.ejb.session.security.SecuritySHome</home>

<remote>com.ieci.tecdoc.isicres.ejb.session.security.SecuritySRemote</remote>

<ejb-class>com.ieci.tecdoc.isicres.ejb.session.security.SecuritySSession</ejb-class>

<session-type>Stateless</session-type>

<transaction-type>Bean</transaction-type>

</session>

A JSP call a method of an object that do the lookup:

Context ctx = new InitialContext();

try {

Object obj = ctx.lookup("java:comp/env/ejb/SecuritySSession");

...

}

Accesing the initial context the object should find the reference and with the reference get the remote but instead i've got this exception:

javax.naming.NameNotFoundException: No object bound for java:comp/env/ejb/SecuritySSession

at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:116)

at javax.naming.InitialContext.lookup(InitialContext.java:347)

at javax.naming.InitialContext.lookup(InitialContext.java:347)

at com.ieci.tecdoc.common.ejbutils.EJBResolver.getEJBHome(EJBResolver.java:57)

at com.ieci.tecdoc.isicres.ejb.common.ISicresEJBResolver.getEJBSecurityRemote(ISicresEJBResolver.java:83)

at com.ieci.tecdoc.isicres.usecase.AbstractUseCase.getSecuritySRemote(AbstractUseCase.java:66)

at com.ieci.tecdoc.isicres.usecase.security.SecurityUseCase.login(SecurityUseCase.java:45)

at jsp_login1120574360173._jspService(jsp_login1120574360173.java:91)

at com.sap.engine.services.servlets_jsp.server.jsp.JspBase.service(JspBase.java:111)

.....

Please, could anybody help me?

Thank you.

Accepted Solutions (0)

Answers (1)

Answers (1)

Opgenorth
Employee
Employee
0 Kudos

Hello Carlos,

the XML-descriptors and your code look ok.

What seems strange to me is the stack of the exception:

javax.naming.NameNotFoundException: No object bound for java:comp/env/ejb/SecuritySSession

at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:116)

at javax.naming.InitialContext.lookup(InitialContext.java:347)

.....

I would expect a implementation of the InitialContext from SAP not from Sun (package com.sun.enterprise....)

Did you include a jndi.jar in ther EAR or in the web-inf/lib directory of the Web archive?

Best regards,

Juergen

Former Member
0 Kudos

Thank you very much, Juergen.

You showed me the way to the solution.

I have found a "j2ee.jar" at the WEB-INF/lib directory so, as you suggested, my web application was using the wrong InitialContext implementation.

As I said I'm migrating an application that i did not develop and I don't know who put that jar there and the most important thing: why.

I was getting crazy, trying thinks, and always got the same exception.

So, thank you very much again and from this moment you've got a friend in Madrid.

Muchas Gracias !!!! (and excuse my english)

Former Member
0 Kudos

Hello Carlos,

it's not unusual to provide a web application with the needed J2EE/EJB client librarys and to put them for this into the WAR file. Particularly if you deploy your Web application on a different server. If you take a look into you SAP Web AS installation, you will find the needed SAP J2EE client jar's.

BTW, have you done a look into your JNDI tree <u>after</u> you have deployed your application? Did you have found your bean in the expected directory?

Halil

Former Member
0 Kudos

Hello !!

Yes, it is in the right place. But my application was not looking there.

Thank you for your answer !!

Carlos

Former Member
0 Kudos

Hi Carlos,

me again, a bit late

To come back to your problem (you have not marked it as solved so i assume you have the problem yet), you write in your initial posting that you use this code to retrieve the data:

Context ctx = new InitialContext();
try {
   Object obj = ctx.lookup("java:comp/env/ejb/SecuritySSession");
   ...
}

The lookup in java:comp/env/ is the wrong thing! This path is the bean environment path only visual in the container itself for J2EE components but not for remote clients outside. If you are doing your lookup with "ejb/SecuritySSession" it should work.

IMHO these problems with JNDI are due to the "fishy" statements in the EJB 2.x specifications and the the different interpretations.

I don't know which version of JBoss you have used. If you take JBoss 4.0.x and set it up properly to be conform with the EJB specification (-> e.g. disable call by reference for remote calls in the same VM) it will behave the same way as SAP WAS and you will not be able to lookup your Bean with the "java:comp/env" prefix.

Bye

Halil