Results 1 to 8 of 8

Thread: EOFException using RMI remoting

  1. #1
    Join Date
    Dec 2006
    Posts
    2

    Default EOFException using RMI remoting

    Hi all,

    I've got a stange problem that occurs with RMI remoting. Let me explain a bit what my environment is like. I have two webapps running on tomcat. One of the webapps exports a service using RmiServiceExporter, and the other webapp uses RmiProxyFactoryBean to proxy the exported service.

    I have a very simple service interface/implementation pair, like so:

    Code:
    package com.foo.service;
    
    public interface TestService {
      public String test();
    }
    Code:
    package com.foo.service;
    
    public class TestServiceImpl implements TestService {
      public String test() {
        return "hello world";
      }
    }

    My "rmi server" webapp applicationcontext.xml snippet:
    Code:
    ...
    <bean id="testService" class="com.foo.service.TestServiceImpl"/>
    <bean class="org.springframework.remoting.rmi.RmiServiceExporter">
      <property name="serviceName" value="TestService"/>
      <property name="service" ref="testService"/>
      <property name="serviceInterface" value="com.foo.service.TestService"/>
    </bean>
    ...
    My "rmi client" webapp applicationcontext.xml snippet:
    Code:
    ...
    <bean id="rmi.service.testService" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
      <property name="serviceUrl" value="rmi://localhost/TestService"/>
      <property name="serviceInterface" value="com.foo.service.TestService"/>
      <property name="refreshStubOnConnectFailure" value="true"/>
    </bean>
    ...
    I think those are the important pieces; I can provide more if I missed something.

    This is the behavior I'm seeing: The first time I start up tomcat, both applications are deployed successfully. The client webapp is able to use the RMI Proxied service. I can stop/start the client as much as I like, and each time the client is able to reconnect to the exported service.

    However, if I restart the server webapp, things are seemingly put into a bad state. Once the server webapp comes back up, the client webapp is never able to reconnect to the exported service (even if I restart the client). I see the following exception:

    Code:
    Dec 30, 2006 1:42:22 PM org.apache.catalina.core.StandardContext listenerStart
    SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rmi.service.testService' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.remoting.RemoteLookupFailureException: Lookup of RMI stub failed; nested exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
            java.io.EOFException
    Caused by: org.springframework.remoting.RemoteLookupFailureException: Lookup of RMI stub failed; nested exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
            java.io.EOFException
    Caused by: java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
            java.io.EOFException
            at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
            at java.rmi.Naming.lookup(Unknown Source)
            at org.springframework.remoting.rmi.RmiClientInterceptor.lookupStub(RmiClientInterceptor.java:199)
            at org.springframework.remoting.rmi.RmiClientInterceptor.prepare(RmiClientInterceptor.java:145)
            at org.springframework.remoting.rmi.RmiClientInterceptor.afterPropertiesSet(RmiClientInterceptor.java:133)
            at org.springframework.remoting.rmi.RmiProxyFactoryBean.afterPropertiesSet(RmiProxyFactoryBean.java:66)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1057)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1024)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:140)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:270)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
            at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
            at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
            at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3763)
            at org.apache.catalina.core.StandardContext.start(StandardContext.java:4211)
            at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1175)
            at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:368)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
            at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
            at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
            at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.EOFException
            at java.io.ObjectInputStream$BlockDataInputStream.peekByte(Unknown Source)
            at java.io.ObjectInputStream.readObject0(Unknown Source)
            at java.io.ObjectInputStream.readObject(Unknown Source)
            at sun.rmi.server.MarshalInputStream.readLocation(Unknown Source)
            at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)
            at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
            at java.io.ObjectInputStream.readClassDesc(Unknown Source)
            at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
            at java.io.ObjectInputStream.readObject0(Unknown Source)
            at java.io.ObjectInputStream.readObject(Unknown Source)
            ... 40 more
    I'm pretty much stumped. Can anybody give me any leads?

  2. #2
    Join Date
    Dec 2006
    Posts
    2

    Default

    Forgot to mention - I must restart the tomcat instance that runs the server webapp to get things to start working again.

    I'm using java version "1.5.0_09"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
    Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode, sharing)
    Last edited by joep; Dec 31st, 2006 at 03:20 AM.

  3. #3

    Default

    I'm seeing similar behavior, but I have to delete tomcat and unzip it again.

    Did you find a solution?

  4. #4

    Default

    Kinda share this issue I guess. Setup: Two different webapps, used to communicate using hessian before, and I want to switch them to RMI now that they're on the same host as it seems faster. Nevertheless, no go:

    Code:
    ...
    2008-03-04 09:07:42 ERROR Context initialization failed ( http-8080-1 ContextLoader )  
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'docDAO' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of 
    init method failed; nested exception is org.springframework.remoting.RemoteLookupFailureException: Lookup of RMI stub failed; nested exception is java.rmi.UnmarshalException: error
     unmarshalling return; nested exception is:  
            java.io.EOFException 
    Caused by:  
    org.springframework.remoting.RemoteLookupFailureException: Lookup of RMI stub failed; nested exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception 
    is:  
            java.io.EOFException 
    Caused by:  
    java.rmi.UnmarshalException: error unmarshalling return; nested exception is:  
            java.io.EOFException 
            at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) 
            at java.rmi.Naming.lookup(Naming.java:84) 
    ...
    Asides this, is there a "better" way of making different applications (different Spring contexts) in the same tomcat (== the same VM?) communicate with each other?

    Thanks and best regards,
    Kristian

  5. #5
    Join Date
    Jan 2006
    Posts
    5

    Default

    The same problem here.
    If the Server with the RMIServiceExporter is running as a standalone process, the client can reconnect even after a server restart.
    When running as a tomcat-webapp, the whole tomcat has to be restarted!

    Did someone check if that happened with older versions too?

    Using tomcat 5.5.26, spring 2.5.2, jdk1.6.0_04.

    Thanks for any help on this!

  6. #6
    Join Date
    Jan 2006
    Posts
    5

    Default

    I finally found the solution!

    The cause of the problem is the fact that Spring creates an RMIRegistry with the classloader of the server webapp. Then, when restarting the server, the RMIRegistry is not shut down. After the restart the Registry keeps its references to the old Stubs which do not exist anymore.

    There are two solutions:
    1) Start the rmiregistry in a seperate process without the classpath of the server app.

    Or 2) (better approach) Let spring start the RMIRegistry throu RmiRegistryFactoryBean, which shuts it down correctly.

    So, the Service-Export looks like this:

    <bean id="registry" class="org.springframework.remoting.rmi.RmiRegistr yFactoryBean">
    <property name="port" value="1199"/>
    </bean>

    <bean class="org.springframework.remoting.rmi.RmiService Exporter">
    <property name="serviceName" value="ProductService" />
    <property name="service" ref="productService" />
    <property name="serviceInterface"
    value="com.myshop.ProductService" />
    <property name="registry" ref="registry"/>
    </bean>

    That solves it all!

  7. #7
    Join Date
    Jul 2009
    Location
    Mumbai, India
    Posts
    2

    Unhappy Still Getting the same.

    Hi,

    I am getting the same error.
    My server side RMI is standalone java program and client side is a swing application.
    I am using spring on both sides.

    It was used to work till yesterday for me, but suddenly don't know how it started giving exception.

    Code:
    java.rmi.UnmarshalException: error unmarshalling return; nested exception is: 
          java.io.EOFException
          at sun.rmi.server.UnicastRef.invoke(Unknown Source)
          at org.springframework.remoting.rmi.RmiInvocationWrapper_Stub.invoke(Unknown Source)
          at org.springframework.remoting.rmi.RmiClientInterceptor
    Can any help me on this.

    I tries the 2nd solution to use registry but still no success.
    Sourabh Girdhar
    BPM - SOA

  8. #8

    Default Solution Using process explorer

    In process explorer look for a javaw.exe process that is floating all by itself and kill it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •