You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Stephane Allegro (JIRA)" <ji...@apache.org> on 2009/12/16 18:08:18 UTC

[jira] Created: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory

Already connected exception when using a proxy created with JAXRSClientFactory
------------------------------------------------------------------------------

                 Key: CXF-2585
                 URL: https://issues.apache.org/jira/browse/CXF-2585
             Project: CXF
          Issue Type: Bug
          Components: JAX-RS
    Affects Versions: 2.2.5
         Environment: JDK 1.5.0.18

            Reporter: Stephane Allegro


I'm trying to get a very simple Rest client working, but I always got this exception:

java.lang.IllegalStateException: Already connected
	at java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:100)
	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1885)
	at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1976)
	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
	at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
	at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
	at $Proxy16.doSomething(Unknown Source)
	at com.francetelecom.resttest.RestTest.main(RestTest.java:27)

Here is my jax-rs interface:

@Path("/")
public interface RestWS {
    @POST
    @Path("/test")
    public String doSomething( @QueryParam("param") String paramName);
}

And here the way my client uses it:

RestWS proxy = JAXRSClientFactory.create("http://localhost:8080/RestWSMock",RestWS.class);
proxy.doSomething("bob");

I can not get it simpler. Any idea what's wrong ?
regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12792002#action_12792002 ] 

Sergey Beryozkin commented on CXF-2585:
---------------------------------------

Hi,

here is the code for a custom interceptor :

public class EmptyPostOutInterceptor extends AbstractPhaseInterceptor<Message> {
                
        public EmptyPostOutInterceptor() {
             super(Phase.PRE_MARSHAL);
            
        } 

        public void handleMessage(Message message) throws Fault {
            if ("POST".equals(message.get(Message.HTTP_REQUEST_METHOD))) {
                message.put("org.apache.cxf.post.empty", true);
            }
        }
    }

you can register it from Spring like this, assuming you use jaxrs:client :

<jaxrs:client>
<jaxrs:outInterceptors>
   <bean class="org.custom.EmptyPostOutInterceptor"/>
</jaxrs:outInterceptors>
</jaxrs:client>


Here is a Java code :

@Test
    public void testEmptyPostProxy() throws Exception {
        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); 
        bean.setAddress("http://localhost:9080");
        bean.setResourceClass(BookStore.class);
        bean.getOutInterceptors().add(new EmptyPostOutInterceptor());
        BookStore store = bean.create(BookStore.class);
        store.emptypost();
        assertEquals(204, WebClient.client(store).getResponse().getStatus());
    }

give it a try please and let me know how it goes. 
It is really a temp measure, the fix will be in 2.2.6 (to be released possibly in Jan)

> Already connected exception when using a proxy created with JAXRSClientFactory
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2585
>                 URL: https://issues.apache.org/jira/browse/CXF-2585
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.2.5
>         Environment: JDK 1.5.0.18
>            Reporter: S.Allegro
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2.6, 2.3
>
>
> I'm trying to get a very simple Rest client working, but I always got this exception:
> java.lang.IllegalStateException: Already connected
> 	at java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:100)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1885)
> 	at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1976)
> 	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
> 	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
> 	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
> 	at $Proxy16.doSomething(Unknown Source)
> 	at com.francetelecom.resttest.RestTest.main(RestTest.java:27)
> Here is my jax-rs interface:
> @Path("/")
> public interface RestWS {
>     @POST
>     @Path("/test")
>     public String doSomething( @QueryParam("param") String paramName);
> }
> And here the way my client uses it:
> RestWS proxy = JAXRSClientFactory.create("http://localhost:8080/RestWSMock",RestWS.class);
> proxy.doSomething("bob");
> I can not get it simpler. Any idea what's wrong ?
> regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sergey Beryozkin updated CXF-2585:
----------------------------------

    Fix Version/s: 2.3
                   2.2.6
         Assignee: Sergey Beryozkin

> Already connected exception when using a proxy created with JAXRSClientFactory
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2585
>                 URL: https://issues.apache.org/jira/browse/CXF-2585
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.2.5
>         Environment: JDK 1.5.0.18
>            Reporter: Stephane Allegro
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2.6, 2.3
>
>
> I'm trying to get a very simple Rest client working, but I always got this exception:
> java.lang.IllegalStateException: Already connected
> 	at java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:100)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1885)
> 	at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1976)
> 	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
> 	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
> 	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
> 	at $Proxy16.doSomething(Unknown Source)
> 	at com.francetelecom.resttest.RestTest.main(RestTest.java:27)
> Here is my jax-rs interface:
> @Path("/")
> public interface RestWS {
>     @POST
>     @Path("/test")
>     public String doSomething( @QueryParam("param") String paramName);
> }
> And here the way my client uses it:
> RestWS proxy = JAXRSClientFactory.create("http://localhost:8080/RestWSMock",RestWS.class);
> proxy.doSomething("bob");
> I can not get it simpler. Any idea what's wrong ?
> regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12793579#action_12793579 ] 

Sergey Beryozkin commented on CXF-2585:
---------------------------------------

Hi,

@Path("/webform.html?cmd=execute")

identifies the value for the uri path component, so '?' and '=' have to be encoded. JAXRS does not provide for embedding query values inside a @Path annotation

How is the service endpoint written ? Is it a 3rd-party endpoint or is it yourself who wrote it ? If yes then may be that service endpoint can be updated to default to "execute" if no "cmd" query is provided ?

Another option to try is to change your method signature like this :

String createCustomer(@QueryParam("") QueryBean bean);

public class QueryBean {
    private String cmd = "execute";
    private String workflow;

    public QueryBean() {
         this("defaultWorkflowValue")
    }
    public QueryBean(String workflow) { 
         this.workflow = workflow;
    }

    public void setCmd(String value) {
        cmd = value;
    }
    public String getCmd() {
        return cmd;
    }

    public void setWorkflow(String value) {
        workflow = value;
    }
    public String getWorkflow() {
        return workflow;
    }
}

and then

proxy.createCustomer(new QueryBean("SomeWorkflowValue"));

This option is good in that you can add a support for new queries by updating the query bean and the service implementation but without changing the signature

Finally, you can try to do

@Path("/webform.html")
public String createCustomer(@QueryParam("workflow") String workflow);

But then update Message.REQUEST_URI value on the current message in the CXF out interceptor, by appending "&cmd=execute" to it

hope it helps, Sergey

 

> Already connected exception when using a proxy created with JAXRSClientFactory
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2585
>                 URL: https://issues.apache.org/jira/browse/CXF-2585
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.2.5
>         Environment: JDK 1.5.0.18
>            Reporter: S.Allegro
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2.6, 2.3
>
>
> I'm trying to get a very simple Rest client working, but I always got this exception:
> java.lang.IllegalStateException: Already connected
> 	at java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:100)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1885)
> 	at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1976)
> 	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
> 	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
> 	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
> 	at $Proxy16.doSomething(Unknown Source)
> 	at com.francetelecom.resttest.RestTest.main(RestTest.java:27)
> Here is my jax-rs interface:
> @Path("/")
> public interface RestWS {
>     @POST
>     @Path("/test")
>     public String doSomething( @QueryParam("param") String paramName);
> }
> And here the way my client uses it:
> RestWS proxy = JAXRSClientFactory.create("http://localhost:8080/RestWSMock",RestWS.class);
> proxy.doSomething("bob");
> I can not get it simpler. Any idea what's wrong ?
> regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory

Posted by "S.Allegro (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12792466#action_12792466 ] 

S.Allegro commented on CXF-2585:
--------------------------------

Hello, 

Using your Interceptor code, I got now this exception:

18 déc. 2009 18:05:25 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
ATTENTION: Interceptor 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:236)
at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
at $Proxy74.createCustomer(Unknown Source)
...

Caused by: java.io.IOException: Introuvable
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2109)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2057)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1982)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessageMessageSenderInterceptor.java:62)

... 45 more

 

Any Idea ?
Thanks for your help.



> Already connected exception when using a proxy created with JAXRSClientFactory
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2585
>                 URL: https://issues.apache.org/jira/browse/CXF-2585
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.2.5
>         Environment: JDK 1.5.0.18
>            Reporter: S.Allegro
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2.6, 2.3
>
>
> I'm trying to get a very simple Rest client working, but I always got this exception:
> java.lang.IllegalStateException: Already connected
> 	at java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:100)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1885)
> 	at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1976)
> 	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
> 	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
> 	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
> 	at $Proxy16.doSomething(Unknown Source)
> 	at com.francetelecom.resttest.RestTest.main(RestTest.java:27)
> Here is my jax-rs interface:
> @Path("/")
> public interface RestWS {
>     @POST
>     @Path("/test")
>     public String doSomething( @QueryParam("param") String paramName);
> }
> And here the way my client uses it:
> RestWS proxy = JAXRSClientFactory.create("http://localhost:8080/RestWSMock",RestWS.class);
> proxy.doSomething("bob");
> I can not get it simpler. Any idea what's wrong ?
> regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory

Posted by "Stephane Allegro (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12791919#action_12791919 ] 

Stephane Allegro commented on CXF-2585:
---------------------------------------

Thank's for your quick answer
I prefer the 2nd workaround, and I will enjoy some code for the interceptor.
(PS: in fact, I setup my proxy using Spring, not JAXRSClientFactory directly)

Stéphane

-----Message d'origine-----
De : Sergey Beryozkin (JIRA) [mailto:jira@apache.org] 
Envoyé : mercredi 16 décembre 2009 21:50
À : ALLEGRO Stephane RD-BIZZ-ISS
Objet : [jira] Commented: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory


    [ https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12791576#action_12791576 ] 

Sergey Beryozkin commented on CXF-2585:
---------------------------------------

it is a bug affecting a proxy based flavor only. 
The problem is that a proxy does not indicate to the transport-level HttpConduit that an empty POST (with no request body) is coming which is something that never occurs with SOAP proxies.

It will be fixed for soon to be released 2.2.6

Couple of workarounds.
1. Use WebClient :

Response r = WebClient.create(endpointAddress).query("param", "bob").post(null); String s = (String)r.getEntity();

2. If you do prefer to use a proxy then for the empty POST be processed correctly, you can temporarily register a CXF out interceptor with a proxy and set a "org.apache.cxf.post.empty" property on a message - let me know please if you'd like to try this option and I will post a code for the interceptor

thanks


--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.



> Already connected exception when using a proxy created with JAXRSClientFactory
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2585
>                 URL: https://issues.apache.org/jira/browse/CXF-2585
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.2.5
>         Environment: JDK 1.5.0.18
>            Reporter: Stephane Allegro
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2.6, 2.3
>
>
> I'm trying to get a very simple Rest client working, but I always got this exception:
> java.lang.IllegalStateException: Already connected
> 	at java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:100)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1885)
> 	at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1976)
> 	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
> 	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
> 	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
> 	at $Proxy16.doSomething(Unknown Source)
> 	at com.francetelecom.resttest.RestTest.main(RestTest.java:27)
> Here is my jax-rs interface:
> @Path("/")
> public interface RestWS {
>     @POST
>     @Path("/test")
>     public String doSomething( @QueryParam("param") String paramName);
> }
> And here the way my client uses it:
> RestWS proxy = JAXRSClientFactory.create("http://localhost:8080/RestWSMock",RestWS.class);
> proxy.doSomething("bob");
> I can not get it simpler. Any idea what's wrong ?
> regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory

Posted by "S.Allegro (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12793261#action_12793261 ] 

S.Allegro commented on CXF-2585:
--------------------------------

Hello,
Sorry, you're completly right.
I was using this annotation
@Path("/webform.html?cmd=execute&workflow=createAccount") for a method.
And CXF did escape "?" and "&" characters and that's why my endpoint was
not responding.
BTW, is there a way to force a queryparam (that always has the same
value, like the "cmd=execute" above) for a method, such as it is not a
customizable parameter of this method ?
Thanks
 


> Already connected exception when using a proxy created with JAXRSClientFactory
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2585
>                 URL: https://issues.apache.org/jira/browse/CXF-2585
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.2.5
>         Environment: JDK 1.5.0.18
>            Reporter: S.Allegro
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2.6, 2.3
>
>
> I'm trying to get a very simple Rest client working, but I always got this exception:
> java.lang.IllegalStateException: Already connected
> 	at java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:100)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1885)
> 	at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1976)
> 	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
> 	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
> 	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
> 	at $Proxy16.doSomething(Unknown Source)
> 	at com.francetelecom.resttest.RestTest.main(RestTest.java:27)
> Here is my jax-rs interface:
> @Path("/")
> public interface RestWS {
>     @POST
>     @Path("/test")
>     public String doSomething( @QueryParam("param") String paramName);
> }
> And here the way my client uses it:
> RestWS proxy = JAXRSClientFactory.create("http://localhost:8080/RestWSMock",RestWS.class);
> proxy.doSomething("bob");
> I can not get it simpler. Any idea what's wrong ?
> regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory

Posted by "S.Allegro (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12791919#action_12791919 ] 

S.Allegro edited comment on CXF-2585 at 12/17/09 1:32 PM:
----------------------------------------------------------

Thank's for your quick answer
I prefer the 2nd workaround, and I will enjoy some code for the interceptor.
(PS: in fact, I setup my proxy using Spring, not JAXRSClientFactory directly)


      was (Author: sallegro):
    Thank's for your quick answer
I prefer the 2nd workaround, and I will enjoy some code for the interceptor.
(PS: in fact, I setup my proxy using Spring, not JAXRSClientFactory directly)

Stéphane

-----Message d'origine-----
De : Sergey Beryozkin (JIRA) [mailto:jira@apache.org] 
Envoyé : mercredi 16 décembre 2009 21:50
À : ALLEGRO Stephane RD-BIZZ-ISS
Objet : [jira] Commented: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory


    [ https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12791576#action_12791576 ] 

Sergey Beryozkin commented on CXF-2585:
---------------------------------------

it is a bug affecting a proxy based flavor only. 
The problem is that a proxy does not indicate to the transport-level HttpConduit that an empty POST (with no request body) is coming which is something that never occurs with SOAP proxies.

It will be fixed for soon to be released 2.2.6

Couple of workarounds.
1. Use WebClient :

Response r = WebClient.create(endpointAddress).query("param", "bob").post(null); String s = (String)r.getEntity();

2. If you do prefer to use a proxy then for the empty POST be processed correctly, you can temporarily register a CXF out interceptor with a proxy and set a "org.apache.cxf.post.empty" property on a message - let me know please if you'd like to try this option and I will post a code for the interceptor

thanks


--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


  
> Already connected exception when using a proxy created with JAXRSClientFactory
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2585
>                 URL: https://issues.apache.org/jira/browse/CXF-2585
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.2.5
>         Environment: JDK 1.5.0.18
>            Reporter: S.Allegro
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2.6, 2.3
>
>
> I'm trying to get a very simple Rest client working, but I always got this exception:
> java.lang.IllegalStateException: Already connected
> 	at java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:100)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1885)
> 	at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1976)
> 	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
> 	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
> 	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
> 	at $Proxy16.doSomething(Unknown Source)
> 	at com.francetelecom.resttest.RestTest.main(RestTest.java:27)
> Here is my jax-rs interface:
> @Path("/")
> public interface RestWS {
>     @POST
>     @Path("/test")
>     public String doSomething( @QueryParam("param") String paramName);
> }
> And here the way my client uses it:
> RestWS proxy = JAXRSClientFactory.create("http://localhost:8080/RestWSMock",RestWS.class);
> proxy.doSomething("bob");
> I can not get it simpler. Any idea what's wrong ?
> regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory

Posted by "S.Allegro (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12793553#action_12793553 ] 

S.Allegro commented on CXF-2585:
--------------------------------

Hi,
Yes, that's what I meant: Having "cmd=execute" by default, without having to put it in the signature.
I tried something like this:
@Path("/")
@Produces("application/xml")
public interface FlexibleHostingService {
    @POST
    @Path("/webform.html?cmd=execute")
    public String createCustomer(@QueryParam("workflow") String workflow);
}

But this proxy escaped '?' and '=', thus posting to a non-existing endpoint.
 
Regards,
Stéphane



> Already connected exception when using a proxy created with JAXRSClientFactory
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2585
>                 URL: https://issues.apache.org/jira/browse/CXF-2585
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.2.5
>         Environment: JDK 1.5.0.18
>            Reporter: S.Allegro
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2.6, 2.3
>
>
> I'm trying to get a very simple Rest client working, but I always got this exception:
> java.lang.IllegalStateException: Already connected
> 	at java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:100)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1885)
> 	at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1976)
> 	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
> 	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
> 	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
> 	at $Proxy16.doSomething(Unknown Source)
> 	at com.francetelecom.resttest.RestTest.main(RestTest.java:27)
> Here is my jax-rs interface:
> @Path("/")
> public interface RestWS {
>     @POST
>     @Path("/test")
>     public String doSomething( @QueryParam("param") String paramName);
> }
> And here the way my client uses it:
> RestWS proxy = JAXRSClientFactory.create("http://localhost:8080/RestWSMock",RestWS.class);
> proxy.doSomething("bob");
> I can not get it simpler. Any idea what's wrong ?
> regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12791576#action_12791576 ] 

Sergey Beryozkin commented on CXF-2585:
---------------------------------------

it is a bug affecting a proxy based flavor only. 
The problem is that a proxy does not indicate to the transport-level HttpConduit that an empty POST (with no request body) is coming which is something that never occurs with SOAP proxies.

It will be fixed for soon to be released 2.2.6

Couple of workarounds.
1. Use WebClient :

Response r = WebClient.create(endpointAddress).query("param", "bob").post(null);
String s = (String)r.getEntity();

2. If you do prefer to use a proxy then for the empty POST be processed correctly, you can temporarily register a CXF out interceptor
with a proxy and set a "org.apache.cxf.post.empty" property on a message - let me know please if you'd like to try this option and I will post a code for the interceptor

thanks

> Already connected exception when using a proxy created with JAXRSClientFactory
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2585
>                 URL: https://issues.apache.org/jira/browse/CXF-2585
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.2.5
>         Environment: JDK 1.5.0.18
>            Reporter: Stephane Allegro
>             Fix For: 2.2.6, 2.3
>
>
> I'm trying to get a very simple Rest client working, but I always got this exception:
> java.lang.IllegalStateException: Already connected
> 	at java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:100)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1885)
> 	at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1976)
> 	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
> 	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
> 	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
> 	at $Proxy16.doSomething(Unknown Source)
> 	at com.francetelecom.resttest.RestTest.main(RestTest.java:27)
> Here is my jax-rs interface:
> @Path("/")
> public interface RestWS {
>     @POST
>     @Path("/test")
>     public String doSomething( @QueryParam("param") String paramName);
> }
> And here the way my client uses it:
> RestWS proxy = JAXRSClientFactory.create("http://localhost:8080/RestWSMock",RestWS.class);
> proxy.doSomething("bob");
> I can not get it simpler. Any idea what's wrong ?
> regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12793284#action_12793284 ] 

Sergey Beryozkin commented on CXF-2585:
---------------------------------------

Hi,

do you mean making it such that a proxy adds this 

'cmd=execute' pair by default ?

It is not really possible with the proxy based api ? Or may be I've misunderstood the question ? What exactly you'd like to see happening ?

Perhaps the interface can be updated such that this Query param is not even in the signature ?

cheers, Sergey

> Already connected exception when using a proxy created with JAXRSClientFactory
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2585
>                 URL: https://issues.apache.org/jira/browse/CXF-2585
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.2.5
>         Environment: JDK 1.5.0.18
>            Reporter: S.Allegro
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2.6, 2.3
>
>
> I'm trying to get a very simple Rest client working, but I always got this exception:
> java.lang.IllegalStateException: Already connected
> 	at java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:100)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1885)
> 	at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1976)
> 	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
> 	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
> 	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
> 	at $Proxy16.doSomething(Unknown Source)
> 	at com.francetelecom.resttest.RestTest.main(RestTest.java:27)
> Here is my jax-rs interface:
> @Path("/")
> public interface RestWS {
>     @POST
>     @Path("/test")
>     public String doSomething( @QueryParam("param") String paramName);
> }
> And here the way my client uses it:
> RestWS proxy = JAXRSClientFactory.create("http://localhost:8080/RestWSMock",RestWS.class);
> proxy.doSomething("bob");
> I can not get it simpler. Any idea what's wrong ?
> regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12792472#action_12792472 ] 

Sergey Beryozkin commented on CXF-2585:
---------------------------------------

Perhaps the remote endpoint is now returns an error or not responding ?

Can you capture please what happens on the wire ?

Suppose an enpoint is listening on somehost:8080, you can use a tool like http://www.pocketsoap.com/tcptrace/ (Windows) or similar, tell it to listen on localhost:8081 and redirect to somehost:8080 and then create a client using a 8081 port...

cheers, Sergey


> Already connected exception when using a proxy created with JAXRSClientFactory
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2585
>                 URL: https://issues.apache.org/jira/browse/CXF-2585
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.2.5
>         Environment: JDK 1.5.0.18
>            Reporter: S.Allegro
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2.6, 2.3
>
>
> I'm trying to get a very simple Rest client working, but I always got this exception:
> java.lang.IllegalStateException: Already connected
> 	at java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:100)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1885)
> 	at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1976)
> 	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
> 	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
> 	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
> 	at $Proxy16.doSomething(Unknown Source)
> 	at com.francetelecom.resttest.RestTest.main(RestTest.java:27)
> Here is my jax-rs interface:
> @Path("/")
> public interface RestWS {
>     @POST
>     @Path("/test")
>     public String doSomething( @QueryParam("param") String paramName);
> }
> And here the way my client uses it:
> RestWS proxy = JAXRSClientFactory.create("http://localhost:8080/RestWSMock",RestWS.class);
> proxy.doSomething("bob");
> I can not get it simpler. Any idea what's wrong ?
> regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (CXF-2585) Already connected exception when using a proxy created with JAXRSClientFactory

Posted by "Sergey Beryozkin (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CXF-2585?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sergey Beryozkin resolved CXF-2585.
-----------------------------------

    Resolution: Fixed

> Already connected exception when using a proxy created with JAXRSClientFactory
> ------------------------------------------------------------------------------
>
>                 Key: CXF-2585
>                 URL: https://issues.apache.org/jira/browse/CXF-2585
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.2.5
>         Environment: JDK 1.5.0.18
>            Reporter: S.Allegro
>            Assignee: Sergey Beryozkin
>             Fix For: 2.2.6, 2.3
>
>
> I'm trying to get a very simple Rest client working, but I always got this exception:
> java.lang.IllegalStateException: Already connected
> 	at java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.java:100)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotReached(HTTPConduit.java:1885)
> 	at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:99)
> 	at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1976)
> 	at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
> 	at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:637)
> 	at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
> 	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:429)
> 	at org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:166)
> 	at $Proxy16.doSomething(Unknown Source)
> 	at com.francetelecom.resttest.RestTest.main(RestTest.java:27)
> Here is my jax-rs interface:
> @Path("/")
> public interface RestWS {
>     @POST
>     @Path("/test")
>     public String doSomething( @QueryParam("param") String paramName);
> }
> And here the way my client uses it:
> RestWS proxy = JAXRSClientFactory.create("http://localhost:8080/RestWSMock",RestWS.class);
> proxy.doSomething("bob");
> I can not get it simpler. Any idea what's wrong ?
> regards

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.