0

I'm trying to set up DWR, direct web remoting, and they had me put in the web.xml this piece of code here,

<servlet>
  <display-name>DWR Servlet</display-name>
  <servlet-name>dwr-invoker</servlet-name>  
  <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
  <init-param>
     <param-name>debug</param-name>
     <param-value>true</param-value>
  </init-param>
</servlet>

<servlet-mapping>
  <servlet-name>dwr-invoker</servlet-name>
  <url-pattern>/dwr/*</url-pattern>
</servlet-mapping>

but I get the error the markup in the document following the root element must be well-formed, and it is at the servlet-mapping part. I tried putting the servlet mapping inside of servlet and it got rid of the error but the webpage http://localhost:8081/WebProject01/dwr/ still wouldn't come up. The dwr.xml didn't have any errors so that looked good. Is there another way to fix the error message? Thanks for your time.

Andrew
  • 117
  • 1
  • 2
  • 11
  • That fragment looks ok and it validates with the [3.0 spec schema definition](http://docs.oracle.com/cd/E24329_01/web.1211/e21049/web_xml.htm#CIHFAIDA). Make sure you have such a namespace definition and schema location in your `web.xml`, it would ahve warned you when you put `servlet-mapping` inside of `servlet`. Please post the whole web.xml for further help. – A4L Jun 12 '14 at 13:47
  • DWR Servlet dwr-invoker org.directwebremoting.servlet.DwrServlet debug true dwr-invoker /dwr/* – Andrew Jun 12 '14 at 14:01
  • thanks for the reply @A4L. I changed it to this, DWR Servlet dwr-invoker org.directwebremoting.servlet.DwrServlet debug true dwr-invoker /dwr/* and now there is a warning at the top – Andrew Jun 12 '14 at 14:03

1 Answers1

3
<?xml version="1.0" encoding="UTF-8"?>
<servlet>
    <display-name>DWR Servlet</display-name>
    <servlet-name>dwr-invoker</servlet-name>
    <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
    <init-param>
        <param-name>debug</param-name>
        <param-value>true</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>dwr-invoker</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
</servlet-mapping>

is not a valid web.xml (this is not even valid XML)

The root element of a web.xml is web-app. Please refer to the documentation to understand how a web deployment descriptor should look like and what it is for.

You could edit you web xml in this way:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
    id="WebApp_ID" version="3.0">
    <servlet>
        <display-name>DWR Servlet</display-name>
        <servlet-name>dwr-invoker</servlet-name>  
        <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
        </init-param>
    </servlet>

    <servlet-mapping>
        <servlet-name>dwr-invoker</servlet-name>
        <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>
</web-app>

version="3.0" must be support supported by your application server (for example tomcat 7.x) Otherwise pleas look for the corresponding declarations for the servlet spec your app-server implements, for example for 2.5

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" 
    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_2_5.xsd"
    version="2.5">
A4L
  • 17,353
  • 6
  • 49
  • 70