Tomcat无法解析web.xml,在提到的代码点没有错误

时间:2014-09-29 15:26:39

标签: java tomcat

我使用Jersey作为我的Web服务,这就是我的web.xml的样子:

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
    <servlet>
        <servlet-name>jersey</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>

        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-name>com.rohanprabhu.external.interfaces.service.web</param-name>
        </init-param>**

        <init-param>
            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
            <param-name>true</param-name>
        </init-param>

        <load-on-startup>5</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>jersey</servlet-name>
        <url-pattern>*</url-pattern>
    </servlet-mapping>
</web-app>

我收到错误Occurred at line 10 column 22,这是我在文件中标记为&#39; **&#39; (它实际上并不在文件中,我只是把它放在这里)。这是我得到的堆栈跟踪(的一部分):

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.lang.IllegalArgumentException: Can't convert argument: null
    at org.apache.tomcat.util.IntrospectionUtils.convert(IntrospectionUtils.java:889)
    at org.apache.tomcat.util.digester.CallMethodRule.end(CallMethodRule.java:476)
    at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1057)
    ... 188 more
Occurred at line 10 column 22
Marking this application unavailable due to previous error(s)

以下是整个堆栈跟踪,如果有帮助:http://pastebin.com/EX4bMGex

2 个答案:

答案 0 :(得分:3)

我同意错误消息不是最理想的,但我也确定您需要<param-name><param-value><init-param>个{{1}}。 : - )

答案 1 :(得分:1)

您正在使用<param-name>两次。但其他init属性应为<param-value>