[jboss-user] [EJB 3.0] - Re: NamingException: Could not dereference object - EJB 3.0

vinu15378 do-not-reply at jboss.com
Mon Jun 9 06:32:30 EDT 2008


I am facing the same problem of JNDI lookup in EJB 3.0 Entity Beans.
I am using Netbeans 5.5.1,JBoss 4.2.0 and standalone client.
I have checked everything.I didnt get where should we search for JNDI name to look up  for bean.
Struggling hard for this example.
Please help for the same
Following is the Client Code.

package enterpriseapplication6;

import com.titan.travelagent.TravelAgentRemote;
import com.titan.domain.Cabin;
import java.util.Properties;

import javax.naming.InitialContext;
import javax.naming.Context;

public class Client 
{
    public static void main(String [] args) 
    {
        try 
	{
            Context jndiContext = getInitialContext();
            Object ref = jndiContext.lookup("travelagent.TransactionPersistenceContextRemote");
            TravelAgentRemote dao = (TravelAgentRemote)ref;

            Cabin cabin_1 = new Cabin();
            cabin_1.setId(1);
            cabin_1.setName("Master Suite");
            cabin_1.setDeckLevel(1);
            cabin_1.setShipId(1);
            cabin_1.setBedCount(3);

            dao.createCabin(cabin_1);

            Cabin cabin_2 = dao.findCabin(1);
            System.out.println(cabin_2.getName());
            System.out.println(cabin_2.getDeckLevel());
            System.out.println(cabin_2.getShipId());
            System.out.println(cabin_2.getBedCount());

        } 
        catch (javax.naming.NamingException ne)
        {
	    ne.printStackTrace();
	}
    }

    public static Context getInitialContext() 
        throws javax.naming.NamingException 
    {
         Properties p = new Properties();
	p.put(InitialContext.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
	p.put(InitialContext.PROVIDER_URL,"jnp://localhost:1099");
        InitialContext ctx = new InitialContext(p);
        return new javax.naming.InitialContext();
    }
}

Following error I am getting while executing Client Code.
I havent made any changes in Remote and Bean Class.

Please help me executing examples in EJB 3.0 Entity Bean Examples using
JBoss AS

javax.naming.NameNotFoundException: travelagent.TransactionPersistenceContextRemote not bound
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
        at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
        at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
        at sun.rmi.transport.Transport$1.run(Transport.java:159)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
        at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:255)
        at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:233)
        at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
        at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at enterpriseapplication6.Client.main(Client.java:17)


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4156625#4156625

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4156625



More information about the jboss-user mailing list