ClassLoader problem in embedded tomcat

Hier geht es um XAMPP AddOns wie z. B. das Apache-Konfigurations-Tool Apanatschi. Irgendwelche Probleme damit oder Fragen dazu? Dann ist hier genau der richtige Ort um nachzufragen.

ClassLoader problem in embedded tomcat

Postby sabinewa » 12. October 2006 12:10

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:

[code]
// 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);
}
[/code]


Best regards,
Sabine[/code]
sabinewa
 
Posts: 1
Joined: 12. October 2006 12:01

Return to XAMPP AddOns

Who is online

Users browsing this forum: No registered users and 2 guests