Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-3714

Presence of <servlet-name> and <url-pattern> is not validated for <servlet-mapping> inside the web.xml

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 9.0.0.Beta1
    • 9.0.0.Alpha1
    • Web (Undertow)
    • None
      • Deploy a simple WAR on WildFly 9 with the above mentioned web.xml file.
      • Before deploying the application check if the <servlet-mapping> tag has valid <servlet-name> and <url-pattern>

      • WildFly do not validate if the <servlet-mapping> tag has valid mappings or not. This should have been handled properly.

      Example: If following kind of web.xml based application is deployed on WildFly9 then

      <?xml version="1.0"?>
      <web-app xmlns="http://java.sun.com/xml/ns/javaee"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
            version="3.0"> 
      	<servlet>
      		<servlet-name>MyServlet</servlet-name>
      		<servlet-class&gt;servlets.MyServlet</servlet-class&gt;
                      <load-on-startup>1</load-on-startup>
      	</servlet>
      	<servlet-mapping>
      		<servlet-name>MyServlet</servlet-name>
      		<!--url-pattern></url-pattern-->             <!-- NOTICE  url-pattern-tag is missing here -->
      	</servlet-mapping>
      </web-app>
      
      • With the above kind of web.xml a NullPointerException is encountered during deployment.
      15:50:20,207 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./ContextParamNullDemo.UndertowDeploymentInfoService: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./ContextParamNullDemo.UndertowDeploymentInfoService: Failed to start service
      	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
      	at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
      Caused by: java.lang.NullPointerException
      	at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService.handleServletMappings(UndertowDeploymentInfoService.java:910)
      	at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService.createServletConfig(UndertowDeploymentInfoService.java:656)
      	at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService.start(UndertowDeploymentInfoService.java:252)
      	at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
      	at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
      	... 3 more
      
      15:50:20,348 ERROR [org.jboss.as.controller.management-operation] (DeploymentScanner-threads - 1) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "ContextParamNullDemo.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./ContextParamNullDemo.UndertowDeploymentInfoService" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./ContextParamNullDemo.UndertowDeploymentInfoService: Failed to start service
          Caused by: java.lang.NullPointerException"}}
      

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              jaysensharma Jay SenSharma (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: