0
votes

I have developed a simple application in GWT. After that, I generate war file and deploy it into JBoss. However, when I do this, I get an error message like:

The content of element type "web-app" must match "(icon?,display-name?,description?,distributable?,context-param*,filter*,filter- mapping*,listener*,servlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,resource-env-ref*,resource- ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-ref*,ejb-local-ref*)".

On the other hand, my web.xml is the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/resources/spring.xml</param-value>
</context-param>

<!-- Servlets -->
<servlet>
  <servlet-name>greetServlet</servlet-name>
   <servlet-class>main.java.com.gwt.app.server.GreetingServiceImpl</servlet-class>
 </servlet>

<servlet-mapping>
    <servlet-name>greetServlet</servlet-name>
     <url-pattern>/zb_app/greet</url-pattern>
</servlet-mapping>

 <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-    class>
</listener>

 <!-- Default page to serve -->
 <welcome-file-list>
    <welcome-file>ZB_app.html</welcome-file>
 </welcome-file-list>

</web-app>

It is to say, the web-app tag contains some mandatory tags. I do not what is the problem, could someone help me with the problem?

Thank you in advance!

Regards!

2

2 Answers

1
votes

Try to put the listener declaration before the servlets, the order of the elements shouldn't be a problem but I've seen this in some container (don't remeber if it was JBoss)


<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- Servlets -->
<servlet>  
<servlet-name>greetServlet</servlet-name>   
<servlet-class>main.java.com.gwt.app.server.GreetingServiceImpl</servlet-class> </servlet>

<servlet-mapping>    
<servlet-name>greetServlet</servlet-name>     
<url-pattern>/zb_app/greet</url-pattern>
</servlet-mapping> 
1
votes

The sequence should be context-param - listener - servlet and here it is

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/resources/spring.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>greetServlet</servlet-name>
        <servlet-class>main.java.com.gwt.app.server.GreetingServiceImpl</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>greetServlet</servlet-name>
        <url-pattern>/zb_app/greet</url-pattern>
    </servlet-mapping>
   <welcome-file-list>
        <welcome-file>ZB_app.html</welcome-file>
    </welcome-file-list>

</web-app>