Link to home
Create AccountLog in
Avatar of prsubject
prsubjectFlag for India

asked on

JNDI lookup issue for an ear file

I am getting a error of jndi lookup while trying to look for the error. I am really not able to get what the correct value I am supposed to pass for the look up. Here below is what I have done

This are the steps I followed.
I have written an ejb classes, ejb-jar.xml and jboss.xml in META-INF and creaed a jar file
I wrote a servlet , created a web.xml and jboss-web.xml in WEB-INFand created a war file
I copied the jar and war in a folder, created application.xml in META-INF and created a ear file

In the servlet I wrote as
InitialContext ctx = new InitialContext();
                  Object objRef = ctx.lookup("ejb/session/SayHello");


<?xml version="1.0"?>

<jboss>
      <enterprise-beans>
            <session>
                  <ejb-name>session/sayHello</ejb-name>
                 <jndi-name>ejb/session/sayHello</jndi-name>
            </session>
      </enterprise-beans>
</jboss>
In the jboss.xml as below which I have passed in the servlet. I am getting the following error. The code on line 23 of SayHelloServlet is
Object objRef = ctx.lookup("ejb/session/SayHello");
Could comeone guide me.


javax.naming.NameNotFoundException: session not bound
16:07:09,001 ERROR [STDERR] 	at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
16:07:09,001 ERROR [STDERR] 	at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
16:07:09,001 ERROR [STDERR] 	at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
16:07:09,001 ERROR [STDERR] 	at org.jnp.server.NamingServer.lookup(NamingServer.java:396)
16:07:09,001 ERROR [STDERR] 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728)
16:07:09,001 ERROR [STDERR] 	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)
16:07:09,001 ERROR [STDERR] 	at javax.naming.InitialContext.lookup(InitialContext.java:392)
16:07:09,001 ERROR [STDERR] 	at org.servlet.SayHelloServlet.init(SayHelloServlet.java:23)

Open in new window

Avatar of prsubject
prsubject
Flag of India image

ASKER

Typo mistake The code on line 23 is
Object objRef = ctx.lookup("ejb/session/SayHello");
ASKER CERTIFIED SOLUTION
Avatar of Sathish David  Kumar N
Sathish David Kumar N
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
I am bit confused or not being able to catch up to what you said. This is what I have done. Please rectify me if I am wrong. Could you please guide where exactly I am supposed to see

I opened jmx console http://localhost:8080/jmx-console
There was a heading "Object Name filter" as jboss.deplopyment, jboss.cache etc under which there are a list of jboss related (application/services/filters)
I couldnot find one with jndi clause.
Iclicked on jboss.j2ee. Here is what I found

jndiName=ejb/session/sayHello,plugin=pool,service=EJB
jndiName=ejb/session/sayHello,service=EJB
module="sayhello.jar",service=EjbModule,uid=20707280
service=EARClassLoaderDeployer
service=EARDeployer

Under jboss.deployment
id="ejb/sayhello.jar#session/sayHello,uid692983",type=Component
id="jboss.j2ee:module="sayhello.jar",service=EjbModule,uid=20707280",type=Component

id="jboss.jacc:id="vfszip:/home/rmvprasad/jboss-6.0.0.M1/server/default/deploy/sayhello.ear/",service=jacc",type=Component
id="jboss.jacc:id="vfszip:/home/rmvprasad/jboss-6.0.0.M1/server/default/deploy/sayhello.ear/sayhello.jar/",parent="sayhello.ear",service=jacc",type=Component
id="jboss.jacc:id="vfszip:/home/rmvprasad/jboss-6.0.0.M1/server/default/deploy/sayhello.ear/sayhello.war/",parent="sayhello.ear",service=jacc",type=Component
What do you mean by running the list method of the service. Could you please explain
in the jboss.j2ee I found the jndi name as jndiName=ejb/session/sayHello,service=EJB, which is not the same in the servlet. sayHello was written as SayHello(S is Caps). I rectified it. Now as I say http://localhost:8080/sayHello, it says  The requested resource (/sayhello/) is not available.