简体   繁体   中英

Exception Thrown java.lang.NoClassDefFoundError: org.apache.commons.logging.Logfactory from Domino OSGi Plugin

I am building an IBM Domino OSGi plugin which packages up a class that entends HttpServlet .

I want to make Http calls ( get , post , etc.) from the Servlet using org.apache.httpcomponents.httpclient_4.2.3 and org.apache.httpcomponents.httpcore_4.2.3 (extracted from the OSGi bundles).

I have added the two jar files to domino\\jvm\\lib\\ext , made the usual changes to java.policy file*, and added the jars to the build path.

When I add code to create and use DefaultHttpClient the server throws the error:

java.lang.NoClassDefFoundError: org.apache.commons.logging.Logfactory

I know that logging is a bit of a tricky subject in Domino's java implementation. The curious thing is I have the same code running with a Servlet contained by an NSF which runs just fine. However within my OSGi context it breaks. If I call the servlet using a url that includes say /log.nsf/ it still breaks.

Any help gratefully received!

grant {
permission java.security.AllPermission;
};

I'm not sure why it works in your NSF implementation but looks like you need commons-logging-1.1.1.jar . That should be included in the httpcomponents download. Or you can download it from here:

http://commons.apache.org/logging/download_logging.cgi

I've had problems with org.apache packages before in XPages, basically because they try to log to the file system and the security policy doesn't like that. Adding it as a referenced library etc, it uses the same ClassLoader as the XPages runtime, so tries to use the one from the server, and that's when you get the NoClassDefFoundError.

Tried adding it to the WebContent\\WEB-INF\\lib folder of your OSGi plugin. Adding it to that path works in an NSF because it uses a different ClassLoader. It could well circumvent the problems you're having in an OSGi plugin as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM