This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bean Not Bound Exception

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

Thanks>
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
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
Linux MySQL Database
  • 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
on
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 ?

Bye
Thanks in advanace
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic