ClassNotFoundException in the plugin

Hi!

I’‘m trying to create plugin to call some corporate application on WebLogic server via T3 protocol. So I need Weblogic client library (weblogic.jar). I placed it in plugin’'s lib\ directory, and I can see it in the deployed plugin directory structure in the server. But I get follow stacktrace:

Connection to CIS lost: java.lang.NullPointerException

javax.naming.NoInitialContextException: Cannot instantiate class: weblogic.jndi.WLInitialContextFactory Root exception is java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory

at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)

at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)

at javax.naming.InitialContext.init(Unknown Source)

at javax.naming.InitialContext.(Unknown Source)

at ru.rian.wildfire.SPNMlinkPlugin.startNewsWorkflow(SPNMlinkPlugin.java:305)

at ru.rian.wildfire.SPNMlinkPlugin.processMessage(SPNMlinkPlugin.java:259)

at ru.rian.wildfire.SPNMlinkPlugin.processPacket(SPNMlinkPlugin.java:234)

Caused by: java.lang.ClassNotFoundException: weblogic.jndi.WLInitialContextFactory

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClassInternal(Unknown Source)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Unknown Source)

at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)

It’'s absolutely reliable that absent class WLInitialContextFactory lies in the weblogic.jar

for information, plugin code example:

try {

Properties p = new Properties();

p.setProperty(“java.naming.provider.url”, provider_url);

p.setProperty(“java.naming.security.principal”, security_principal);

p.setProperty(“java.naming.security.credentials”, security_credentials);

p.setProperty(“jndi.ejb.NewsManager”, pathNewsManager);

p.setProperty(“java.naming.factory.initial”, factory_initial); <==== “weblogic.jndi.WLInitialContextFactory” string is here

ic = new InitialContext§; <==== and crash here

objref = ic.lookup(jndiName);

NewsManagerHome home = (NewsManagerHome) PortableRemoteObject.narrow(objref, NewsManagerHome.class);

newsManager = home.create();

} catch (Exception ex2) {

log.error(ex2);

newsManager = null;

}

Hello

it reminds something similar … I am not sure it is the case but let me describe what was happening:

I was running wildfire inside tomcat so all classes of the wildfire were loaded with class loader embedded in the context of the web application.

I developped a plugin and wanted to use reflection. I don’'t remember precisely how or why I needed to use it but the class loader used was not the one of the plugin which searches in /lib but the class loader of the servlet that had not the plugin path in its search directories (it is normal because plugin can be added or removed independantly and the web app could not have any knowledge of the plugin and its content).

So I moved my classes in the wildfire.war libraries and it worked.

Of course I don’'t know if this can be the same problem but it can maybe give you some ideas about what could happen.

Indeed, plugin use main program classloader. Problem was solved by placing dynamically loading classes in wildfire embedded jre lib/ext directory.