Hi All,
I am trying to have a Embedded Tomcat Server. I got the examples to do so from the web, and modified the code, so that my Tomcat server is embedded along with the Web Application.
However, when I run the Embedded Tomcat class, it, I am getting the following error:
StandardManager[/TestApp]: Seeding of random number generator has been completed
StandardWrapper[/TestApp:default]: Loading container servlet default
StandardWrapper[/TestApp:default]: Marking servlet default as unavailable
StandardContext[/TestApp]: Servlet /TestApp threw load() exception
javax.servlet.ServletException: Error instantiating servlet class org.apache.catalina.servlets.DefaultServlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.jav a:865)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:776)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.j ava:3363)
I have attached the Embedded Tomcat java source file as well.
What am I missing in this ? Any solution or pointers to why this is occurring are most welcome.
Thanks and Regards, Mohamed Rafi S
//package com.apple.pos;
import java.net.URL; import org.apache.catalina.Connector; import org.apache.catalina.Context; import org.apache.catalina.Deployer; import org.apache.catalina.Engine; import org.apache.catalina.Host; import org.apache.catalina.logger.SystemOutLogger; import org.apache.catalina.startup.Embedded; import org.apache.catalina.Container; public class EmbeddedTomcat { public static int tesss = 0; private String path = null; private Embedded embedded = null; private Host host = null; public EmbeddedTomcat() { tesss = 9999; } public void setPath(String path) { this.path = path; } public String getPath() { return path; } public void startTomcat() throws Exception { Engine engine = null; System.setProperty("catalina.home", getPath()); embedded = new Embedded(); embedded.setDebug(0); embedded.setLogger(new SystemOutLogger()); engine = embedded.createEngine(); engine.setDefaultHost("localhost"); host = embedded.createHost("localhost", getPath() + "/webapps"); engine.addChild(host); Context context1 = embedded.createContext("/TestApp", getPath() + "/webapps/TestAppp"); host.addChild(context1); embedded.addEngine(engine); Connector connector = embedded.createConnector(null, 8080, false); embedded.addConnector(connector); embedded.start(); } public void stopTomcat() throws Exception { embedded.stop(); } public void registerWAR(String contextPath, URL warFile) throws Exception { if ( contextPath == null ) { throw new Exception("Invalid Path : " + contextPath); } if( contextPath.equals("/") ) { contextPath = ""; } if ( warFile == null ) { throw new Exception("Invalid WAR : " + warFile); } Deployer deployer = (Deployer)host; Context context = deployer.findDeployedApp(contextPath); if (context != null) { throw new Exception("Context " + contextPath + " Already Exists!"); } deployer.install(contextPath, warFile); } public void unregisterWAR(String contextPath) throws Exception { Context context = host.map(contextPath); if ( context != null ) { embedded.removeContext(context); } else { throw new Exception("Context does not exist for named path :" + contextPath); } } public static void main(String args[]) { try { EmbeddedTomcat tomcat = new EmbeddedTomcat(); tomcat.setPath("/Users/rafi/Desktop/Tomcat_Research/jakarta-tomcat-4.1.31/"); tomcat.startTomcat(); Thread.sleep(1000000); tomcat.stopTomcat(); System.exit(0); } catch( Exception e ) { e.printStackTrace(); } } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]