使用Apache CXF的Spring Webservices未部署在客户端服务器中(weblogic)

时间:2017-03-20 23:34:16

标签: spring web-services cxf jersey-2.0 weblogic12c

我正在为应用程序构建spring webservices。我正在使用apache cxf来创建webservices和maven来构建战争。我正在使用weblogic 12c在我的电脑上部署web服务。我使用“org.codehaus.jackson.jaxrs.JacksonJsonProvider”作为jsonProvider。代码部署在服务器运行的机器上,没有任何错误。但是,当我尝试在具有weblogic 12.2.1的客户端计算机中部署相同的代码时,部署失败并出现以下错误:

  

“Jersey”在Web应用程序启动时无法预加载:   “经纪人-ws.war”。

<[ACTIVE] ExecuteThread: '12' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1490020025257> <BEA-101216> <Servlet: "Jersey" failed to preload on startup in Web application: "broker-ws.war".
    at com.sun.jersey.spi.inject.Errors.processErrorMessages(Errors.java:170)
    at com.sun.jersey.spi.inject.Errors.postProcess(Errors.java:136)
    at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:199)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:795)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:790)
    at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:491)
    at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:321)
    at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605)
    at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207)
    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:376)
    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:559)
    at javax.servlet.GenericServlet.init(GenericServlet.java:240)
    at weblogic.jaxrs.server.portable.servlet.ServletContainer.init(ServletContainer.java:121)
    at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:337)
    at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:288)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
    at weblogic.servlet.internal.StubSecurityHelper.initServletInstance(StubSecurityHelper.java:98)
    at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:86)
    at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:71)
    at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:57)
    at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:31)
    at weblogic.servlet.internal.ServletStubImpl.initStubLifecycleHelper(ServletStubImpl.java:656)
    at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:600)
    at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1974)
    at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1951)
    at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1841)
    at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2871)
    at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1661)
    at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:823)
    at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:360)
    at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:356)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
    at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:138)
    at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)

我没有明确地在我的项目中的任何地方引用Jersey,但我正在使用jax-rs,它正在寻找Jersey。我机器中的weblogic服务器有泽西罐子,但客户端机器中的weblogic没有泽西罐子。我尝试将以下jar添加到 pom.xml

<!--  https://mvnrepository.com/artifact/org.glassfish.jersey.bundles/jaxrs-ri -->
     <dependency>
            <groupId>org.glassfish.jersey.bundles</groupId>
            <artifactId>jaxrs-ri</artifactId>
            <version>2.25.1</version>
        </dependency>   
        <dependency>
            <groupId>org.glassfish.hk2</groupId>
            <artifactId>hk2-api</artifactId>
            <version>2.5.0-b32</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.hk2</groupId>
            <artifactId>hk2-locator</artifactId>
            <version>2.5.0-b32</version>
        </dependency> 

        <dependency>
            <groupId>org.glassfish.hk2</groupId>
            <artifactId>hk2-utils</artifactId>
            <version>2.5.0-b32</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.hk2/hk2-inhabitant-generator -->
        <dependency>
            <groupId>org.glassfish.hk2</groupId>
            <artifactId>hk2-inhabitant-generator</artifactId>
            <version>2.5.0-b19</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.inject/javax.inject -->
        <!-- https://mvnrepository.com/artifact/org.apache.servicemix.bundles/org.apache.servicemix.bundles.javax-inject -->
        <dependency>
            <groupId>org.apache.servicemix.bundles</groupId>
            <artifactId>org.apache.servicemix.bundles.javax-inject</artifactId>
            <version>1_2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client -->
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <version>2.25.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.glassfish.jersey.bundles.repackaged/jersey-guava -->
        <dependency>
            <groupId>org.glassfish.jersey.bundles.repackaged</groupId>
            <artifactId>jersey-guava</artifactId>
            <version>2.25</version>
        </dependency>

然而,我无法在没有任何错误的情况下部署应用程序。我现在得到了一个不同的错误。

  

java.lang.IllegalStateException:没有提供生成器   没有默认的发电机注册

请在spring-config文件中找到我的jax-rs配置。

<jaxrs:server id="restService" address="/rest">
        <jaxrs:serviceBeans>
            <ref bean="userService" />
            <ref bean="billingService" />
        </jaxrs:serviceBeans>
        <jaxrs:providers>
            <ref bean='jsonProvider' />
        </jaxrs:providers>
        <jaxrs:inInterceptors>
            <bean class="com.brokerws.interceptor.WSLoggingRequestInterceptor" />
        </jaxrs:inInterceptors>
        <jaxrs:outInterceptors>
            <bean class="com.brokerws.interceptor.WSLoggingResponseInterceptor" />
        </jaxrs:outInterceptors>
    </jaxrs:server>

请在下面找到我的web.xml

    <?xml version="1.0" encoding="ISO-8859-1"?>
<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"
    metadata-complete="true" version="3.0">
    <display-name>SuppApp</display-name>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/app-beans.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</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>/services/*</url-pattern>
    </servlet-mapping>
    <servlet>
        <servlet-name>health-check</servlet-name>
        <servlet-class>com.suddenlink.util.HealthCheckServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>health-check</servlet-name>
        <url-pattern>/healthCheck</url-pattern>
    </servlet-mapping>

    <filter>
        <filter-name>Logback-MDC-Filter</filter-name>
        <filter-class>com.suddenlink.traceability.filter.HttpHeaderServletFilter</filter-class>
        <init-param>
            <param-name>application_name</param-name>
            <param-value>broker-ws</param-value>
        </init-param>
        <init-param>
            <param-name>application_type</param-name>
            <param-value>ws</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>Logback-MDC-Filter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

</web-app>

有人可以告诉我这里缺少什么。我尝试了通过互联网提供的各种解决方案,但没有任何对我有用。

1 个答案:

答案 0 :(得分:0)

终于找到了问题的根本原因。这是春季webapp版本,它使weblogic服务器寻找泽西依赖。我将webapp版本从3.0更改为2.5,错误消失了。希望这可以帮助那些将遇到这个问题的人,因为这需要将近两天的时间来确定实际发生的事情。