gpt4 book ai didi

java - Apache CXF Web 服务导致缺少依赖项错误

转载 作者:太空宇宙 更新时间:2023-11-04 13:53:46 27 4
gpt4 key购买 nike

我正在尝试使用 Apache CXF 创建 HelloWorld Web 服务。我可以在 Tomcat 上部署并运行它,但无法让它在 WebLogic 上运行。当我尝试运行它时,当 WebLogic 尝试部署 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>

我不确定为什么要引入 CXF REST 模块,我从未指定过它们。我的 web.xml 是:

<?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>

我的 cxf-servlet 是:

<?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>

我的 DefaultHelloWorld.java 文件是:

@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;
}
}

我尝试将这些模块添加到 pom 中,但这根本没有帮助。任何有关此问题的帮助将不胜感激。

最佳答案

出现此问题的原因是,如错误消息所述,缺少依赖项。对我来说,令人困惑的部分是它们在部署应用程序时丢失,而不是在构建应用程序时丢失。要解决 WebLogic 中这些类型的缺失依赖项问题,您需要将 jar 添加到部署中。在 WebLogic 中,这是通过将它们添加到 [WebContent]/WEB-INF/lib 目录来完成的。然后,WebLogic 将拾取它们并在部署期间包含它们。

请注意,如果您添加到此库的 jar 与 WebLogic 应用程序服务器附带的 jar 之间存在冲突,您可能需要向 weblogic-[application/web-app].xml 添加一些配置,告诉 WebLogic 优先选择应用程序库中的那些。您可以通过更新 container-descriptor 并将 prefer-web-inf-classes 值设置为 true(至少在 WebLogic 12c 中是这样)来完成此操作。

关于java - Apache CXF Web 服务导致缺少依赖项错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30038726/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com