ClassLoader problem in embedded tomcat

Discussion in 'Java' started by sabine, Oct 11, 2006.

  1. sabine

    sabine Guest

    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
    sabine, Oct 11, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. Miguel

    classloader in tomcat

    Mr. Miguel, Jul 11, 2003, in forum: Java
    Replies:
    2
    Views:
    596
    Miguel De Anda
    Jul 14, 2003
  2. Replies:
    5
    Views:
    692
    Nigel Wade
    Jul 15, 2003
  3. Mikito Harakiri

    Tomcat ClassLoader/Compile nightmare

    Mikito Harakiri, Nov 6, 2003, in forum: Java
    Replies:
    0
    Views:
    332
    Mikito Harakiri
    Nov 6, 2003
  4. Mark F

    Tomcat classloader problem

    Mark F, Mar 5, 2004, in forum: Java
    Replies:
    0
    Views:
    477
    Mark F
    Mar 5, 2004
  5. Moiristo

    Tomcat classloader

    Moiristo, Jun 21, 2006, in forum: Java
    Replies:
    0
    Views:
    328
    Moiristo
    Jun 21, 2006
Loading...

Share This Page