[jboss-user] [JBoss and NetBeans] - Re: NameNotFoundException: DefaultDS not bound - Entity Unit

lkotouc do-not-reply at jboss.com
Thu Feb 8 08:52:32 EST 2007


You must initialize the context environment. The following code works with JBoss AS 4 (EJB2.1 module is deployed):


package accessejb;

import a.AccessibleSessionRemote;
import a.AccessibleSessionRemoteHome;
import java.util.Hashtable;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

public class Main {
    
    public static void main(String[] args) throws Exception {

        AccessibleSessionRemote asr = lookupAccessibleSessionBean();
        String msg = asr.hello("World");
        System.out.println(msg);
    }
    
    private static AccessibleSessionRemote lookupAccessibleSessionBean() throws Exception {
        Object remote = getContext().lookup("AccessibleSessionBean");
        AccessibleSessionRemoteHome rv = (AccessibleSessionRemoteHome) PortableRemoteObject.narrow(remote, AccessibleSessionRemoteHome.class);
        return rv.create();
    }
    
    private static InitialContext getContext() throws Exception {
        Hashtable<String, String> env = new Hashtable<String, String>();
        env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
        env.put("java.naming.provider.url", "jnp://localhost:1099");
        return new InitialContext(env);
    }
}



Remote interface: a.AccessibleSessionRemote
Home interface: a.AccessibleSessionRemoteHome

The home interface is bound to 'AccessibleSessionBean' name.

Following libraries must be on the classpath:
/client/jboss-j2ee.jar
/client/jbossall-client.jar
/server/default/lib/jnpserver.jar
/lib/jboss-common.jar

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

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



More information about the jboss-user mailing list