0

This is the content of my jboss file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN"
        "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
<jboss-web>
  <context-root>/</context-root>
  <resource-ref>
    <res-ref-name>value</res-ref-name>
    <jndi-name>value</jndi-name>
  </resource-ref>
  <resource-ref>
    <res-ref-name>value</res-ref-name>
    <jndi-name>value</jndi-name>
  </resource-ref>
  <resource-ref>
    <res-ref-name>value</res-ref-name>
    <jndi-name>value</jndi-name>
  </resource-ref>
  <servlet>
    <servlet-name>ActionServlet</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    <init-param>
      <param-name>config</param-name>
      <param-value>struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>debug</param-name>
      <param-value>5</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>5</param-value>
    </init-param>
    <init-param>
      <param-name>validate</param-name>
      <param-value>true</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>ActionServlet</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
</jboss-web>

I am receiving following error in eclipse

The content of element type "jboss-web" must match "(class-loading?,security-domain?,context-root?,virtual-host*,use-session-cookies?,replication-config?,resource-env-ref*,resource-ref*,security-role*,ejb-ref*,ejb-local-ref*,message-destination-ref*,message-destination*,webservice-description*,service-ref*,depends*,servlet*,authenticators*)".
jboss-web.xml   line 4  XML Problem

Please help.

5
  • What are the "other elements" ? That's probably where the error is. Eclipse is validating the xml file against the DTD referenced in the url above. The error message is saying that one of the direct children of <jboss-web> is none of those listed in the message Commented Dec 1, 2014 at 17:30
  • thank you for your response I have update the question.please let me know if anything else is required Commented Dec 1, 2014 at 17:46
  • R u using JBoss 4 ? u have added jboss-web_4_0.dtd in ur DOCTYPE. Is ur JBoss AS or EAP ? Commented Dec 1, 2014 at 18:20
  • Have a look at this jboss-web.xml validation error Commented Dec 1, 2014 at 18:28
  • @OO7 yeah we are still using jboss 4.2 Commented Dec 1, 2014 at 19:48

2 Answers 2

2

It looks like <servlet-mapping> does not belong there, as it is not part of the allowed children for <jboss-web>, as declared in the DTD.

As far as I know, <servlet-mapping> should be in the web.xml instead.

Sign up to request clarification or add additional context in comments.

1 Comment

even though I have moved the servlet-mapping to web.xml I can still see those error.
1

Lolo is correct, the <servlet-mapping/> tag should be in the the web.xml instead. The web.xml descriptor defines the web application independent of the deployment environment, while the jboss-web.xml descriptor is meant to map those configuration elements to its actual deployed environment. That is why it contains those <resource-ref/> elements to map a resource defined in the web.xml to a particular jndi name for instance.

Besides moving the <servlet-mapping/> element you should also move the <servlet/> element to the web.xml.

In case you still have issues you could have eclipse validate the web.xml for you. If configured properly you can even use auto-complete while editing the xml files, see http://eclipse.org/webtools/community/tutorials/XMLValidation/XMLValidationTutorial.html.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.