Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > ClassLoader problem in embedded tomcat

Reply
Thread Tools

ClassLoader problem in embedded tomcat

 
 
sabine
Guest
Posts: n/a
 
      10-11-2006
Hello,

I use embedded tomcat 5.5.20 in an osgi/ equinox bundle. When the
bundle is started, tomcat is also started, but tomcat uses the wrong
ClassLoader. In fact, tomcat uses an osgi's DefaultClassLoader. The
console's output is the following:

osgi> install file:tomcatbundle_1.0.0.jar
Bundle id is 262

osgi> start 262
Tomcat starting...
11.10.2006 16:50:59 org.apache.catalina.startup.Embedded start
INFO: Starting tomcat server
11.10.2006 16:50:59 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.20
11.10.2006 16:50:59 org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
11.10.2006 16:50:59 org.apache.catalina.loader.WebappLoader start
INFO: Dual registration of jndi stream handler: factory already defined
11.10.2006 16:50:59 org.apache.catalina.loader.WebappLoader
setClassPath
INFO: Unknown loader
org.eclipse.osgi.internal.baseadaptor.DefaultClass Loader@1b4fad5 class
org.eclipse.osgi.internal.baseadaptor.DefaultClass Loader
11.10.2006 16:50:59 org.apache.catalina.loader.WebappLoader
setClassPath
INFO: Unknown loader
org.eclipse.osgi.internal.baseadaptor.DefaultClass Loader@1b4fad5 class
org.eclipse.osgi.internal.baseadaptor.DefaultClass Loader
11.10.2006 16:51:00 org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
11.10.2006 16:51:00 org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Tomcat started


This DefaultClassLoader makes problems with loading webapplications
properly, especially with loading libraries included in
webapplications.
How can I set the right ClassLoader?
I think org.apache.catalina.loader.WebappLoader or WebappClassLoader is
the right one, or does tomcat usually use another one?
Is the ClassLoader set for the context, the host or the engine?


My embedded tomcats' init()-method before tomcat is started:


// Instance variables:
private String name = "local";
private int portNumber = 8080;
private Embedded embedded;
private Engine baseEngine;
private Host baseHost;
private Connector httpConnector;

...

private void init(){

MemoryRealm realm;
Context managerContext;
String baseEngineName;
String hostName;

embedded = new Embedded();
realm = new MemoryRealm();
embedded.setRealm(realm);

// create an Engine
baseEngine = embedded.createEngine();

// set Engine properties
baseEngineName = name + "Engine";
hostName = name + "host";

baseEngine.setName(baseEngineName);
baseEngine.setDefaultHost(hostName);

baseHost = embedded.createHost(hostName, "webapps");
baseEngine.addChild(baseHost);

// RootContext
addContext("", "ROOT");

// ManagerContext
managerContext = addContext("/manager", "manager");
managerContext.setPrivileged(true);

// add new Engine to set of Engine for embedded server
embedded.addEngine(baseEngine);

// create Connector
httpConnector = embedded.createConnector((java.net.InetAddress)
null, portNumber, false);

// add new Connector to set of Connectors for embedded server,
associated
// with Engine
embedded.addConnector(httpConnector);
}



Best regards,
Sabine

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tomcat classloader Moiristo Java 0 06-21-2006 02:26 PM
Tomcat classloader problem Mark F Java 0 03-05-2004 02:33 PM
Tomcat ClassLoader/Compile nightmare Mikito Harakiri Java 0 11-06-2003 11:10 PM
ClassLoader + tomcat read-the-signature@send-spam-to-dev-null.com Java 5 07-15-2003 01:28 PM
classloader in tomcat Mr. Miguel Java 2 07-14-2003 06:18 PM



Advertisments