ClassLoader problem in embedded tomcat

S

sabine

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.DefaultClassLoader@1b4fad5 class
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader
11.10.2006 16:50:59 org.apache.catalina.loader.WebappLoader
setClassPath
INFO: Unknown loader
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1b4fad5 class
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader
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
 

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,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top