How does Quartz RMI Remote classloading work?

432 views Asked by At

I'm working with quartz-2.2.1 using http URLs in the codebase and have made it to 1st base with codebase and security managers.

I have two questions about RMI classloading:

1) Can jars be requested via http RMI? I specify a single jar containing the complete application in the the codebase URL passed to the client. Even though the jar is requested and "served" by the http server, the server continues to receive requests for classes that are contained in libraries included in the jar.

Any ideas what's going on here? I would expect the server to add the jar to its classpath but this does not seem to be the case.

I didn't notice any methods in RMIClassLoader that handle anything other than classes.

2) Can RMI request objects other than classes? I finally figured out how to serve classes from jars (to solve the above problem) but the remote job fails trying to load a ".txt" resource. It is contained in the application jar, but the http server never sees the request.

I am also wondering if these issues are common to RMI in general or specific to Quartz.

As this is my first foray into RMI, any and all comments will be very much appreciated.

1

There are 1 answers

0
user207421 On

Can jars be requested via http RMI?

Yes.

I specify a single jar containing the complete application in the the codebase URL passed to the client.

That's normal.

Even though the jar is requested and "served" by the http server, the server continues to receive requests for classes that are contained in libraries included in the jar.

Aha. 'libraries included in the jar' may not work. You should provided them separately via further codebase URLs. The java.rmi.server.codebase property is a list of URLs, not just one.

Any ideas what's going on here? I would expect the server to add the jar to its classpath but this does not seem to be the case.

It ultimately adds a URLClassLoader to its classloader set.

I didn't notice any methods in RMIClassLoader that handle anything other than classes.

You need to note that RMIClassLoader isn't really a ClassLoader. It's a strange beast but its class loading is ultimately delegated to a URLClassLoader.

2) Can RMI request objects other than classes?

The codebase feature is for anything you can retrieve via a classloader, including resources, if they are obtained via getResource() and friends.

I finally figured out how to serve classes from jars (to solve the above problem) but the remote job fails trying to load a ".txt" resource. It is contained in the application jar, but the http server never sees the request.

There wouldn't be such a request to see. It should be loaded straight from the .jar file, which has already been downloaded. Check that you are referring to the resource correctly.