Unable to load RMI with external classes

I

Ian

Hello!

I have written quite a large application that uses RMI. I can run rmic and
generate the skeletons which I copied to
http://www.dur.ac.uk/i.j.hammond/project/codebase/.

My application uses an external jar called ldapjdk.jar which is located in
the same directory as all my class files.

When I run java -

Djava.rmi.server.codebase=http://www.dur.ac.uk/i.j.hammond/project/codebase

RCSImpl

I get the error java.lang.NoClassDefFoundError: netscape/ldap/LDAPException

So I then set my classpath to read:

java -classpath .:/home/hudson/ug/d25sg2/ldapjdk.jar -
Djava.rmi.server.codebase=http://www.dur.ac.uk/i.j.hammond/project/codebase

RCSImpl

and I get the same error even though ldapjdk.jar does exist. I have also
tried placing the jar in the codebase with no effect.

If I remove the binding to the RMI in the RCSImpl class then all works fine
and the jar is found.

Does anyone have any advice?

Thanks,

Ian
 
J

JScoobyCed

Ian said:
Hello!

I have written quite a large application that uses RMI. I can run rmic and
generate the skeletons which I copied to
http://www.dur.ac.uk/i.j.hammond/project/codebase/.

My application uses an external jar called ldapjdk.jar which is located in
the same directory as all my class files.

When I run java -

Djava.rmi.server.codebase=http://www.dur.ac.uk/i.j.hammond/project/codebase

RCSImpl

I get the error java.lang.NoClassDefFoundError: netscape/ldap/LDAPException

Do you have a RMISecurityManager ? (i.e. System.setSecurityManager(new
RMISecurityManager()); ) in your code. You can't load remote classes
without it.
Now that will mean that you might need to have a java.policy and start
your app with the additional parameter -Djava.security.policy=java.policy


So I then set my classpath to read:

java -classpath .:/home/hudson/ug/d25sg2/ldapjdk.jar -
Djava.rmi.server.codebase=http://www.dur.ac.uk/i.j.hammond/project/codebase

RCSImpl

I would say same thing here. The subclasses of UnicastRemoteObject will
be first loaded through RMI channel (note: don't take this for 100%, it
is the most probable thing I am thinking of)
and I get the same error even though ldapjdk.jar does exist. I have also
tried placing the jar in the codebase with no effect.

If I remove the binding to the RMI in the RCSImpl class then all works fine
and the jar is found.

Then maybe because here it sees there is no RMI environment, so it loads
the classes directly, note the stubs and skeletons.
Does anyone have any advice?

Try using a RMISecurityManager
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,118
Latest member
LatishaWhy
Top