Bug 47316 - In config file, Service and engine names must match
Summary: In config file, Service and engine names must match
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: Nightly Build
Hardware: Other AIX
: P2 normal with 1 vote (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2009-06-04 09:26 UTC by Chris
Modified: 2009-06-13 13:38 UTC (History)
0 users

Proposed patch to fix this issue (2.49 KB, application/octet-stream)
2009-06-05 10:32 UTC, Mark Thomas

Note You need to log in before you can comment on or make changes to this bug.
Description Chris 2009-06-04 09:26:54 UTC
We had a config working on 6.0.18 and failing in 6.0.20.

In tomcat log, we found the following NPE at initialization:
Jun 4, 2009 5:15:25 PM org.apache.catalina.connector.MapperListener init
WARNING: Error registering contexts
Throwable occurred: java.lang.NullPointerException
        at org.apache.catalina.connector.MapperListener.registerHost(MapperListener.java:332)
        at org.apache.catalina.connector.MapperListener.init(MapperListener.java:129)
        at org.apache.catalina.connector.Connector.start(Connector.java:1146)
        at org.apache.catalina.core.StandardService.start(StandardService.java:531)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:612)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)

Following this error, server keeps on starting and is correctly listening on its connector port as expected. Any call to a JSP, static ressource will keep on returning a 400 status code.

Further testes were conducted and we found that in server.xml service name (<Service name="xxx") and engine name (<Engine name="xxx") have to match. If they don't, you get the NPE error and 400 status code. If they match, no NPE and no 400 errors.
Comment 1 Mark Thomas 2009-06-04 09:52:19 UTC
That looks to be a side effect of the fix for 42707.

Having the names the same won't cause any problems. In fact it helps make sure JMX works as expected.

As has been said previously, we really need to combine service and engine. That is too big a change for 6.0.x but we should be able to do it for 7. For 6.0.x, the best we can do is add something to the docs.
Comment 2 Remy Maucherat 2009-06-05 07:09:48 UTC
Actually, you can fix it by removing the use of ServerFactory, and get the engine through the connector.
Comment 3 Mark Thomas 2009-06-05 10:32:12 UTC
Created attachment 23764 [details]
Proposed patch to fix this issue

Given it was me who removed ServerFactory from trunk, you'd think I would have figured that out.

Thanks for the tip. Patch attached.
Comment 4 Mark Thomas 2009-06-10 04:49:27 UTC
This has been fixed in trunk and will be in 6.0.21
Comment 5 Konstantin Kolinko 2009-06-10 06:06:19 UTC
Reopening. This issue is reproducible in tc5.5.x.
The fix is already proposed there.
Comment 6 Mark Thomas 2009-06-13 13:38:58 UTC
Fix in 5.5.x and will be in 5.5.28 onwards.