Announcement Announcement Module
Collapse
No announcement yet.
RMI: could not bind a second rmi service to registry Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • RMI: could not bind a second rmi service to registry

    Hi guys,

    I have the following problem: I try to use RMI and Spring in an OSGi environment, more precisely in Eclipse Equinox. I have a server component which binds two services to the registry (spring files below; changed class names!). They are both using the same ports.

    Code:
    	<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
    		<property name="serviceName" value="service1" />
    		<property name="service" ref="refService1" />
    		<property name="serviceInterface"
    			value="serviceInterface1" />
    		<property name="registryPort" value="1099" />
    		<property name="servicePort" value="1100" />
    	</bean>
    
    	<bean class="org.springframework.remoting.rmi.RmiServiceExporter">
    		<property name="serviceName" value="service2" />
    		<property name="service" ref="refService2" />
    		<property name="serviceInterface"
    			value="serviceInterface1" />
    		<property name="registryPort" value="1099" />
    		<property name="servicePort" value="1100" />
    	</bean>
    If I only bind one service (doesn't matter which one) everything works fine, but when I use both service the exception below is thrown during rebinding of the second service.

    This is the code part of the RmiServiceExporter class:

    Code:
    		
                    // Bind RMI object to registry.
    		try {
    			if (this.replaceExistingBinding) {
    				this.registry.rebind(this.serviceName, this.exportedObject); <----- here
    			}
    			else {
    				this.registry.bind(this.serviceName, this.exportedObject);
    			}
    		}
    Code:
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
    	java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
    	java.lang.ClassNotFoundException: service2_Stub (no security manager: RMI class loader disabled)
    	at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396)
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
    	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:886)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    	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:359)
    	at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
    	at org.springframework.remoting.rmi.RmiServiceExporter.prepare(RmiServiceExporter.java:286)
    	at org.springframework.remoting.rmi.RmiServiceExporter.afterPropertiesSet(RmiServiceExporter.java:227)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)
    	... 75 more
    Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
    	java.lang.ClassNotFoundException: service2_Stub (no security manager: RMI class loader disabled)
    	at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
    	at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:386)
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
    	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:886)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    	at java.lang.Thread.run(Thread.java:619)
    Caused by: java.lang.ClassNotFoundException: service2_Stub (no security manager: RMI class loader disabled)
    	at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:375)
    	at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
    	at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
    	at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
    	at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
    	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
    	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
    	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
    	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    	... 12 more
    It should not be a problem with a non setted Security Manager, because this exception is only be thrown because RMI tries to download the Stub. But during binding the first service the stub is found. Both stub classes are at the same place.

    Hopefully someone can help me!
Working...
X