Question

I'm trying to assign a controller to a URL and my descriptor is:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <servlet-mapping>
        <servlet-name>application</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

It throws the following error:

java.lang.RuntimeException: There is no web component by the name of application here.

Was it helpful?

Solution

As the error message is telling you, there's no such component found. You should add a servlet description with the class of your controller, like:

<servlet>
    <servlet-name>application</servlet-name>
    <servlet-class>my.package.MyController</servlet-class>
</servlet>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top