如何在部署CXF Restful WebServices时避免与Spring相关的警告

时间:2016-07-07 06:13:24

标签: java spring web-services jboss

在将war文件部署到我的JBOSS服务器时,我面临一些与spring-beans.xsd相关的警告。

我的警告和我的beans.xml如下所述。任何人都可以帮我解决这个问题......

我的警告:

11:23:59,945 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015960:Class Path entry jaxb-api.jar in /C:/Desktop/jbdevstudio/runtimes
/jboss-eap/standalone/deployments/MyWebService.war/WEB-INF/lib/jaxb-impl-2.1.13.jar  does not point to a valid jar for a Class-Path reference.

11:24:21,564 WARN  [org.jboss.weld.deployer] (MSC service thread 1-4) JBAS016010: Warning while parsing vfs:/C:/Desktop/jbdevstudio/runtimes/jboss-eap/standalone/deployments/MyWebService.war/WEB-INF/beans.xml:12 schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans-4.1.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>.

我的Web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>SBPWebService</display-name>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/beans.xml</param-value>
  </context-param>
  <servlet>
    <servlet-name>CXFServlet</servlet-name>
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>CXFServlet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
  </servlet-mapping>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
</web-app>

我的beans.xml:

<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
    http://cxf.apache.org/jaxrs
    http://cxf.apache.org/schemas/jaxrs.xsd
    http://cxf.apache.org/jaxws
    http://cxf.apache.org/schemas/jaxws.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.1.xsd">
....
....
</beans>

我的pom.xml依赖项:

<dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>4.1.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.1.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.1.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>4.1.3.RELEASE</version>
        </dependency>
        <!-- Apache CXF Dependencies -->
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>2.7.13</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>2.7.13</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http-jetty</artifactId>
            <version>2.7.13</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
            <version>2.7.13</version>
        </dependency>
        <!-- Jackson The JSON Producer dependency -->
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-jaxrs</artifactId>
            <version>1.9.13</version>
        </dependency>

        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>3.2.2</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>

    </dependencies>

1 个答案:

答案 0 :(得分:1)

  

/ C:/ Desktop / jbdevstudio / runtimes中的类路径条目jaxb-api.jar   /jboss-eap/standalone/deployments/MyWebService.war/WEB-INF/lib/jaxb-impl-2.1.13.jar未指向类路径引用的有效jar。

您不需要将jaxb与您的应用程序捆绑在一起,因为它们自JDK1.6起已经是JDK / App服务器的一部分。从classpah中删除jaxb *

  

无法读取架构文档“http://www.springframework.org/schema/beans/spring-beans-4.1.xsd”,因为1)找不到该文档; 2)文件无法阅读; 3)文档的根元素不是。

系统无法读取指向的XSD。尝试使用无版本模式。在升级spring版本时,无版本应该也可以使用,这是推荐的用法。见Spring configuration XML schema: with or without version?

http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/beans/spring-beans.xsd

必要的模式可以在META-INF/spring.schemasspring-beans.jar找到并包含在jar中,因此不需要上网

http://www.springframework.org/schema/beans/spring-beans-4.1.xsd=org/springframework/beans/factory/xml/spring-beans-4.1.xsd
http://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-4.1.xsd