Published on Aug 23 2013 in Error messages Java Tomcat

This error (java.lang.NullPointerException at org.apache.tomcat.util.modeler.Util.objectNameValueNeedsQuote) can show up due to bad syntax in web.xml.

Additional SEVERE and 'Caused by' lines accompanying it are:

SEVERE: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to initialize component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[].StandardWrapper[null]] 
Caused by: java.lang.NullPointerException 
       at org.apache.tomcat.util.modeler.Util.objectNameValueNeedsQuote(Util.java:26) 

SEVERE: ContainerBase.addChild: start: 
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] 
Caused by: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to initialize component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[].StandardWrapper[null]] 

SEVERE: Error deploying web application directory /home/user/appservers/apache-tomcat-7.0.42/webapps/ROOT java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]] 

In this particular case there was

<servlet>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
</servlet>

added to web.xml but init-param should be set inside a named servlet (servlet-name is required parameter of each servlet tag) element and in this case servlet name generated by XML parser was null thus the java.lang.NullPointerException at org.apache.tomcat.util.modeler.Util.objectNameValueNeedsQuote. You may recreate this error by simply pasting

<servlet></servlet>

into web.xml and restarting tomcat.

See also http://docs.oracle.com/cd/E13222_01/wls/docs81/webapp/web_xml.html