標題中的報錯是在寫一個webservices例子時候報的錯誤,我直接訪問http://localhost:8080/ibatisSpringDemo/ws/testWS?wsdl 後 tomcat中總是報那個錯誤,後來發現原因原來是,web.xml配置文件的問題,啓動tomcat容器後沒有加載spring的application.xml文件,也就不會加載spring cxf的三個配置,<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
tomcat正常啓動後控制檯應該打印出這三個文件的加載信息,如果未加載說明,application.xml未正確加載。
我的application.xml文件放到了src目錄下,如下是錯誤寫法:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationcontext*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
如下是正確寫法:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:*/applicationcontext*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>