我继承了一个基于 CXF 的项目,具有以下(相关)原始依赖项(在 中pom.xml
):
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.2.7</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.2.7</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>2.2.7</version>
</dependency>
和
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.2.8-SNAPSHOT</version>
通过“原始”,我的意思是这是我收到的源代码快照,它在几年前用于构建良好,这些年来一直处于休眠状态,现在,需要对代码进行一些修改,它将不再按原样构建。
尝试“按原样”构建它的主要问题是,找不到它的版本......2.2.8-SNAPSHOT
Maven找不到它并且构建失败。cxf-codegen-plugin
因此,我将上面的内容替换为(请注意,唯一的区别是 2.2.8 与 2.2.8-SNAPSHOT)
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.2.8</version>
现在构建成功超过了这一点,但在未找到 2 个符号时失败:
Password.set_value(String value)
- 从包org.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_secext_1_0
。SQLService.setENDPOINT(String sei)
来自基于javax.xml.ws.Service
.
Password
这两个类的源文件SQLService
都是由 Apache CXF 2.2.8 动态生成的,由该项目的原作者设计。
因此,我迅速检查了这些文件的新生成版本并发现:
Password.set_value(String value)
好像被替换了Password.setValue(String value)
。SQLService.setENDPOINT(String sei)
已完全消除,而是要求在构造函数中传递 sei:SQLService(URL wsdlLocation, QName serviceName)
所以我修改了调用这些方法的源代码以适应这两个看似微小的变化,现在项目构建成功!
但是......它在运行时失败,但有以下例外:
WARNING: Interceptor for {http://rservice.rorg.net/sql}SQLService#{http://rservice.rorg.net/sql}Get has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:487)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
at $Proxy38.get(Unknown Source)
...
Caused by: java.net.ConnectException: ConnectException invoking http://localhost:8080/rservice/services/SQLServiceSoap: Connection refused
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:522)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:2058)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2043)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:639)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
... 14 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:413)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:274)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:261)
at java.net.Socket.connect(Socket.java:556)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:403)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:521)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:246)
at sun.net.www.http.HttpClient.New(HttpClient.java:320)
at sun.net.www.http.HttpClient.New(HttpClient.java:337)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:996)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:948)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:873)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1040)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1955)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1907)
at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42)
at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1974)
... 17 more
04-Jan-2013 12:07:17 ERROR [SQLModule] Error running SQL module: Could not send Message.
javax.xml.ws.WebServiceException: Could not send Message.
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
at $Proxy38.get(Unknown Source)
at net.rorg.rservice.client.base.sql.SQLClientBase.get(SQLClientBase.java:306)
at net.rorg.rservice.client.module.sql.SQLModule.getBatch(SQLModule.java:149)
at net.rorg.rservice.client.module.sql.SQLModule.getAndProcessSQL(SQLModule.java:110)
at net.rorg.rservice.client.module.sql.SQLModule.run(SQLModule.java:280)
at net.rorg.rservice.client.RClient.exec(RClient.java:398)
at net.rorg.rservice.client.RClient.run(RClient.java:173)
at net.rorg.rservice.client.RClient.main(RClient.java:166)
Caused by:
java.net.ConnectException: ConnectException invoking http://localhost:8080/rservice/services/SQLServiceSoap: Connection refused
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:522)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:2058)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2043)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:639)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:487)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
... 8 more
Caused by:
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:413)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:274)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:261)
at java.net.Socket.connect(Socket.java:556)
at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:403)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:521)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:246)
at sun.net.www.http.HttpClient.New(HttpClient.java:320)
at sun.net.www.http.HttpClient.New(HttpClient.java:337)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:996)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:948)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:873)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1040)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1955)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1907)
at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:42)
at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1974)
... 17 more
注意:即使我在 WSDL 中对实际 (www) 服务器 URL 进行硬编码(即用 替换http://localhost:8080
)https://test.rserver.com
,我也会收到显示为目的地的ConnectException错误。http://localhost:8080
显然,没有执行某些 CXF 替换或解析。这可能是问题出在哪里的线索吗?CXF 的哪个组件负责从http://localhost:8080
URL 到真实 URL 的神奇转换?
堆栈跟踪提示的位置是否正确(即JaxWsClientProxy或frontend.ClientProxy或...)?
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:484)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:310)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:262)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
如果是这样,为什么会发生这种情况,我该如何解决?
现在...如果我是 CXF 和/或 JAX-WS 专家,我可能会找出堆栈跟踪中误导性的“连接被拒绝”提示的根本原因。
但在这一点上,我几乎迷失了,因为我非常确定 SEI 在那里,身份验证用户名/密码是正确的:较旧的二进制文件(带有依赖项的 JAR)在这个服务上运行得很好。
因此,我正在寻找可能已经看到这种类型的“连接被拒绝”堆栈跟踪并且知道它可能由典型原因之外的其他原因触发的专家的线索或见解。例如,一旦2.2.8-SNAPSHOT 被 2.2.8 替换,就会引入某种类型的不匹配?cxf-codegen-plugin
或有关如何解决此问题的其他提示?