tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sabine Wagner" <wagnersab...@gmx.de>
Subject ClassLoader problem in embedded tomcat
Date Wed, 11 Oct 2006 16:54:36 GMT
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 Wagner



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message