I inherited a CXF based project, with the following (relevant) original dependencies (in 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>
And
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.2.8-SNAPSHOT</version>
By "original" I mean that this is the source code snapshot I received that used to build fine years ago, has been dormant for all these years and now, that some modifications to the code are needed, it will no longer build as is.
The main problem with trying to build it "as is", is that the 2.2.8-SNAPSHOT
version of cxf-codegen-plugin
is nowhere to be found... Maven can't find it and fails the build.
So, I replaced the above with (note that the only differences is 2.2.8 vs. 2.2.8-SNAPSHOT)
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.2.8</version>
The build succeeds now past this point but fails on 2 symbols not found:
Password.set_value(String value)
-- from the packageorg.oasis_open.docs.wss._2004._01.oasis_200401_wss_wssecurity_secext_1_0
.SQLService.setENDPOINT(String sei)
from own package based onjavax.xml.ws.Service
.
Both source files for the classes Password
and SQLService
are generated on-the-fly by Apache CXF 2.2.8, as designed by the original author of this project.
So, I quickly examined the new generated versions of this files and discovered that:
Password.set_value(String value)
seems to have been substituted byPassword.setValue(String value)
.SQLService.setENDPOINT(String sei)
has been eliminated completely, and instead requiring that sei be passed in the constructor:SQLService(URL wsdlLocation, QName serviceName)
So I modified the source code that calls these methods to adapt to this 2 seemingly minor changes and the project now builds successfully!
But... it fails at runtime with the following exceptions:
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
Note: Even if I hardcode the actual (www) server URL in the WSDL (i.e. replacing http://localhost:8080
with https://test.rserver.com
), I get the ConnectException error displaying http://localhost:8080
as the destination. Clearly, some CXF-substitution or resolution is not performed. Could that be a clue to where the problem is? Which component of CXF is responsible for that magical transformation from http://localhost:8080
to the real URL?
Is it right where the stack trace hints (i.e. JaxWsClientProxy or frontend.ClientProxy or...)?
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)
If so, why is this happening and how do I fix this?
Now... if I were a CXF and/or JAX-WS expert, I would have probably figured out the root cause of that misleading "Connection refused" hint in the stack trace.
But at this point I am pretty much lost, since I know beyond certainty that the SEI is there, the authentication username/password are correct: The older binary (JAR with dependencies) runs just fine against this service.
I am therefore looking for a clue or an insight from an expert who may have seen this type of "Connection refused" stack trace and knows that it could be trigger by other than the typical reasons. For example, some type of mismatch that has been introduced once the cxf-codegen-plugin
2.2.8-SNAPSHOT was replaced by 2.2.8?
Or additional tips on how to troubleshoot this problem?