Spring Framework
  1. Spring Framework
  2. SPR-3113

Failed reconnect on OC4J: Object reference no longer valid.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.8, 2.0.1
    • Fix Version/s: 1.2.9, 2.0.3
    • Component/s: EJB
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      I use a SimpleRemoteStatelessSessionProxyFactoryBean to connect to an EJB on an OC4J appserver. While stresstesting some transaction logic, I kept killing the server to see if the transaction was able to complete on reconnect. This worked well most times, however, som times I got the error:

      Object reference no longer valid (Disconnected)

      Stacktrace:
      org.springframework.remoting.RemoteAccessException: Cannot access remote service [Service]; nested exception is com.evermind.server.rmi.RMIConnectionException: Object reference no longer valid (Disconnected)
      at org.springframework.remoting.rmi.RmiClientInterceptorUtils.convertRmiAccessException(RmiClientInterceptorUtils.java:177)
      at org.springframework.ejb.access.SimpleRemoteSlsbInvokerInterceptor.doInvoke(SimpleRemoteSlsbInvokerInterceptor.java:84)
      at org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor.invoke(AbstractRemoteSlsbInvokerInterceptor.java:119)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
      at $Proxy0.countChangesAfter(UnknownSource)
      at com.company.cache.agent.CacheAgent.getUpdatesSinceLastUpdate(CacheAgent.java:206)

      At line 206 in the cacheagent i do a call to the application context to get an instance of the Service.

      With this error, Spring was not able to reload. I have set RefreshHomeOnConnectFailure, and as I said it works most of the time (on errors like JVM termination and unknown command). It seems Spring holds on to a connection it thinks is valid somehow. Is there anyway to make a complete refresh of the context, so that it can "start fresh"? If I restart the client without restarting the server after an error like this, everything works normally, so there must be something on the client.

        Activity

        Hide
        Juergen Hoeller added a comment -

        The decision about connect failures is made in AbstractRemoteSlsbInvokerInterceptor's protected "isConnectFailure" method. By default, all well-known RMI connect failure exceptions are detected there. It looks like "com.evermind.server.rmi.RMIConnectionException" doesn't derive from any of those well-known base exceptions.

        So for a workaround, you could extend your SimpleRemoteStatelessSessionProxyFactoryBean and override "isConnectFailure" to detect Oracle's RMIConnectionException as well.

        Can you please check what exception RMIConnectionException derives from? I'm of course open to refining our default check there, as a last resort even to check for the "com.evermind.server.rmi.RMIConnectionException" class name...

        Juergen

        Show
        Juergen Hoeller added a comment - The decision about connect failures is made in AbstractRemoteSlsbInvokerInterceptor's protected "isConnectFailure" method. By default, all well-known RMI connect failure exceptions are detected there. It looks like "com.evermind.server.rmi.RMIConnectionException" doesn't derive from any of those well-known base exceptions. So for a workaround, you could extend your SimpleRemoteStatelessSessionProxyFactoryBean and override "isConnectFailure" to detect Oracle's RMIConnectionException as well. Can you please check what exception RMIConnectionException derives from? I'm of course open to refining our default check there, as a last resort even to check for the "com.evermind.server.rmi.RMIConnectionException" class name... Juergen
        Hide
        Richard Borge added a comment -

        It seems that RMIConnectionException inherits directly from java.rmi.RemoteException (http://www.orionserver.com/docs/api/orion/serialized-form.html). That explains it. RmiClientInterceptorUtils.isConnectFailure would return false in this context. I will make my own class to override SRSSPFB, but this problem must have been seen by others as well, not sure the best way to fix it.

        RMIConnectionException really should extend ConnectException. I blame Oracle

        Show
        Richard Borge added a comment - It seems that RMIConnectionException inherits directly from java.rmi.RemoteException ( http://www.orionserver.com/docs/api/orion/serialized-form.html ). That explains it. RmiClientInterceptorUtils.isConnectFailure would return false in this context. I will make my own class to override SRSSPFB, but this problem must have been seen by others as well, not sure the best way to fix it. RMIConnectionException really should extend ConnectException. I blame Oracle
        Hide
        Juergen Hoeller added a comment -

        I've simply added an equals check for the class name "com.evermind.server.rmi.RMIConnectionException", treating such an exception as connect failure as well. We're used to such workaround for specific servers; this is not the first time

        This should be available in tonight's 2.0.3 snapshot (http://www.springframework.org/snapshots).

        Juergen

        Show
        Juergen Hoeller added a comment - I've simply added an equals check for the class name "com.evermind.server.rmi.RMIConnectionException", treating such an exception as connect failure as well. We're used to such workaround for specific servers; this is not the first time This should be available in tonight's 2.0.3 snapshot ( http://www.springframework.org/snapshots ). Juergen

          People

          • Assignee:
            Juergen Hoeller
            Reporter:
            Richard Borge
            Last updater:
            Trevor Marshall
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              7 years, 11 weeks, 6 days ago