This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JBoss/WildFly and the fly likes Bean Not Bound Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Bean Not Bound Exception" Watch "Bean Not Bound Exception" New topic

Bean Not Bound Exception

Arpit Gadle
Ranch Hand

Joined: Dec 16, 2008
Posts: 69

I have deployed a simple stateless bean.Stateless Session Bean client code is

package client;

import beans.SimpleSession;
import javax.naming.InitialContext;

public class SimpleSessionClient
public static void main(String [] args)
throws Exception
InitialContext ctx=new InitialContext();

SimpleSession simpleSession=(SimpleSession)ctx.lookup(SimpleSession.class.getName());

for(int i=0;i<args.length;i++)
String returnedString=simpleSession.getEchoString(args[i]);
System.out.println("Sent String: "+args[i]+" Return String: "+returnedString);


After running the client i am getting following error

Exception in thread "main" javax.naming.NameNotFoundException: SimpleSessionApp. SimpleSession not bound

There is no error at server console.
My configuration is

JBOSS 4.0.3S1
Java 6.0

There is some problem in lookup method.
What is the JNDI naming convention to look for an ejb instance in JBOSS?

Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441

You seem to be using an incorrect jndi-name for the lookup. Follow the steps mentioned here to view the jndi tree and figure out the jndi-name of your bean. You can then use it to lookup the bean.

[My Blog] [JavaRanch Journal]
Arpit Gadle
Ranch Hand

Joined: Dec 16, 2008
Posts: 69

Thanks Jaikiran,
Just go through the snippets

My JNDI Tree View is

+- SimpleSessionBean (class: org.jnp.interfaces.NamingContext)
| +- remote (proxy: $Proxy72 implements interface beans.SimpleSession,interface org.jboss.ejb3.JBossProxy)

At Server console

20:05:06,959 INFO [EJBContainer] STARTED EJB: beans.SimpleSessionBean ejbName: SimpleSessionBean
20:05:07,169 INFO [EJB3Deployer] Deployed: file:/H:/jboss/server/all/deploy/SimpleSessionApp.ejb3

As per your advice and the above server console output i changed lookup method with jndi name as lookup("SimpleSessionBean") and at Client Console i got this exception

Exception in thread "main" java.lang.ClassCastException: org.jnp.interfaces.NamingContext cannot be cast to beans.SimpleSessi
at client.SimpleSessionClient.main(

So, Am i using a correct jndi name in lookup method?
What is the solution to the above exception ?

Thanks in advanace
I agree. Here's the link:
subject: Bean Not Bound Exception
jQuery in Action, 3rd edition