dcsimg
A weird exception when making a remote method call
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   David_Duran
Posted On:   Friday, December 13, 2002 05:03 PM

Can anyone possibly explain to me who/what could be the culprit of the exception below? Context: RMI client code in a jsp file running on Tomcat 4.0 tries to make a remote method call to a remote server. Simplified below: RemoteInterface ri = Naming.lookup("//.../RemoteServer"); ri.remoteFunc(); // Exception happens here! I'm not sure how to interpret the exception- Is it a tomcat problem? Is is a client problem? A server problem? Can anyone shed some light? I would really appreciate it. java.rmi.MarshalException: Error marshaling transport header; nested exception is: java.net.SocketException: Connection reset by peer: Connection reset by peer    More>>

Can anyone possibly explain to me who/what could be the culprit of the exception below?
Context: RMI client code in a jsp file running on Tomcat 4.0 tries to make a remote method call to a remote server. Simplified below:


RemoteInterface ri = Naming.lookup("//.../RemoteServer");

ri.remoteFunc(); // Exception happens here!


I'm not sure how to interpret the exception- Is it a tomcat problem? Is is a client problem? A server problem? Can anyone shed some light? I would really appreciate it.


java.rmi.MarshalException: Error marshaling transport header; nested exception is:

java.net.SocketException: Connection reset by peer: Connection reset by peer

java.net.SocketException: Connection reset by peer: Connection reset by peer

at java.net.SocketInputStream.socketRead(Native Method)

at java.net.SocketInputStream.read(SocketInputStream.java:90)

at java.io.BufferedInputStream.fill(BufferedInputStream.java:186)

at java.io.BufferedInputStream.read(BufferedInputStream.java:204)

at java.io.DataInputStream.readByte(DataInputStream.java:222)

at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:206)

at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)

at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:83)

at sun.rmi.server.ActivatableRef.invoke(ActivatableRef.java:120)

at server.RemoteServer_Stub.remoteFunc(Unknown Source)

at org.apache.jsp.YourPage$jsp._jspService(YourPage$jsp.java:1054)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)

...

at java.lang.Thread.run(Thread.java:484)

   <<Less

Re: A weird exception when making a remote method call

Posted By:   David_Duran  
Posted On:   Friday, January 10, 2003 11:30 AM

After much trial and error, I found out what the culprit was. This might differ for you depending on what circumstances you are getting this error.


Our client code caches the remote object. It will do a Naming Lookup and store the object in a HashMap associated with the URI that it was given.


Then, the next time a request is made for the object with that same URI, the Map would be checked first. If a value existed with that key then we would just return the cached remote object. If one didn't, then we would do a Naming.lookup and again store it in the Map.


For an application that receives thousands of hits/day, it seemed like a time saver, especially since doing a Naming.lookup EACH time was very redundant.


Unfortunately, that exception would be the result of the caching on the client code and the daily inactivation of the RMI servers that we were doing. SOMETHING, I don't even know exactly what, would cause the cached object to fail. By disabling the daily inactivation (& not the caching), the problem went away.

About | Sitemap | Contact