java.lang.ClassNotFoundException: org.springframework.remoting.rmi.RmiInvocationWrapper_Stub

org.springframework.remoting.RemoteLookupFailureException: Lookup of RMI stub failed; nested exception is java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
 java.lang.ClassNotFoundException: org.springframework.remoting.rmi.RmiInvocationWrapper_Stub (no security manager: RMI class loader disabled)

该异常发生在dubbo调用采用rmi协议调用接口时发生。异常的根本原因在于spring2和spring3源码的差异,去掉了RmiInvocationWrapper_Stub该类,可以从源码中拷出来打jar包从新部署。

package org.springframework.remoting.rmi;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.rmi.MarshalException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.UnexpectedException;
import java.rmi.UnmarshalException;
import java.rmi.server.Operation;
import java.rmi.server.RemoteCall;
import java.rmi.server.RemoteObject;
import java.rmi.server.RemoteRef;
import java.rmi.server.RemoteStub;
import org.springframework.remoting.support.RemoteInvocation;

public final class RmiInvocationWrapper_Stub extends RemoteStub
  implements RmiInvocationHandler
{
  private static final Operation[] operations = { new Operation("java.lang.String getTargetInterfaceName()"), new Operation("java.lang.Object invoke(org.springframework.remoting.support.RemoteInvocation)") };
  private static final long interfaceHash = -1910731558L;
  private static final long serialVersionUID = 2L;
  private static boolean useNewInvoke;
  private static Method $method_getTargetInterfaceName_0;
  private static Method $method_invoke_1;

  static
  {
    try
    {
      tmp48_45.getMethod("invoke", new Class[] { Remote.class, Method.class, RmiInvocationWrapper_Stub.array$Ljava$lang$Object = class$("[Ljava.lang.Object;"), Long.TYPE });
      useNewInvoke = true;
      $method_getTargetInterfaceName_0 = RmiInvocationHandler.class.getMethod("getTargetInterfaceName", new Class[0]);
      $method_invoke_1 = tmp194_191.getMethod("invoke", new Class[] { RemoteInvocation.class });
    }
    catch (NoSuchMethodException localNoSuchMethodException)
    {
      useNewInvoke = false;
    }
  }

  public RmiInvocationWrapper_Stub(RemoteRef paramRemoteRef)
  {
    super(paramRemoteRef);
  }

  public String getTargetInterfaceName()
    throws RemoteException
  {
    try
    {
      String str;
      if (useNewInvoke)
      {
        localObject1 = this.ref.invoke(this, $method_getTargetInterfaceName_0, null, 370039408L);
        return ((String)localObject1);
      }
      Object localObject1 = this.ref.newCall(this, operations, 0, -1910731558L);
      this.ref.invoke((RemoteCall)localObject1);
      try
      {
        ObjectInput localObjectInput = ((RemoteCall)localObject1).getInputStream();
        str = (String)localObjectInput.readObject();
      }
      catch (IOException localIOException)
      {
        throw new UnmarshalException("error unmarshalling return", localIOException);
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
        throw new UnmarshalException("error unmarshalling return", localClassNotFoundException);
      }
      finally
      {
        this.ref.done((RemoteCall)localObject1);
      }
      return str;
    }
    catch (RuntimeException localRuntimeException)
    {
      throw localRuntimeException;
    }
    catch (RemoteException localRemoteException)
    {
      throw localRemoteException;
    }
    catch (Exception localException)
    {
      throw new UnexpectedException("undeclared checked exception", localException);
    }
  }

  public Object invoke(RemoteInvocation paramRemoteInvocation)
    throws IllegalAccessException, NoSuchMethodException, InvocationTargetException, RemoteException
  {
    try
    {
      Object localObject2;
      if (useNewInvoke)
      {
        localObject1 = this.ref.invoke(this, $method_invoke_1, new Object[] { paramRemoteInvocation }, -1509252135L);
        return localObject1;
      }
      Object localObject1 = this.ref.newCall(this, operations, 1, -1910731558L);
      try
      {
        ObjectOutput localObjectOutput = ((RemoteCall)localObject1).getOutputStream();
        localObjectOutput.writeObject(paramRemoteInvocation);
      }
      catch (IOException localIOException1)
      {
        throw new MarshalException("error marshalling arguments", localIOException1);
      }
      this.ref.invoke((RemoteCall)localObject1);
      try
      {
        ObjectInput localObjectInput = ((RemoteCall)localObject1).getInputStream();
        localObject2 = localObjectInput.readObject();
      }
      catch (IOException localIOException2)
      {
        throw new UnmarshalException("error unmarshalling return", localIOException2);
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
        throw new UnmarshalException("error unmarshalling return", localClassNotFoundException);
      }
      finally
      {
        this.ref.done((RemoteCall)localObject1);
      }
      return localObject2;
    }
    catch (RuntimeException localRuntimeException)
    {
      throw localRuntimeException;
    }
    catch (RemoteException localRemoteException)
    {
      throw localRemoteException;
    }
    catch (IllegalAccessException localIllegalAccessException)
    {
      throw localIllegalAccessException;
    }
    catch (NoSuchMethodException localNoSuchMethodException)
    {
      throw localNoSuchMethodException;
    }
    catch (InvocationTargetException localInvocationTargetException)
    {
      throw localInvocationTargetException;
    }
    catch (Exception localException)
    {
      throw new UnexpectedException("undeclared checked exception", localException);
    }
  }
}

 

posted @ 2015-05-05 18:00  942391815  阅读(2712)  评论(0编辑  收藏  举报