jetty / tomcat webapp context.xml

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

jetty / tomcat webapp context.xml

golbie
Hello !
 
I need support regarding integration of a tomcat web application with the jetty webserver. My application is more complex (using it's own context.xml) so that I did not find any examples how to deal with it.
 
My tomcat webapp project has following file structure (maven compatible):
 
-------------------------------
* src/main/java
* src/main/webapp
+ META-INF (contains the context.xml file with application specific properties like "<Environment>...", "<Logger>...", "<Valve...>" and "<Resource ...>")
+ jsps (contains jsp files)
+ WEB-INF (contains the web.xml file with properties like "servlet-mapping" or "servlet")
index.jsp
-------------------------------
 
Now I want to start the maven jetty:run goal. It exits with following exception because my own class InitializeApplication attempts to read some properties from the application context file (META-INF/context.xml).
The reason for this exception is the missing context file that seems not to be managed by jetty. Now my questions:
 
1. is there any way to execute a tomcat application with both, tomcat and jetty, without configuration changes (perhaps contextHandlers node in the pom.xml, e.g. '<contextHandler implementation="org.apache.catalina.core.StandardContext"> ....' or something similar)?
2. if changes are necessary what should be changed (conversion of the tomcat-specific context.xml into the jetty-specific xml structure and so on...).
 
-----------------------------
Context file excerpt:
-----------------------------
 
<?xml version="1.0" encoding="UTF-8"?>
<Context
 docBase="mytestapplication"
 path="/mytestapplication"
 unpackWARs="true"
 reloadable="true"
 swallowOutput="true">
 
 <Logger className="org.apache.catalina.logger.FileLogger"
  prefix="wigeoweb."
  suffix=".log"
  timestamp="true"/>
 <Valve className="org.apache.catalina.valves.AccessLogValve"
  directory="logs"
  prefix="wigeoweb_access_log."
  suffix=".log"
  pattern="combined"
  resolveHosts="true"/>
 
 <Resource
  name="jdbc/ConfigDB"
  auth="Container"
  type="javax.sql.DataSource"
  factory="org.apache.commons.dbcp.BasicDataSourceFactory"
  maxActive="500"
  maxIdle="5"
  maxWait="3000"
  username="xxx"
  password="yyy"
  driverClassName="org.gjt.mm.mysql.Driver"
  url=""
  />
 
 <Environment name="baseLogDir" value="C:\tmp\logs" type="java.lang.String" override="false"/>
 <Environment name="logEnabled" value="true" type="java.lang.String" override="false"/>
</Context>
 
-----------------------------
Source Code (InitializeApplication):
-----------------------------
 
Context appCtx = (Context)(new InitialContext()).lookup("java:comp/env");
 
//...code
 
String string = (String)(appCtx.lookup("baseLogDir"));
// here the exception is thrown because appCtx does not contain "baseLogDir" key ===> context.xml has not been recognized by jetty!!

if( string == null ) throw new ConfigurationLoadException(...);
 
-----------------------------
Thrown Exception:
-----------------------------
 
[INFO] Starting jetty 6.1.19 ...
2009-08-13 12:30:17.618::INFO:  jetty-6.1.19
2009-08-13 12:30:17.868::WARN:  Unknown realm: MyTestApplication Realm
2009-08-13 12:30:17.931::INFO:  No Transaction manager found - if your webapp requires one, please configure one.
13.08.2009 12:30:18 InitializeApplication init
INFO: ################################################################################################################################
13.08.2009 12:30:18 InitializeApplication init
INFO: MyTestApplication Framework
13.08.2009 12:30:18 InitializeApplication init
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR: Initialization failed! (ConfigurationLoadException[sourceInformation="Web application context",message="Key "baseLogDi
r" not found in web application configuration!"])

13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     ApplicationContextFrameworkConfiguration.getStringE(ApplicationContextFrameworkConfiguration.java:164)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     mytestapplication.framework.config.BaseFrameworkConfiguration.parseConfiguration(BaseFrameworkConfiguration.jav
a:72)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     ApplicationContextFrameworkConfiguration.<init>(ApplicationContextFrameworkConfiguration.java:66)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     InitializeApplication.init(InitializeApplication.java:254)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:431)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:263)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:676)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1239)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:466)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:124)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.Server.doStart(Server.java:224)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:441)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:553)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:523)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371
)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     java.lang.reflect.Method.invoke(Method.java:589)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
13.08.2009 12:30:18 InitializeApplication init
SCHWERWIEGEND: ERROR:     org.codehaus.classworlds.Launcher.main(Launcher.java:375)
2009-08-13 12:30:18.618::INFO:  Shutdown hook executing
 
 
thank you for the support
golbie