2014-12-01 29 views
0

此的jboss-web.xml中驗證錯誤是我的JBoss文件的在eclipse

<?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> 

我在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 

請幫忙收到以下錯誤的內容。

+0

什麼是「其他元素」?這可能是錯誤的地方。 Eclipse正在根據上述url中引用的DTD驗證xml文件。錯誤消息是說''的直接孩子之一是沒有在消息 – Lolo 2014-12-01 17:30:15

+0

列出的那些謝謝你的迴應我已經更新問題。請讓我知道是否需要其他任何東西 – Ashish 2014-12-01 17:46:14

+0

如果你使用JBoss 4'?你在'DOCTYPE'中添加了'jboss-web_4_0.dtd'。你是JBoss AS還是EAP? – OO7 2014-12-01 18:20:56

回答

1

它看起來像<servlet-mapping>不屬於那裏,因爲它不是在DTD中聲明的允許子女<jboss-web>的一部分。

據我所知,<servlet-mapping>應該在web.xml中。

+0

甚至儘管我已將servlet映射移至web.xml,但我仍然可以看到這些錯誤。 – Ashish 2014-12-01 19:42:55

0

Lolo是正確的,<servlet-mapping/>標記應位於web.xml而不是。 web.xml描述符定義獨立於部署環境的Web應用程序,而jboss-web.xml描述符則用於將這些配置元素映射到其實際部署的環境。 這就是爲什麼它包含那些<resource-ref/>元素來將web.xml中定義的資源映射到特定的jndi名稱。

除了移動<servlet-mapping/>元素,您還應該將<servlet/>元素移動到web.xml

如果你仍然有問題,你可以讓eclipse爲你驗證web.xml。如果配置正確,甚至可以在編輯xml文件時使用自動完成功能,請參閱http://eclipse.org/webtools/community/tutorials/XMLValidation/XMLValidationTutorial.html