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"?>

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

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

prsubjectAuthor Commented:
Typo mistake The code on line 23 is
Object objRef = ctx.lookup("ejb/session/SayHello");
Sathish David Kumar NArchitectCommented:
Open your jmx console (http://localhost:8080/jmx-console) and check the JNDI service.
Run the list method of the service, to see the JNDI tree of your server. Does the Lego EJB appears there?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
prsubjectAuthor Commented:
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


Under jboss.deployment

prsubjectAuthor Commented:
What do you mean by running the list method of the service. Could you please explain
prsubjectAuthor Commented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.