org.jboss.as.server.deployment.DeploymentUnitProcessingException:在 ws 端点部署中检测到 Apache CXF 库

org.jboss.as.server.deployment.DeploymentUnitProcessingException: Apache CXF library detected in ws endpoint deployment

我正在使用 Eclipse Juno 和 WildFly 8.2 并尝试使用 ws-security 部署 soap web 服务。这是我的参考站点。

https://docs.jboss.org/author/display/JBWS/WS-Security#WS-Security-Authenticationandauthorization

部署正常!但问题似乎是 Eclipse 的客户端。我用 eclipse ide

做了一些 jsp 代码
<%@ page import="javax.xml.ws.BindingProvider"%>

<%@ page import="javax.xml.namespace.QName"%>
<%@ page import="java.net.URL"%>
<%@ page import="javax.xml.ws.Service"%>

<%@ page import="org.apache.cxf.ws.security.SecurityConstants"%> 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>WildFly SOAP Security test</title>
</head>
<body>
<% 
String SERVICE_URL = "http://localhost:8080/SOAPSecureWeb/HelloWorld";

try {
 QName serviceName = new QName("http://soap.aaa.com/", "HelloWorldService");

URL wsdlURL;
 wsdlURL = new URL(SERVICE_URL + "?wsdl");
 Service service = Service.create(wsdlURL, serviceName);
 IHelloWorld port = (IHelloWorld) service.getPort(IHelloWorld.class);

以上代码抛出简单的异常,

An error occurred at line: 12 in the generated java file : Only a type can be imported. org.apache.cxf.ws.security.SecurityConstants resolves to a package

所以我把cxf-rt-ws-security-2.7.13.jar复制到/WEBContent/WEB-INF/lib,然后抛出这个异常,甚至部署失败。

Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS015599: Apache CXF library (cxf-rt-ws-security-2.7.13.jar) detected in ws endpoint deployment; either provide a proper deployment replacing embedded libraries with container module dependencies or disable the webservices subsystem for the current deployment adding a proper jboss-deployment-structure.xml descriptor to it. The former approach is recommended, as the latter approach causes most of the webservices Java EE and any JBossWS specific functionality to be disabled.

我用谷歌搜索了一些类似的问题。

Failed to process phase PARSE of deployment

WSDL based webservices on Wildfly

我在哪里可以找到一些有用的答案?

我在使用带有 wildfly8.2 和 wildfly8.1 的 CXF 时遇到了同样的问题。 基本上 wildfly 服务器有自己的 CXF jars ,默认情况下会在您启动服务器时加载。

如果您使用 maven 项目,则添加范围为“provided”的以下依赖项

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-frontend-jaxws</artifactId>
    <version>${cxf.version}</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http</artifactId>
    <version>${cxf.version}</version>
    <scope>provided</scope>
</dependency>
    <!-- Jetty is needed if you're are not using the CXFServlet -->
<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http-jetty</artifactId>
    <version>${cxf.version}</version>
    <scope>provided</scope>
</dependency>

因此它不会在您的开发工作区中给您任何错误,jar 将添加到 class eclipse 路径,但它不会将 cxf jar 添加到您的 .war 文件。

如果是 Ant 项目,请将 jar 作为外部 jar 添加到 class 路径,但不要将 jar 放入 lib 文件夹。

如果您将 jar 放入 lib 文件夹,请编写 ant 代码以排除 .war 文件的 jar。

希望对您有所帮助。