Re: help with embedded tomcat's webapp classloader

2005-09-19 Thread Donald Ball

Donald Ball wrote:

everything works okay but my webapp fails on initialization, with a 
NoClassDefFoundError on net.sf.hibernate.HibernateException. this is 
somewhat surprising given that hibernate.jar lives in the webapp's 
WEB-INF/lib directory. is there some additional configuration i need to 
do on my embedded Context object to force it to act like a normal tomcat 
webapp Context? do i perhaps need to ensure the webapp directory 
structure is in place before constructing my Tomcat instance? (that is 
to say, are the contents of WEB-INF/lib examined when the Context is 
created and/or added to the Host, or when tomcat is started?)


i worked around this issue by simply adding the classpath resources 
under WEB-INF to the classpath of the swt application in which tomcat is 
embedded. not a very elegant solution, but it'll do for the moment. now 
i find that jsp files cannot be compiled because Jasper is unable to 
find a javac compiler; com.sun.tools.javac.Main is not on the classpath.


ought i hunt down tools.jar and add that to my classpath manually as 
well, or can someone point me towards some documentation w.r.t. 
configuring embedded tomcat's webapp classloaders? i'm frankly unable to 
tell if this behavior is expected and i'm supposed to be manually doing 
some extra initialiation work on my Context, or if this is unusual 
behavior and i'm doing something wrong? any suggestions?


- donald

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



help with embedded tomcat's webapp classloader

2005-09-16 Thread Donald Ball
hey guys. i'm trying out embedding tomcat 5.0 in an swt app that creates 
complex configuration data for a webapp. basically, i'd like the users 
to be able to do a test deploy of the webapp on their own box using 
hsqldb and an embedded tomcat.


my code looks more or less like so:

import org.apache.catalina.*;
import org.apache.catalina.logger.FileLogger;
import org.apache.catalina.realm.MemoryRealm;
import org.apache.catalina.startup.Embedded;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.net.InetAddress;

public final class Tomcat {

private static final Log log = LogFactory.getLog(Tomcat.class);

private final Embedded embeddedTomcat;
private final Engine baseEngine;
private final Host baseHost;
private final Context rootContext;

public Tomcat() {
embeddedTomcat = new Embedded();

final FileLogger fileLogger = new FileLogger();
fileLogger.setDirectory(.);
fileLogger.setPrefix(myTomcat);
fileLogger.setSuffix(.log);
fileLogger.setTimestamp(true);
embeddedTomcat.setLogger(fileLogger);

final MemoryRealm memoryRealm = new MemoryRealm();
embeddedTomcat.setRealm(memoryRealm);

baseEngine = embeddedTomcat.createEngine();
baseEngine.setName(myEngine);
baseEngine.setDefaultHost(localhost);

baseHost = embeddedTomcat.createHost(localhost, webapps);
baseEngine.addChild(baseHost);

rootContext = embeddedTomcat.createContext(, ROOT);
baseHost.addChild(rootContext);

embeddedTomcat.addEngine(baseEngine);

final Connector httpConnector = 
embeddedTomcat.createConnector((InetAddress)null, 8080, false);

embeddedTomcat.addConnector(httpConnector);
}

public void start() {
try {
embeddedTomcat.start();
} catch (LifecycleException e) {
log.error(Error starting tomcat, e);
}
}

public void stop() {
try {
embeddedTomcat.stop();
} catch (LifecycleException e) {
log.error(Error stopping tomcat, e);
}
}

}

everything works okay but my webapp fails on initialization, with a 
NoClassDefFoundError on net.sf.hibernate.HibernateException. this is 
somewhat surprising given that hibernate.jar lives in the webapp's 
WEB-INF/lib directory. is there some additional configuration i need to 
do on my embedded Context object to force it to act like a normal tomcat 
webapp Context? do i perhaps need to ensure the webapp directory 
structure is in place before constructing my Tomcat instance? (that is 
to say, are the contents of WEB-INF/lib examined when the Context is 
created and/or added to the Host, or when tomcat is started?)


- donald

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]