简体   繁体   English

Java RMI Server问题

[英]Java RMI Server problems

I apologize in advance for what's likely to be an obvious problem, but I've been trying to get this working all day and I can't figure out how to get this to work. 对于可能是一个明显的问题,我事先表示歉意,但是我一直在努力使它整天工作,但我不知道如何使它工作。 In short: my RMIregistry can't find the interface class of my RMI server app. 简而言之:我的RMIregistry找不到我的RMI服务器应用程序的接口类。

I'm running rmiregistry.exe through Eclipse with these arguments: 我正在使用以下参数通过Eclipse运行rmiregistry.exe:

1234 -J-Djava.rmi.server.useCodebaseOnly=false

And I got the following RMI server: 我得到了以下RMI服务器:

        package es.test.innova.pruebas.test;

    import java.io.File;
    import java.rmi.Naming;
    import java.rmi.RMISecurityManager;
    import java.rmi.RemoteException;
    import java.rmi.server.UnicastRemoteObject;

    public class TestImpl extends UnicastRemoteObject implements Test
    {
        public TestImpl() throws RemoteException {}

        public static void main(String args[])
        {
            try
            {           
             if (System.getSecurityManager() == null) {
                 System.setSecurityManager(new RMISecurityManager());
                 } 

                TestImpl obj = new TestImpl();

                Naming.rebind("rmi://localhost:1234/Test",obj);
                System.out.println("Connected to registry!");
            }
            catch (Exception e)
            {
                System.out.println("HelloImpl err: " + e.getMessage());
                e.printStackTrace();
            }
        }

        @Override
        public String validate(File f) throws RemoteException {
            return "hello world";
        }
}

Which I then run with these arguments: 然后使用以下参数运行:

-Djava.security.policy=C:\D\RMI\policy.all -Djava.rmi.server.codebase=file:/C:/D/Proyectos/Firma/validarfirma/

The policy file referenced is this: 引用的策略文件是这样的:

grant {
    permission java.security.AllPermission "", "";
};

The codebase parameter references the project's folder, through I've also tried directing it at the folder's bin folder and even directly at the .class files, as mentioned in other answers in this site. 正如我在本站点的其他答案中所提到的,通过尝试将代码库参数指向项目的文件夹,我还尝试将其指向文件夹的bin文件夹,甚至直接指向.class文件。

Regardless of what I try, I keep getting this error: 无论我尝试什么,我都会不断收到此错误:

java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: 
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
    java.lang.ClassNotFoundException: es.test.innova.pruebas.test.Test
    at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:419)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
    at sun.rmi.transport.Transport$1.run(Transport.java:177)
    at sun.rmi.transport.Transport$1.run(Transport.java:174)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:275)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:252)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:378)
    at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
    at java.rmi.Naming.rebind(Naming.java:177)
    at es.test.innova.pruebas.test.TestImpl.main(TestImpl.java:25)
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
    java.lang.ClassNotFoundException: es.test.innova.pruebas.test.Test
    at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
    at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:409)
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
    at sun.rmi.transport.Transport$1.run(Transport.java:177)
    at sun.rmi.transport.Transport$1.run(Transport.java:174)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.ClassNotFoundException: es.test.innova.pruebas.test.Test
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.rmi.server.LoaderHandler$Loader.loadClass(LoaderHandler.java:1206)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:270)
    at sun.rmi.server.LoaderHandler.loadClassForName(LoaderHandler.java:1219)
    at sun.rmi.server.LoaderHandler.loadProxyInterfaces(LoaderHandler.java:729)
    at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:673)
    at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:610)
    at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:646)
    at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:311)
    at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:255)
    at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1556)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1512)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1769)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
    ... 13 more
HelloImpl err: RemoteException occurred in server thread; nested exception is: 
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
    java.lang.ClassNotFoundException: es.test.innova.pruebas.test.Test

Class not found. 找不到课程。 I've tried running everything manually instead of using Eclipse, running rmi directly from the .class file folder, compiling the Server as a .jar and using that instead... And of course I've fiddled with the codebase parameter a bunch. 我试过手动运行所有内容,而不是使用Eclipse,直接从.class文件夹运行rmi,将Server编译为.jar,然后改用....当然,我还摆弄了basebase参数。 I've tried everything I could think of, but I'm stuck. 我已经尽力想尽一切办法,但是我陷入了困境。

The thing is I must be setting the codebase wrong or someting like that, but I don't see how. 问题是我必须设置错误的代码库或类似的东西,但我不知道如何做。 The registry just can't find my classes. 注册表只是找不到我的课程。

I'd be very grateful if someone could help me out here. 如果有人可以在这里帮助我,我将不胜感激。 Thanks for reading. 谢谢阅读。

-Djava.rmi.server.codebase=file:/C:/D/Proyectos/Firma/validarfirma/

其含义是缺少的类应位于:

C:/D/Proyectos/Firma/validarfirma/es/test/innova/pruebas/test/Test.class

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM