no security manager: RMI class loader disabled
dc-williams Sep 3, 2005 11:57 AMHi, hope this is the right place to put this message. I have a stand-alone java class which I am trying to use as a client to an EJB running inside JBOSS v4.0.2. I actually took this source code from another website as an example and just changed the package declaration. The EJB deploys fine and I can look it up OK from a Servlet/WAR file running inside the same JVM. When I try to access the bean from a different JVM (different host) or same host but outside the container, I get the exception shown at bottom of this message.
Here is all my code and config:
1. stand-alone client class with main method (same try/catch works flawlessly if I put inside a servlet inside JBOSS).
package com.dan;
import javax.naming.Context;
import javax.naming.InitialContext;
public class TesterClient extends java.lang.Object {
public static void main(String[] args) {
try {
InitialContext ic = new InitialContext();
Object o = ic.lookup("test/Tester");
TesterHome home = (TesterHome)
javax.rmi.PortableRemoteObject.narrow (o, TesterHome.class);
Tester test = home.create();
System.out.println( test.returnMessage( args[0] ) );
} catch ( Exception e ) {
e.printStackTrace();
}//end try/catch
}//end main()
}//end class TesterClient
2. jndi.properties on the client side (nowhere near jboss)
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
3. The classpath and command line
The CLASSPATH when running (under Win2k, same box on which the jboss server is running although It's using networking to get to the server anyway as if I shut down the server, I get a socket timeout exception instead) has all the JARs from the jboss\client directory in it plus the usual suspects from J2SDK1.5 home.
The BAT file I use to run the is as follows (where the com/dan path is under the current directory):
SET CP=jboss;client;JARs (didn't want to put them all in here)
java -cp %CLASSPATH%;%CP%;. tester.TesterClient 'some string'
3. EJB code (and usual interfaces):
package com.dan;
public interface Tester extends javax.ejb.EJBObject {
public String returnMessage( String msg ) throws java.rmi.RemoteException;
}//end interface Tester
---
package com.dan;
import javax.ejb.*;
public class TesterEJB extends java.lang.Object implements SessionBean {
/** Creates new TesterEJB */
public void ejbCreate() {
}
public void ejbActivate() throws javax.ejb.EJBException, java.rmi.RemoteException {
}
public void ejbPassivate() throws javax.ejb.EJBException, java.rmi.RemoteException {
}
public void ejbRemove() throws javax.ejb.EJBException, java.rmi.RemoteException {
}
public void setSessionContext(javax.ejb.SessionContext sessionContext) throws javax.ejb.EJBException, java.rmi.RemoteException {
}
public String returnMessage(java.lang.String msg) {
return msg;
}
}
---
package com.dan;
public interface TesterHome extends javax.ejb.EJBHome {
Tester create() throws java.rmi.RemoteException, javax.ejb.CreateException;
}//end interface TesterHome
4. ejb-jar.xml in the EJB JAR META-INF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<ejb-jar>
<display-name>TesterJAR</display-name>
<enterprise-beans>
<display-name>TesterBean</display-name>
<ejb-name>TesterBean</ejb-name>
com.dan.TesterHome
com.dan.Tester
<ejb-class>com.dan.TesterEJB</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</enterprise-beans>
</ejb-jar>
5. jboss.xml in META-INF
<?xml version="1.0" encoding="UTF-8"?>
<enterprise-beans>
<ejb-name>TesterBean</ejb-name>
<jndi-name>test/Tester</jndi-name>
</enterprise-beans>
6. And the exception...
javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: com.dan.TesterHome (no security manager: RMI class loader disabled)]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:713)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at tester.TesterClient.main(TesterClient.java:22)
Caused by: java.lang.ClassNotFoundException: com.dan.TesterHome (no security man
ager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:531)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:6
28)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294
)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStrea
m.java:238)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1494)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1457)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
693)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:5
7)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:637)
... 3 more
Any hints / solution suggestions would be greatly appreciated!
Dan