CXF 3.1.4 RS在Weblogic 12c中不起作用

时间:2018-08-06 14:30:13

标签: java weblogic cxf weblogic12c cxfrs

我有使用CXF开发的RESTFULL服务,它可以在Tomcat中完美运行,但不能在Weblogic中运行。

我对Weblogic并不熟悉,所以整整一天我都在搜索,现在以某种方式知道Weblogic没有使用打包在war文件中的jar。

我尝试了以下解决方案,但没有解决

CXF recomendation on JAX-RS : Deployment

CXF Nabble forum

下面是我的配置,

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>GenServiceV1.6</display-name>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/cxf.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>com.pointel.spws.services.InitListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>CXFServlet</servlet-name>
        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>CXFServlet</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

cxf.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:jaxrs="http://cxf.apache.org/jaxrs"
    xmlns:cxf="http://cxf.apache.org/core"
    xsi:schemaLocation="
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd">
    <jaxrs:server id="base" address="/Restful">

        <jaxrs:serviceBeans>
            <ref bean="GenService" />
        </jaxrs:TestService>

        <jaxrs:features>
            <cxf:logging />
        </jaxrs:features>
    </jaxrs:server>
    <bean id="TestService" class="com.abc.services.ServiceImpl" />

</beans>

异常(几行)

####<6 Aug, 2018, 12:22:06,360 PM IST> <Error> <HTTP> <PTLLTP008> <AdminServer> <[ACTIVE] ExecuteThread: '11' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <b2276e62-bf3f-4b42-80a7-cc63a3297980-00000028> <1533538326360> <[severity-value: 8] [rid: 0] [partition-id: 0] [partition-name: DOMAIN] > <BEA-101216> <Servlet: "JAX-RS/Jersey#1" failed to preload on startup in Web application: "GenServiceV1.9.war".
java.lang.NoClassDefFoundError: org/apache/abdera/model/Element
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.getDeclaredMethods(Class.java:1975)
    at org.glassfish.jersey.server.model.IntrospectionModeller$2.run(IntrospectionModeller.java:253)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.glassfish.jersey.server.model.IntrospectionModeller.getAllDeclaredMethods(IntrospectionModeller.java:247)
    at org.glassfish.jersey.server.model.IntrospectionModeller.checkForNonPublicMethodIssues(IntrospectionModeller.java:172)
    at org.glassfish.jersey.server.model.IntrospectionModeller.doCreateResourceBuilder(IntrospectionModeller.java:119)
    at org.glassfish.jersey.server.model.IntrospectionModeller.access$000(IntrospectionModeller.java:80)
    at org.glassfish.jersey.server.model.IntrospectionModeller$1.call(IntrospectionModeller.java:112)
    at org.glassfish.jersey.server.model.IntrospectionModeller$1.call(IntrospectionModeller.java:109)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)

在创建错误后创建WEB-INF / weblogic.xml

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
  <container-descriptor>
     <prefer-web-inf-classes>false</prefer-web-inf-classes>
    <prefer-application-packages>
      <package-name>javax.ws.rs.*</package-name>
    </prefer-application-packages>

    <prefer-application-resources>
      <resource-name>META-INF/services/*</resource-name>
    </prefer-application-resources>
  </container-descriptor>
</weblogic-web-app>

也尝试<prefer-web-inf-classes>true</prefer-web-inf-classes>遇到相同的错误。 任何帮助都将受到高度赞赏

0 个答案:

没有答案