实现JAX-WS,如果忘了jaxws-spring这个jar的奇怪现象

之前参考网上的例子,练习了下并完好在本地实现了一个演示,但是后来很长时间没搞了,昨天重新弄的时候发现了各种奇怪现象:

1. applicationContext.xml 在第一行的前面有个红叉叉,鼠标放上去说这个错:

Referenced file contains errors (http://jax-ws.dev.java.net/spring/servlet.xsd). For more information, right click on the message in the Problems View and select "Show Details..."
我用Maven能正确打包,但是部署到Tomcat就发生了下面的错误:

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

还出现了不能解压这个包的错误提示:

SEVERE: Exception fixing docBase for context [/spring_ws]
java.util.zip.ZipException: error in opening zip file
SEVERE: Error starting static Resources
java.lang.IllegalArgumentException: Invalid or unreadable WAR file : error in opening zip file

接下来 Tomcat 给出的信息让人摸不着头脑了:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 19 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'aop:config'.
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 27 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'wss:binding'.

网上搜了下,说http://jax-ws.dev.java.net/spring/servlet.xsd 地址不对的有之,说需要在applicationContext.xml 里加上 http://www.springframework.org/schema/aop/spring-context-3.0.xsd 的有之,说服务器自带的 XML Parser 和项目里的 XML Parser 有冲突的有之。

当然不能说他们的说法不对,正如网上一老兄说的:“generically this exception will be thrown for many reasons.” 

后来看到了  Schemas are located at the root of the jaxws-spring.jar file  并仔细查看自己的 Tomcat 的日志:

org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://jax-ws.dev.java.net/spring/servlet.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.

这才怀疑是不是自己的配置错了,一看 pom.xml 才知道我把 jaxws-spring 这个 dependency 给注释掉了:

<!-- 
	<dependency>
		<groupId>org.jvnet.jax-ws-commons.spring</groupId>
		<artifactId>jaxws-spring</artifactId>
		<version>1.8</version>
		<exclusions>
		  <exclusion>
           		<groupId>org.springframework</groupId>
      			<artifactId>spring-core</artifactId>
        	  </exclusion>
        	  <exclusion>
           		<groupId>org.springframework</groupId>
      			<artifactId>spring-context</artifactId>
        	  </exclusion>
        	  <exclusion>
           		<groupId>com.sun.xml.stream.buffer</groupId>
      			<artifactId>streambuffer</artifactId>
        	  </exclusion>
        	  <exclusion>
           		<groupId>org.jvnet.staxex</groupId>
      			<artifactId>stax-ex</artifactId>
        	  </exclusion>
		</exclusions>
	</dependency>
-->
把这个注释去掉,重新打包,tomcat 才正常解压。哎,耽误了一天的功夫,不知道当初为什么把注释掉了。惭愧!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值