*
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Bean Not Bound Exception" Watch "Bean Not Bound Exception" New topic
Author

Bean Not Bound Exception

Arpit Gadle
Ranch Hand

Joined: Dec 16, 2008
Posts: 69

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

Joined: Jul 20, 2005
Posts: 9962
    
163

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
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Bean Not Bound Exception
 
Similar Threads
Running EJB 3.0 Session Bean in JBoss
NoInitialContextException error
Stuck In the Mud with First EJB
Connection to remote Glassfish server
Where to put jndi.properties