[jboss-user] [EJB] - Loading classes from client for EJB 2 / RMI Class loading fr

evgens do-not-reply at jboss.com
Tue Sep 29 16:02:04 EDT 2009


Imagine you have a SessionBean with the method:

  |     Object executeTask(Task t) throws RemoteException {
  |         return t.execute();
  |     }
  | 
where

  | public interface Task {
  | 	Object execute();
  | }
  | 
This means, the client of this EJB can call the method executeTask with its own class, that implements Task interface:

  | public class Pi implements Task, Serializable {
  | ...
  | 	/**
  | 	 * Compute the value of pi to the specified number of digits after the
  | 	 * decimal point. The value is computed using Machin's formula
  |          */
  |         public Object execute() {
  |                 int digits = 45;
  | 		int scale = digits + 5;
  | 		BigDecimal arctan1_5 = arctan(5, scale);
  | 		BigDecimal arctan1_239 = arctan(239, scale);
  | 		BigDecimal pi = arctan1_5.multiply(FOUR).subtract(arctan1_239)
  | 				.multiply(FOUR);
  | 		return pi.setScale(digits, BigDecimal.ROUND_HALF_UP);
  | 	}
  | 
Obviously, the server will not have this implementation class.
RMI has introduced special JVM Parameter for this: java.rmi.server.codebase 
The client has to specify it while starting its jvm: -Djava.rmi.server.codebase=file:/Users/xxx/work/samples/compute-client-0.0.1-SNAPSHOT.jar
where the jar file compute-client-0.0.1-SNAPSHOT.jar contains the class PI.

This works perfectly in standard sun's RMI.
This also works fine in JBoss 4.2 and newer, but only if the SessionBean is implemented and deployed as EJB3.

Unfortunately I have failed trying to get it running in JBoss 4.2.2 for the SessionBean that was implemented and deployed as EJB2 with the following exception:

  | Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: sample.remote.ejb2client.Pi
  | 	at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:212)
  | 	at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
  | 	at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
  | 	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
  | 	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
  | 	at java.lang.Class.forName0(Native Method)
  | 	at java.lang.Class.forName(Class.java:242)
  | 	at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:585)
  | 	at org.jboss.invocation.MarshalledValueInputStream.resolveClass(MarshalledValueInputStream.java:109)
  | 	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1544)
  | 	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1466)
  | 	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
  | 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
  | 	at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1634)
  | 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
  | 	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
  | 	at org.jboss.invocation.MarshalledValue.get(MarshalledValue.java:91)
  | ...
  | 

Does anybody have an idea what can be wrong?

P.S. The security manager of both client and server were set to java.lang.SecuirtyManager. The corresponding policy file on both client and app. server allows everything:

  | grant {
  |     permission java.security.AllPermission;
  | };
  | 

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

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



More information about the jboss-user mailing list