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

StackOverflow https://stackoverflow.com/questions/21210444

  •  29-09-2022
  •  | 
  •  

سؤال

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.

هل كانت مفيدة؟

المحلول

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>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top