https://bz.apache.org/bugzilla/show_bug.cgi?id=62090

            Bug ID: 62090
           Summary: NPE in o.a.t.util.modeler.Util when servlet-name does
                    not exist in web.xml
           Product: Tomcat 9
           Version: 9.0.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: csuth...@apache.org
  Target Milestone: -----

When using a web.xml that specifies a servlet element, but excludes
servlet-name a NPE is observed and the webapp fails to deploy. A check should
be added in the StandardWrapper and it should throw a ServletException when
servlet-name is missing.

To reproduce, add a serlvet tag to your web.xml with no servlet-name. For
example:

  <servlet>
    <servlet-class>com.example.servlets.HelloServlet</servlet-class>
  </servlet>

Then start Tomcat and observe the exception in catalina.out:

SEVERE [main] org.apache.catalina.core.ContainerBase.addChildInternal
ContainerBase.addChild: start:
  org.apache.catalina.LifecycleException: Failed to initialize component
[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/test].StandardWrapper[null]]
    at
org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:441)
    ....
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
Caused by: java.lang.NullPointerException
    at
org.apache.tomcat.util.modeler.Util.objectNameValueNeedsQuote(Util.java:26)
    at
org.apache.catalina.core.StandardWrapper.getObjectNameKeyProperties(StandardWrapper.java:1619)
    at
org.apache.catalina.util.LifecycleMBeanBase.initInternal(LifecycleMBeanBase.java:61)
    at
org.apache.catalina.core.ContainerBase.initInternal(ContainerBase.java:885)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
    ... 49 more

Setting xmlValidation="true" on the Context may handle this differently, but
it's off by default so we should check for null and handle that case.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to