Java class loading problem

I’m having a problem getting a Java agent to properly load imported classes. The agent does JNDI lookups to an Active Directory LDAP server.

Here’s the problem: the agent runs fine on my Notes 5.0.10 client, but throws a java.lang.NoClassDefFoundError when it try to run it on the server. (Apologies: I’m actually running this on a Domino 5.0.12 server on Windows, but I’m posting the question here because the R4/R5 forum doesn’t get much attention.)

The agent relies on three standard libraries: jndi.jar, ldap.jar and providerutil.jar. All are included in the agent via Edit Project. I’ve taken this approach (rather than using JavaUserClasses= in Notes.ini) because I want to deploy this agent to several servers and I’m trying to avoid a dependency on the presence of these jar library files on each box. The agent is launched from LotusScript via RunOnServer().

My client machine does not have a JavaUserClasses= line in Notes.ini, but the development server has the following setting (put in place to support Java agents in other apps):

JavaUserClasses=D:\lotus\domino\providerutil.jar;D:\lotus\domino\mail.jar;D:\lotus\domino\activation.jar;

The import statements for my agent are as follows:

import lotus.domino.*;

import javax.naming.*;

import javax.naming.directory.*;

import java.util.Hashtable;

import java.util.Vector;

and the error appears to be generated by the following line (the agent runs fine through all the code setting up the Hashtable for the context):

DirContext ctx = new InitialDirContext(env);

Can anyone tell me why using the InitialDirContext class is throwing this error on the server, but not on the client?

I found a posting from Joseph Millar (http://www-10.lotus.com/ldd/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/ab82e1bf2e775c1d85256bc0006f0549?OpenDocument) that indicates that classes loaded via JavaUserClasses are system classes shared across all class instances. Does that indicate there’s some conflict becauae providerutil.jar is specified both in JavaUserClasses and directly in the agent?

Any suggestions or advice would be greatkly welcomed!

Thanks,

Rupert Clayton

Chicago

Subject: Update: Java class loading problem

Well, no responses, but I do have some progress to report. I got our trusty outsourced Domino Admin to place the two extra jar files in the Domino program folder on the 5.0.12 server. And I changed the explicit system class loading in the server’s notes.ini as follows:

JavaUserClasses=D:\Lotus\Domino;providerutil.jar;jndi.jar;ldap.jar;mail.jar;activation.jar;

Next, I tested the agent’s behavior in a local replica launched from the client (just re-establishing my baseline as I had also tried a bit of removing and readding the libraries via Edit Project. And… disaster. Now the Java agent refused to start at all, and I got the following error:

03/21/2008 12:31:38 PM JVM: The Java Virtual Machine creation returned an invalid JVM machine pointer.

03/21/2008 12:31:38 PM JVM: Java Virtual Machine failed to start

I did some searching on this and eventually turned up this posting from Joe Millar: http://www-10.lotus.com/ldd/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/88706d0b43a3247485256bbf00632222?OpenDocument

The key point here was a note that 5.0.10 probably had some issues with LS agents calling Java agents. My client is 5.0.10 and the server is 5.0.12.

So I went off to try the agent on the 5.0.12 server, and it runs just fine: no java.lang.NoClassDefFoundError or any others.

Moral of the story, if you can’t get your immovable enterprise to upgrade to a modern version of Domino, then try using a modern point release of an old version instead.

I still wish I didn’t need the jar files deployed directly on the server, but for some reason that won’t work.

Hope this helps some other poor soul stuck with Java agents in R5.

Rupert Clayton

Chicago