Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question

Remoting IllegalArgumentException with classes from different classloaders

I have deployed a remote service with a method where one of the parameters is an interface. I am experiencing a problem where a concrete class is compiled for the client only, but is not deployed on the grid server. When the client passes the class to the remote method, I get an "IllegalArgumentException: argument type mismatch". I believe the reason this happens is because when the class is deserialized by the server, it is loaded into a different classloader than the classloader for the interface and service classes. More importantly, a second instance of the interface is loaded into the former classloader and the concrete class references this instance of the interface rather than the instance of the interface in the latter classloader. This appears to make it impossible to define arbitrary classes in client code, then pass them as arguments to the remote service method.

Is this true? If so, is there a way around this problem?

Thanks, Larry

Edited by: Larry Chu on Jul 8, 2008 11:34 AM

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=2445]{quote}

asked 2008-07-08 11:30:45 -0600

larrychu gravatar image

updated 2013-08-08 09:52:00 -0600

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

Space Domain Classes must be at:
PU Folder/shared-lib/DOMAIN_CLASSES.jar

where DOMAIN_CLASSES.jar should have all your Space Domain Classes.
This will make sure these will be loaded into the correct class loader avoiding the problem you see.

Business Logic classes should can be under the PU Folder at their own jar file.


answered 2008-07-08 13:38:28 -0600

shay hassidim gravatar image
edit flag offensive delete link more



I had put my service classes in PUFolder/com/... and the interface and concrete class previously referred to (Not really domain classes) into the same "com" folder. Is this still the wrong place for them?

Thanks, Larry

larrychu gravatar imagelarrychu ( 2008-07-08 14:34:18 -0600 )edit

With my experience "IllegalArgumentException: argument type mismatch" would be solved by placing classes that are used by the space within the shared-lib folder. Can you give this a try? Shay

shay hassidim gravatar imageshay hassidim ( 2008-07-08 15:59:58 -0600 )edit

Is there any reason I shouldn't put all service and domain interfaces and concrete classes in shared-lib? I guess doing so would make hot redeployment of maintenance changes to those classes without shutdown of container impossible. Any other reasons?

Edited by: Larry Chu on Jul 8, 2008 6:21 PM

larrychu gravatar imagelarrychu ( 2008-07-08 18:03:28 -0600 )edit

It may have been premature to immediately assume that my error was caused by the class not deployed to the server. It seems that even when the class is deployed to the server, a separate class is still created in a different classloader. I'm not sure how to coerce the server to use the existing class from the appropriate classloader in the hierarchy and I don't understand how the classloaders are structured. For now I will have to guess, test and retry.

answered 2008-07-08 13:18:36 -0600

larrychu gravatar image
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2008-07-08 11:30:45 -0600

Seen: 126 times

Last updated: Jul 08 '08