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
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user