• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Bean Not Bound Exception

Ranch Hand
Posts: 69
MySQL Database Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Posts: 10445
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Arpit Gadle
Ranch Hand
Posts: 69
MySQL Database Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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(SimpleSessionClient.java:15)

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

Thanks in advanace
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!