简体   繁体   中英

Apache CXF Web Service leads to missing dependency errors

I am trying to create a HelloWorld web service using Apache CXF. I am able to deploy and run it on Tomcat, but I can't get it to work on WebLogic. When I try to run it, I get the following exceptions when WebLogic tries to deploy the war:

<May 4, 2015 2:22:45 PM EDT> <Error> <com.sun.jersey.spi.inject.Errors> <BEA-000000> <The following errors and warnings have been detected with resource and/or provider classes:
  SEVERE: Missing dependency for method public org.apache.cxf.rs.security.saml.sso.LogoutResponse org.apache.cxf.rs.security.saml.sso.LogoutService.logout(javax.ws.rs.core.Cookie,org.apache.cxf.security.SecurityContext) at parameter at index 1
  SEVERE: Method, public org.apache.cxf.rs.security.saml.sso.LogoutResponse org.apache.cxf.rs.security.saml.sso.LogoutService.logout(javax.ws.rs.core.Cookie,org.apache.cxf.security.SecurityContext), annotated with GET of resource, class org.apache.cxf.rs.security.saml.sso.LogoutService, is not recognized as valid resource method.
  SEVERE: Missing dependency for method public org.apache.cxf.rs.security.saml.sso.LogoutResponse org.apache.cxf.rs.security.saml.sso.LogoutService.postLogout(javax.ws.rs.core.Cookie,org.apache.cxf.security.SecurityContext) at parameter at index 1
  SEVERE: Method, public org.apache.cxf.rs.security.saml.sso.LogoutResponse org.apache.cxf.rs.security.saml.sso.LogoutService.postLogout(javax.ws.rs.core.Cookie,org.apache.cxf.security.SecurityContext), annotated with POST of resource, class org.apache.cxf.rs.security.saml.sso.LogoutService, is not recognized as valid resource method.
  SEVERE: Missing dependency for method public void org.apache.cxf.rs.security.saml.sso.AbstractRequestAssertionConsumerHandler.setMessageContext(org.apache.cxf.jaxrs.ext.MessageContext) at parameter at index 0> 

I'm not sure why the CXF REST modules are being pulled in, I never specified them. My web.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">
    <description>cxf</description>
    <display-name>cxf</display-name>
    <servlet>
        <description>Apache CXF Endpoint</description>
        <display-name>cxf</display-name>
        <servlet-name>cxf</servlet-name>
        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>cxf</servlet-name>
        <url-pattern>/example/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>60</session-timeout>
    </session-config>
    <context-param>
        <param-name>ContextConfigLocation</param-name>
        <param-value>WEB-INF/cxf-servlet.xml</param-value>
    </context-param>
</web-app>

My cxf-servlet is:

<?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:jaxws="http://cxf.apache.org/jaxws"
       xmlns:soap="http://cxf.apache.org/bindings/soap"
       xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

    <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
    <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>

    <cxf:bus>
        <cxf:inInterceptors>
            <ref bean="logInbound"/>
        </cxf:inInterceptors>
        <cxf:outInterceptors>
            <ref bean="logOutbound"/>
        </cxf:outInterceptors>
        <cxf:outFaultInterceptors>
            <ref bean="logOutbound"/>
        </cxf:outFaultInterceptors>
        <cxf:inFaultInterceptors>
            <ref bean="logInbound"/>
        </cxf:inFaultInterceptors>
    </cxf:bus>

    <jaxws:endpoint id="helloWorldService" implementor="org.temadison.example.DefaultHelloWorld" address="/HelloWorldService" />
</beans>

And my DefaultHelloWorld.java file is:

@WebService(endpointInterface = "example.HelloWorld", serviceName = "HelloWorld")
public class DefaultHelloWorld implements HelloWorld {
      public String sayHelloWorldFrom(String from) {
           String result = "Hello, world, from " + from;
           System.out.println(result);
           return result;
      }
}

I tried adding those modules to the pom, but that didn't help at all. Any help with this issue would be most appreciated.

The problem was happening because, as error messages stated, the dependencies were missing. The confusing part, to me, was that they were missing while deploying the app, not while building it. To get around these types of missing dependency issues in WebLogic, you need to add the jars to the deployment. In WebLogic, this is done by adding them to the [WebContent]/WEB-INF/lib directory. WebLogic will then pick them up and include them during the deploy.

Note that, if there are conflicts between the jars you have added to this lib and those that come with the WebLogic app server, you may need to add some configuration to your weblogic-[application/web-app].xml that tells WebLogic to prefer those in your application's lib. You do this by updating the container-descriptor and setting the prefer-web-inf-classes value to true (at least this is the case in WebLogic 12c).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM