The code in StandardEngine (around line 354) handles the situation when the standard engine is not set. But if you don't do it, the execution of Tomcat embedded fails with a NPE. The reason for this is a missing name for the StandardService. A workaround is to just add the StandardService to the server container with the following code: <code> StandardService service = new StandardService(); service.setContainer( server.getContainer() ); service.setName(TC_HOST_CONTAINER_NAME); service.initialize(); </code> However, the name should be set in org.apache.catalina.core.StandardEngine:355 to the engine name. The error exists in the trunk too.
Trunk has been re-factored so that code doesn't exist any more. The following patch should work for 6.0.x: Index: java/org/apache/catalina/core/StandardEngine.java =================================================================== --- java/org/apache/catalina/core/StandardEngine.java (revision 958198) +++ java/org/apache/catalina/core/StandardEngine.java (working copy) @@ -354,6 +354,8 @@ service=new StandardService(); service.setContainer( this ); service.initialize(); + // Use same name for Service + service.setName(getName()); } catch( Throwable t ) { log.error(t); }
Fixed in 6.0.x and will be included in 6.0.28 onwards.