简体   繁体   English

java.rmi.UnmarshalException:无法通过服务器提取客户端类

[英]java.rmi.UnmarshalException: unable to pull client classes by server

I have an RMI client/server set-up on two machines that works fine in a simple situation when the server doesn't require a client-side defned class. 我在两台机器上都有一个RMI客户端/服务器设置,在服务器不需要客户端定义类的简单情况下,它可以很好地工作。 However, when I need to use a class defined on the client side I am unable to have the server unmarshall those classes. 但是,当我需要使用在客户端定义的类时,无法使服务器取消编组这些类。 I suspect this is an issue with my java.rmi.server.codebase property that I pass in as argument to the client app. 我怀疑这是我将java.rmi.server.codebase属性作为参数传递给客户端应用程序的问题。 I followed Sun's RMI Tutorial trail and I think I have followed the steps exactly except that I don't specify a classpath argument when executing client and server because they execute in the directory right above the root package directory (however I tried that too with no effect). 我遵循了Sun的RMI Tutorial跟踪,我认为我完全遵循了这些步骤,只是在执行客户端和服务器时没有指定classpath参数,因为它们在根包目录正上方的目录中执行(但是我也尝试这样做,没有影响)。

The exceptions I get when attempting to execute the different client-side combinations described in detail below are all the same: 我在尝试执行下面详细描述的不同客户端组合时遇到的异常都是相同的:

RmiServer exception: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: test.MyTask at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:353) at sun.rmi.transport.Transport$1.run(Transport.java:177) 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:553) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:808) at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:667) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:636) 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:142) at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178) at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132) at $Proxy0.execute(Unknown Source) at test.myClient.main(myClient.java:32)

The details are: 详细信息是:

My client/server rmi is set up over a home network behind a router. 我的客户端/服务器rmi是通过路由器后面的家庭网络设置的。 The router is assigned to a static ip address I will call myhostname . 路由器被分配了一个静态IP地址,我将其称为myhostname Appropriate port-mapping is set-up in the router that points to the right machines. 在指向正确机器的路由器中设置了适当的端口映射。

role, machine, os, ip-address: 角色,机器,操作系统,IP地址:

server, venice, linux ubuntu 9.10, 10.0.1.2
client, naples, mac os x leopard, 10.0.1.4

I startup the server side as follows inside /home/andrews/workspace/epsilon/bin : 我在/home/andrews/workspace/epsilon/bin内按以下方式启动服务器端:

1 starting registry on the default port 1099: 1个默认端口1099上的启动注册表:

venice% rmiregistry &

2 starting web-server on port 2001 pointing to code base for common interfaces: 2在端口2001上启动Web服务器,指向通用接口的代码库:

venice% java webserver/ClassFileServer 2001 /home/andrew/workspace/epsilon/bin

3 starting server app (main class in test/myServer) which registers the server object: 3个启动服务器应用程序(test / myServer中的主类),用于注册服务器对象:

venice% java -Djava.rmi.server.codebase="http://myhostname:2001/" -Djava.security.policy=server.policy -Djava.rmi.server.hostname=myhostname test/myServer &

Now the client side inside /Users/andrews/Development/Java/workspace/epsilon/bin : 现在,客户端位于/Users/andrews/Development/Java/workspace/epsilon/bin

1 start a local web server that can server client-side classes to the server (not sure if this is needed, but I added I tried it, and still no success; I have added port-mapping to the router for 2001 to venice , for 2002 to naples ) 1启动一个本地Web服务器,该服务器可以将客户端类服务器提供给服务器(不确定是否需要这样做,但是我添加了我尝试过的方法,但仍然没有成功;我为2001年的venice路由器添加了端口映射功能, 2002年到naples

naples$ java webserver/ClassFileServer 2002 /Users/andrews/Development/Java/workspace/epsilon/bin/

Trying to run the client (note: I don't specify the -cp argument because client executes right above the root package directory): 尝试运行客户端(注意:我没有指定-cp参数,因为客户端在根包目录的上方执行):

1 try #1 using an http hostname 1使用HTTP主机名尝试#1

naples$ java -Djava.rmi.server.codebase=http://10.0.1.4:2002/ -Djava.security.policy=client.policy test.myClient myhostname

Note 1: the myhostname argument at the end is passed-in to the client so that it resolves to server's rmi hostname. 注意1:最后将myhostname参数传递给客户端,以便将其解析为服务器的rmi主机名。

Note 2: I tried using localhost:2002 instead of 10.0.1.4:2002 too. 注意2:我也尝试使用localhost:2002而不是10.0.1.4:2002

Note 3: I tried using myhostname:2002 since myhostname is assigned to the router and I have proper port-mapping set-up, this address should resolve to naples and not venice 注意3:我尝试使用myhostname:2002因为myhostname已分配给路由器,并且我具有正确的端口映射设置,所以该地址应解析为naples而不是venice

2 try #2: 2次尝试#2:

naples$ java -Djava.rmi.server.codebase=file:/Users/andrews/Development/Java/workspace/epsilon/bin/ -Djava.security.policy=client.policy test.myClient myhostname

Note 1: the code base url format is correct, I created a small program to convert current file directory path into a url and used that. 注意1:代码库的url格式正确,我创建了一个小程序,将当前文件目录路径转换为url,并使用了该程序。 using file:///Users... has same effect. 使用file:///Users...具有相同的效果。

Other notes: 其他说明:

1 my server and client policy files correctly specify the path, as I've tested this setup with good and bad paths, and getting a security exception for bad path 1我的服务器和客户端策略文件正确指定了路径,因为我已经使用好路径和坏路径测试了此设置,并为坏路径获取了安全例外

2 this setup works if I don't use client-side defined objects, the client connects correctly to the server and the server executes. 2如果我不使用客户端定义的对象,客户端正确连接到服务器并且服务器执行,则此设置有效。

3 when I place the client-side class on the server in the server's classpath, all executes fine. 3当我将客户端类放在服务器的类路径中的服务器上时,一切正常。

All help is appreciated. 感谢所有帮助。

Do you really need to use RMI? 您真的需要使用RMI吗? Me and a friend tried it once in school and it was way slow, much slower then the simple ObjectOutputStream networking we had been doing earlier. 我和一个朋友试图在学校的一次,它是缓慢的方式慢得多然后我们早些时候做简单的ObjectOutputStream联网。

I strong agree with Chad Okere's said, RMI is really very slow and consuming-resouces. 我非常同意Chad Okere的说法,RMI确实非常缓慢且消耗资源。 sometimes directly use Sockets maybe is simple and useful chooice, regarding your exception Could you confirm your rmi server work correctly? 有时直接使用Sockets可能是简单而有用的选择,关于您的例外情况您能否确认rmi服务器正常工作? http://www.javarmi.com/2010/05/java-rmi-error-unmarshalling-arguments/ maybe be can help you http://www.javarmi.com/2010/05/java-rmi-error-unmarshalling-arguments/也许可以帮助您

暂无
暂无

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

相关问题 RMI客户端无法查找服务器-java.rmi.UnmarshalException - RMI client cannot lookup server - java.rmi.UnmarshalException RMI 调用中的 java.rmi.UnmarshalException - java.rmi.UnmarshalException in RMI call ResultSet错误java.rmi.UnmarshalException - ResultSet Error java.rmi.UnmarshalException 远程对象不支持RMI方法:java.rmi.UnmarshalException:无法识别的方法哈希 - RMI Method not supported by remote object: java.rmi.UnmarshalException: unrecognized method hash java.rmi.UnmarshalException: 解组参数错误; 嵌套异常是:java.lang.ClassNotFoundException: ServicesTableau - java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: ServicesTableau java.rmi.UnmarshalException:无法识别的方法hash:远程对象不支持的方法 - java.rmi.UnmarshalException: unrecognized method hash: method not supported by remote object weblogic上下文查找错误:java.rmi.UnmarshalException:错误解组参数 - weblogic context lookup error : java.rmi.UnmarshalException: error unmarshalling arguments 获取java.rmi.UnmarshalException:无法识别的方法哈希:远程对象不支持的方法 - Getting java.rmi.UnmarshalException: unrecognized method hash: method not supported by remote object java.rmi.UnmarshalException:java.lang.ClassNotFoundException。 无法使用RMI从另一个物理JVM访问类 - java.rmi.UnmarshalException: java.lang.ClassNotFoundException. Can't get acces to class from another physical JVM using RMI Java RMI UnmarshalException和AWS EC2服务器 - Java RMI UnmarshalException and AWS EC2 Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM