You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Sean Patrick Floyd <se...@gmx.net> on 2010/06/17 12:21:33 UTC
CXF problem: IllegalStateException (Already connected)
Hello,
I am a somewhat experienced Java / Spring developer but new to CXF. I am
trying to hook up a client and server using the simple frontend using these
spring configs:
SERVER:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:simple="http://cxf.apache.org/simple"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cs="http://[www.mycompany.com]/coupon/service"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/simple
http://cxf.apache.org/schemas/simple.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-autowire="byType"
>
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
<import
resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<import resource="classpath*:persistenceContext.xml" /> <!-my service
implementation -->
<!-- serviceClass points to an interface -->
<simple:server id="server" serviceBean="couponService"
serviceClass="[com.mycompany].MyServiceInterface"
bindingId="http://apache.org/cxf/binding/http"
address="/${wsdl.path}"
serviceName="cs:couponService"
endpointName="cs:couponServicePort"
>
<simple:dataBinding>
<bean
class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
</simple:dataBinding>
<simple:binding>
<soap:soapBinding version="1.2" mtomEnabled="true" />
</simple:binding>
</simple:server>
<context:property-placeholder location="classpath:service.properties"
/>
</beans>
CLIENT:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:simple="http://cxf.apache.org/simple"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:oxm=http://www.springframework.org/schema/oxm
xmlns:cs="http://[www.mycompany.com]/coupon/service"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/simple
http://cxf.apache.org/schemas/simple.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd"
default-autowire="byType"
>
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
<import
resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<simple:client id="couponService" wsdlLocation="${wsdl.url}?wsdl"
serviceName="cs:couponService"
endpointName="cs:couponServicePort"
transportId="http://schemas.xmlsoap.org/soap/http"
address="${wsdl.url}"
bindingId="http://apache.org/cxf/binding/http"
serviceClass="[com.mycompany].MyServiceInterface">
<simple:dataBinding>
<bean
class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
</simple:dataBinding>
<simple:binding>
<soap:soapBinding mtomEnabled="true" version="1.2" />
</simple:binding>
</simple:client>
<context:property-placeholder location="classpath:service.properties"
/>
</beans>
On the client side, I inject the generated service into my web application
(I am using wicket but that should be irrelevant) and when I call service
methods on it I get an IllegalStateException from java.net.HttpURLConnection
saying the connection is already open. Here's the stack trace:
java.lang.IllegalStateException: IllegalStateException invoking
http://localhost:9999/services/coupon: Already connected
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcces
sorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstruc
torAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(H
TTPConduit.java:2058)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPCond
uit.java:2048)
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$MessageSenderEndingInter
ceptor.handleMessage(MessageSenderInterceptor.java:62)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain
.java:243)
at
org.apache.cxf.binding.http.interceptor.DatabindingOutSetupInterceptor.handl
eMessage(DatabindingOutSetupInterceptor.java:91)
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.frontend.ClientProxy.invoke(ClientProxy.java:68)
at $Proxy30.createIndividualUserCouponsJob(Unknown Source)
at
[com.mycompany].coupons.web.app.dummycontent.DummyContentInitializer.addSome
IndividualCoupons(DummyContentInitializer.java:84)
at
[com.mycompany].coupons.web.app.dummycontent.DummyContentInitializer.addSome
Coupons(DummyContentInitializer.java:68)
at
[com.mycompany].coupons.web.app.dummycontent.DummyContentInitializer.init(Du
mmyContentInitializer.java:50)
at
org.apache.wicket.Application.callInitializers(Application.java:843)
at
org.apache.wicket.Application.initializeComponents(Application.java:678)
at
org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:725)
at
org.apache.wicket.protocol.http.WicketServlet.init(WicketServlet.java:219)
at javax.servlet.GenericServlet.init(GenericServlet.java:241)
at
org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:433)
at
org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:256)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at
org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:617)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
at
org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218)
at
org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
at
org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at
org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
at org.mortbay.jetty.Server.doStart(Server.java:220)
at
org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at [com.mycompany].coupons.web.test.Start.main(Start.java:45)
Caused by: java.lang.IllegalStateException: Already connected
at
java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.jav
a:103)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotRe
ached(HTTPConduit.java:1889)
at
org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutpu
tStream.java:99)
at
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPCond
uit.java:1980)
This happens the first time a service call is made, and the only
URLConnection that is opened before that is that of the wsdl (I put a
breakpoint in the constructor of HttpURLConnection).
I have searched the web for similar problems, but all I found was a bug
using rest that has already been fixed.
I am trying to use the simple frontend, as my service is not annotated with
jax-ws annotations and I would like to keep it that way.
Can someone help? Thanks in advance.
Sean
--
MostlyMagic.com - Sean Patrick Floyd
IT-Consultant und Senior Java Developer
Mobile: +49 170 4746496
Mail: info@mostlymagic.com
Web: www.mostlymagic.com
XING: https://www.xing.com/profile/SeanPatrick_Floyd
GULP: http://www.gulp.de/Profil/mostlymagic.html
Re: CXF problem: IllegalStateException (Already connected)
Posted by Daniel Kulp <dk...@apache.org>.
On Thursday 17 June 2010 10:07:35 am Sean Patrick Floyd wrote:
> Daniel, thanks for your help.
>
> I'll try to post a Sample project in an hour or so.
> [
> Re Versions, I think I am current.
Yep. That's the latest CXF.
Dan
>
> Here's the output of
> mvn dependency:tree -Dincludes=org.apache.cxf
>
> Client Project:
>
> +- org.apache.cxf:cxf-rt-frontend-simple:jar:2.2.9:compile
>
> | +- org.apache.cxf:cxf-api:jar:2.2.9:compile
> |
> | | +- org.apache.cxf:cxf-common-utilities:jar:2.2.9:compile
> | | \- org.apache.cxf:cxf-common-schemas:jar:2.2.9:compile
> |
> | +- org.apache.cxf:cxf-rt-core:jar:2.2.9:compile
> | \- org.apache.cxf:cxf-rt-bindings-soap:jar:2.2.9:compile
> |
> | +- org.apache.cxf:cxf-tools-common:jar:2.2.9:compile
> | \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.2.9:compile
>
> +- org.apache.cxf:cxf-rt-transports-http:jar:2.2.9:compile
> +- org.apache.cxf:cxf-rt-databinding-aegis:jar:2.2.9:compile
> \- org.apache.cxf:cxf-rt-bindings-http:jar:2.2.9:compile
> +- org.apache.cxf:cxf-rt-bindings-xml:jar:2.2.9:compile
> \- org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.2.9:compile
> \- org.apache.cxf:cxf-rt-ws-addr:jar:2.2.9:compile
>
> Server Project:
>
> +- org.apache.cxf:cxf-rt-databinding-aegis:jar:2.2.9:compile
>
> | +- org.apache.cxf:cxf-api:jar:2.2.9:compile
> |
> | | +- org.apache.cxf:cxf-common-utilities:jar:2.2.9:compile
> | | \- org.apache.cxf:cxf-common-schemas:jar:2.2.9:compile
> |
> | +- org.apache.cxf:cxf-rt-core:jar:2.2.9:compile
> | \- org.apache.cxf:cxf-rt-frontend-simple:jar:2.2.9:compile
> |
> | \- org.apache.cxf:cxf-rt-bindings-soap:jar:2.2.9:compile
> |
> | \- org.apache.cxf:cxf-tools-common:jar:2.2.9:compile
>
> +- org.apache.cxf:cxf-rt-transports-http:jar:2.2.9:compile
> +- org.apache.cxf:cxf-rt-bindings-http:jar:2.2.9:compile
>
> | +- org.apache.cxf:cxf-rt-bindings-xml:jar:2.2.9:compile
> |
> | | \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.2.9:compile
> |
> | \- org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.2.9:compile
> |
> | \- org.apache.cxf:cxf-rt-ws-addr:jar:2.2.9:compile
>
> \- org.apache.cxf:cxf-rt-transports-http-jetty:jar:2.2.9:provided
>
> > Hello,
> >
> >
> >
> > I am a somewhat experienced Java / Spring developer but new to CXF. I am
> > trying to hook up a client and server using the simple frontend using
>
> these
>
> > spring configs:
> >
> >
> >
> > SERVER:
> >
> >
> >
> > <beans xmlns="http://www.springframework.org/schema/beans"
> >
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >
> > xmlns:simple="http://cxf.apache.org/simple"
> >
> > xmlns:soap="http://cxf.apache.org/bindings/soap"
> >
> > xmlns:context="http://www.springframework.org/schema/context"
> >
> > xmlns:cs="http://[www.mycompany.com]/coupon/service"
> >
> > xsi:schemaLocation="http://www.springframework.org/schema/beans
> >
> > http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
> >
> > http://cxf.apache.org/bindings/soap
> >
> > http://cxf.apache.org/schemas/configuration/soap.xsd
> >
> > http://cxf.apache.org/simple
> >
> > http://cxf.apache.org/schemas/simple.xsd
> >
> > http://www.springframework.org/schema/context
> >
> > http://www.springframework.org/schema/context/spring-context-3.0.xsd"
> >
> > default-autowire="byType"
> >
> > <import resource="classpath:META-INF/cxf/cxf.xml" />
> >
> > <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
> >
> > <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
> >
> > <import
> >
> > resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml" />
> >
> > <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
> >
> > <import resource="classpath*:persistenceContext.xml" /> <!-my
>
> service
>
> > implementation -->
> >
> > <!-- serviceClass points to an interface -->
> >
> > <simple:server id="server" serviceBean="couponService"
> >
> > serviceClass="[com.mycompany].MyServiceInterface"
> >
> > bindingId="http://apache.org/cxf/binding/http"
> >
> > address="/${wsdl.path}"
> >
> > serviceName="cs:couponService"
> >
> > endpointName="cs:couponServicePort"
> >
> >
> >
> > <simple:dataBinding>
> >
> > <bean
> >
> > class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
> >
> > </simple:dataBinding>
> >
> > <simple:binding>
> >
> > <soap:soapBinding version="1.2" mtomEnabled="true" />
> >
> > </simple:binding>
> >
> > </simple:server>
> >
> >
> >
> > <context:property-placeholder
>
> location="classpath:service.properties"
>
> > />
> >
> > </beans>
> >
> >
> >
> > CLIENT:
> >
> >
> >
> > <beans xmlns="http://www.springframework.org/schema/beans"
> >
> > xmlns:simple="http://cxf.apache.org/simple"
> >
> > xmlns:soap="http://cxf.apache.org/bindings/soap"
> >
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >
> > xmlns:aop="http://www.springframework.org/schema/aop"
> >
> > xmlns:context="http://www.springframework.org/schema/context"
> >
> > xmlns:oxm=http://www.springframework.org/schema/oxm
> >
> > xmlns:cs="http://[www.mycompany.com]/coupon/service"
> >
> > xsi:schemaLocation="http://www.springframework.org/schema/beans
> >
> > http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
> >
> > http://cxf.apache.org/bindings/soap
> >
> > http://cxf.apache.org/schemas/configuration/soap.xsd
> >
> > http://cxf.apache.org/simple
> >
> > http://cxf.apache.org/schemas/simple.xsd
> >
> > http://www.springframework.org/schema/aop
> >
> > http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
> >
> > http://www.springframework.org/schema/context
> >
> > http://www.springframework.org/schema/context/spring-context-3.0.xsd
> >
> > http://www.springframework.org/schema/oxm
> >
> > http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd"
> >
> > default-autowire="byType"
> >
> > <import resource="classpath:META-INF/cxf/cxf.xml" />
> >
> > <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
> >
> > <import
> >
> > resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml" />
> >
> > <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
> >
> >
> >
> >
> >
> > <simple:client id="couponService" wsdlLocation="${wsdl.url}?wsdl"
> >
> > serviceName="cs:couponService"
> >
> > endpointName="cs:couponServicePort"
> >
> > transportId="http://schemas.xmlsoap.org/soap/http"
> >
> > address="${wsdl.url}"
> >
> > bindingId="http://apache.org/cxf/binding/http"
> >
> > serviceClass="[com.mycompany].MyServiceInterface">
> >
> > <simple:dataBinding>
> >
> > <bean
> >
> > class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
> >
> > </simple:dataBinding>
> >
> > <simple:binding>
> >
> > <soap:soapBinding mtomEnabled="true" version="1.2" />
> >
> > </simple:binding>
> >
> > </simple:client>
> >
> >
> >
> > <context:property-placeholder
>
> location="classpath:service.properties"
>
> > />
> >
> >
> >
> >
> >
> > </beans>
> >
> >
> >
> > On the client side, I inject the generated service into my web
> > application (I am using wicket but that should be irrelevant) and when I
> > call service methods on it I get an IllegalStateException from
> > java.net.HttpURLConnection saying the connection is already open. Here's
> > the stack trace:
> >
> >
> >
> > java.lang.IllegalStateException: IllegalStateException invoking
> > http://localhost:9999/services/coupon: Already connected
> >
> > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> >
> > Method)
> >
> > at
>
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcce
>
> > s sorImpl.java:39)
> >
> > at
>
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstru
>
> > c torAccessorImpl.java:27)
> >
> > at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
> >
> > at
>
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(
>
> > H TTPConduit.java:2058)
> >
> > at
>
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPCon
>
> > d uit.java:2048)
> >
> > 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$MessageSenderEndingInte
>
> > r ceptor.handleMessage(MessageSenderInterceptor.java:62)
> >
> > at
>
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>
> > n .java:243)
> >
> > at
>
> org.apache.cxf.binding.http.interceptor.DatabindingOutSetupInterceptor.hand
>
> > l eMessage(DatabindingOutSetupInterceptor.java:91)
> >
> > at
>
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
>
> > n .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.frontend.ClientProxy.invoke(ClientProxy.java:68)
> >
> > at $Proxy30.createIndividualUserCouponsJob(Unknown Source)
> >
> > at
>
> [com.mycompany].coupons.web.app.dummycontent.DummyContentInitializer.addSom
>
> > e IndividualCoupons(DummyContentInitializer.java:84)
> >
> > at
>
> [com.mycompany].coupons.web.app.dummycontent.DummyContentInitializer.addSom
>
> > e Coupons(DummyContentInitializer.java:68)
> >
> > at
>
> [com.mycompany].coupons.web.app.dummycontent.DummyContentInitializer.init(D
>
> > u mmyContentInitializer.java:50)
> >
> > at
> >
> > org.apache.wicket.Application.callInitializers(Application.java:843)
> >
> > at
> >
> > org.apache.wicket.Application.initializeComponents(Application.java:678)
> >
> > at
> >
> > org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:725)
> >
> > at
> >
> > org.apache.wicket.protocol.http.WicketServlet.init(WicketServlet.java:219
> > )
> >
> > at javax.servlet.GenericServlet.init(GenericServlet.java:241)
> >
> > at
>
> org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:433)
>
> > at
> >
> > org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:256)
> >
> > at
> >
> > org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
> >
> > at
>
> org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:617
>
> > )
> >
> > at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
> >
> > at
>
> org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218
>
> > )
> >
> > at
> >
> > org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
> >
> > at
> >
> > org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
> >
> > at
> >
> > org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
> >
> > at
> >
> > org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
> >
> > at org.mortbay.jetty.Server.doStart(Server.java:220)
> >
> > at
> >
> > org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
> >
> > at [com.mycompany].coupons.web.test.Start.main(Start.java:45)
> >
> > Caused by: java.lang.IllegalStateException: Already connected
> >
> > at
>
> java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.ja
>
> > v a:103)
> >
> > at
>
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotR
>
> > e ached(HTTPConduit.java:1889)
> >
> > at
>
> org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutp
>
> > u tStream.java:99)
> >
> > at
>
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPCon
>
> > d uit.java:1980)
> >
> >
> >
> > This happens the first time a service call is made, and the only
> > URLConnection that is opened before that is that of the wsdl (I put a
> > breakpoint in the constructor of HttpURLConnection).
> >
> >
> >
> > I have searched the web for similar problems, but all I found was a bug
> > using rest that has already been fixed.
> >
> > I am trying to use the simple frontend, as my service is not annotated
>
> with
>
> > jax-ws annotations and I would like to keep it that way.
> >
> >
> >
> > Can someone help? Thanks in advance.
> >
> >
> >
> > Sean
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
RE: CXF problem: IllegalStateException (Already connected)
Posted by Sean Patrick Floyd <se...@gmx.net>.
Daniel, thanks for your help.
I'll try to post a Sample project in an hour or so.
Re Versions, I think I am current.
Here's the output of
mvn dependency:tree -Dincludes=org.apache.cxf
Client Project:
+- org.apache.cxf:cxf-rt-frontend-simple:jar:2.2.9:compile
| +- org.apache.cxf:cxf-api:jar:2.2.9:compile
| | +- org.apache.cxf:cxf-common-utilities:jar:2.2.9:compile
| | \- org.apache.cxf:cxf-common-schemas:jar:2.2.9:compile
| +- org.apache.cxf:cxf-rt-core:jar:2.2.9:compile
| \- org.apache.cxf:cxf-rt-bindings-soap:jar:2.2.9:compile
| +- org.apache.cxf:cxf-tools-common:jar:2.2.9:compile
| \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.2.9:compile
+- org.apache.cxf:cxf-rt-transports-http:jar:2.2.9:compile
+- org.apache.cxf:cxf-rt-databinding-aegis:jar:2.2.9:compile
\- org.apache.cxf:cxf-rt-bindings-http:jar:2.2.9:compile
+- org.apache.cxf:cxf-rt-bindings-xml:jar:2.2.9:compile
\- org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.2.9:compile
\- org.apache.cxf:cxf-rt-ws-addr:jar:2.2.9:compile
Server Project:
+- org.apache.cxf:cxf-rt-databinding-aegis:jar:2.2.9:compile
| +- org.apache.cxf:cxf-api:jar:2.2.9:compile
| | +- org.apache.cxf:cxf-common-utilities:jar:2.2.9:compile
| | \- org.apache.cxf:cxf-common-schemas:jar:2.2.9:compile
| +- org.apache.cxf:cxf-rt-core:jar:2.2.9:compile
| \- org.apache.cxf:cxf-rt-frontend-simple:jar:2.2.9:compile
| \- org.apache.cxf:cxf-rt-bindings-soap:jar:2.2.9:compile
| \- org.apache.cxf:cxf-tools-common:jar:2.2.9:compile
+- org.apache.cxf:cxf-rt-transports-http:jar:2.2.9:compile
+- org.apache.cxf:cxf-rt-bindings-http:jar:2.2.9:compile
| +- org.apache.cxf:cxf-rt-bindings-xml:jar:2.2.9:compile
| | \- org.apache.cxf:cxf-rt-databinding-jaxb:jar:2.2.9:compile
| \- org.apache.cxf:cxf-rt-frontend-jaxws:jar:2.2.9:compile
| \- org.apache.cxf:cxf-rt-ws-addr:jar:2.2.9:compile
\- org.apache.cxf:cxf-rt-transports-http-jetty:jar:2.2.9:provided
--
MostlyMagic.com - Sean Patrick Floyd
IT-Consultant und Senior Java Developer
Mobile: +49 170 4746496
Mail: info@mostlymagic.com
Web: www.mostlymagic.com
XING: https://www.xing.com/profile/SeanPatrick_Floyd
GULP: http://www.gulp.de/Profil/mostlymagic.html
-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org]
Sent: Donnerstag, 17. Juni 2010 15:56
To: users@cxf.apache.org
Cc: Sean Patrick Floyd
Subject: Re: CXF problem: IllegalStateException (Already connected)
I've never really seen this error before with CXF. Is there any way you
can
create a small sample that shows it?
Also, what version of CXF and what version of the JDK? If not using the
latest of each, definitely try updating.
Dan
On Thursday 17 June 2010 6:21:33 am Sean Patrick Floyd wrote:
> Hello,
>
>
>
> I am a somewhat experienced Java / Spring developer but new to CXF. I am
> trying to hook up a client and server using the simple frontend using
these
> spring configs:
>
>
>
> SERVER:
>
>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:simple="http://cxf.apache.org/simple"
>
> xmlns:soap="http://cxf.apache.org/bindings/soap"
> xmlns:context="http://www.springframework.org/schema/context"
>
> xmlns:cs="http://[www.mycompany.com]/coupon/service"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>
> http://cxf.apache.org/bindings/soap
> http://cxf.apache.org/schemas/configuration/soap.xsd
>
> http://cxf.apache.org/simple
> http://cxf.apache.org/schemas/simple.xsd
>
> http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context-3.0.xsd"
>
> default-autowire="byType"
>
>
>
>
>
> <import resource="classpath:META-INF/cxf/cxf.xml" />
>
> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>
> <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
>
> <import
> resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml" />
>
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
> <import resource="classpath*:persistenceContext.xml" /> <!-my
service
> implementation -->
>
>
>
> <!-- serviceClass points to an interface -->
>
> <simple:server id="server" serviceBean="couponService"
>
> serviceClass="[com.mycompany].MyServiceInterface"
>
> bindingId="http://apache.org/cxf/binding/http"
>
> address="/${wsdl.path}"
>
> serviceName="cs:couponService"
>
> endpointName="cs:couponServicePort"
>
>
>
> <simple:dataBinding>
>
> <bean
> class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
>
> </simple:dataBinding>
>
> <simple:binding>
>
> <soap:soapBinding version="1.2" mtomEnabled="true" />
>
> </simple:binding>
>
> </simple:server>
>
>
>
> <context:property-placeholder
location="classpath:service.properties"
> />
>
> </beans>
>
>
>
> CLIENT:
>
>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>
> xmlns:simple="http://cxf.apache.org/simple"
> xmlns:soap="http://cxf.apache.org/bindings/soap"
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:aop="http://www.springframework.org/schema/aop"
>
> xmlns:context="http://www.springframework.org/schema/context"
>
> xmlns:oxm=http://www.springframework.org/schema/oxm
>
> xmlns:cs="http://[www.mycompany.com]/coupon/service"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>
> http://cxf.apache.org/bindings/soap
> http://cxf.apache.org/schemas/configuration/soap.xsd
>
> http://cxf.apache.org/simple
> http://cxf.apache.org/schemas/simple.xsd
>
> http://www.springframework.org/schema/aop
> http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
>
> http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context-3.0.xsd
>
> http://www.springframework.org/schema/oxm
> http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd"
>
> default-autowire="byType"
>
>
>
>
>
>
>
> <import resource="classpath:META-INF/cxf/cxf.xml" />
>
> <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
>
> <import
> resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml" />
>
> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>
>
>
>
>
> <simple:client id="couponService" wsdlLocation="${wsdl.url}?wsdl"
>
> serviceName="cs:couponService"
>
> endpointName="cs:couponServicePort"
>
> transportId="http://schemas.xmlsoap.org/soap/http"
>
> address="${wsdl.url}"
>
> bindingId="http://apache.org/cxf/binding/http"
>
> serviceClass="[com.mycompany].MyServiceInterface">
>
> <simple:dataBinding>
>
> <bean
> class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
>
> </simple:dataBinding>
>
> <simple:binding>
>
> <soap:soapBinding mtomEnabled="true" version="1.2" />
>
> </simple:binding>
>
> </simple:client>
>
>
>
> <context:property-placeholder
location="classpath:service.properties"
> />
>
>
>
>
>
> </beans>
>
>
>
> On the client side, I inject the generated service into my web application
> (I am using wicket but that should be irrelevant) and when I call service
> methods on it I get an IllegalStateException from
> java.net.HttpURLConnection saying the connection is already open. Here's
> the stack trace:
>
>
>
> java.lang.IllegalStateException: IllegalStateException invoking
> http://localhost:9999/services/coupon: Already connected
>
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>
> at
>
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcce
> s sorImpl.java:39)
>
> at
>
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstru
> c torAccessorImpl.java:27)
>
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>
> at
>
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(
> H TTPConduit.java:2058)
>
> at
>
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPCon
> d uit.java:2048)
>
> 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$MessageSenderEndingInte
> r ceptor.handleMessage(MessageSenderInterceptor.java:62)
>
> at
>
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
> n .java:243)
>
> at
>
org.apache.cxf.binding.http.interceptor.DatabindingOutSetupInterceptor.hand
> l eMessage(DatabindingOutSetupInterceptor.java:91)
>
> at
>
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
> n .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.frontend.ClientProxy.invoke(ClientProxy.java:68)
>
> at $Proxy30.createIndividualUserCouponsJob(Unknown Source)
>
> at
>
[com.mycompany].coupons.web.app.dummycontent.DummyContentInitializer.addSom
> e IndividualCoupons(DummyContentInitializer.java:84)
>
> at
>
[com.mycompany].coupons.web.app.dummycontent.DummyContentInitializer.addSom
> e Coupons(DummyContentInitializer.java:68)
>
> at
>
[com.mycompany].coupons.web.app.dummycontent.DummyContentInitializer.init(D
> u mmyContentInitializer.java:50)
>
> at
> org.apache.wicket.Application.callInitializers(Application.java:843)
>
> at
> org.apache.wicket.Application.initializeComponents(Application.java:678)
>
> at
> org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:725)
>
> at
> org.apache.wicket.protocol.http.WicketServlet.init(WicketServlet.java:219)
>
> at javax.servlet.GenericServlet.init(GenericServlet.java:241)
>
> at
>
org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:433)
>
> at
> org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:256)
>
> at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
>
> at
>
org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:617
> )
>
> at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
>
> at
>
org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218
> )
>
> at
> org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
>
> at
> org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
>
> at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
>
> at
> org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
>
> at org.mortbay.jetty.Server.doStart(Server.java:220)
>
> at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
>
> at [com.mycompany].coupons.web.test.Start.main(Start.java:45)
>
> Caused by: java.lang.IllegalStateException: Already connected
>
> at
>
java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.ja
> v a:103)
>
> at
>
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotR
> e ached(HTTPConduit.java:1889)
>
> at
>
org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutp
> u tStream.java:99)
>
> at
>
org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPCon
> d uit.java:1980)
>
>
>
> This happens the first time a service call is made, and the only
> URLConnection that is opened before that is that of the wsdl (I put a
> breakpoint in the constructor of HttpURLConnection).
>
>
>
> I have searched the web for similar problems, but all I found was a bug
> using rest that has already been fixed.
>
> I am trying to use the simple frontend, as my service is not annotated
with
> jax-ws annotations and I would like to keep it that way.
>
>
>
> Can someone help? Thanks in advance.
>
>
>
> Sean
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: CXF problem: IllegalStateException (Already connected)
Posted by Daniel Kulp <dk...@apache.org>.
On Thursday 17 June 2010 11:55:15 am Sean Patrick Floyd wrote:
> OH, attachment (10 k) was removed. OK, I'll try to post it somewhere. Sorry
>
> Sean
You can send to me directly if you want. dan at kulp.com should be fine.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
RE: CXF problem: IllegalStateException (Already connected)
Posted by Sean Patrick Floyd <se...@gmx.net>.
OH, attachment (10 k) was removed. OK, I'll try to post it somewhere. Sorry
Sean
--
MostlyMagic.com - Sean Patrick Floyd
IT-Consultant und Senior Java Developer
Mobile: +49 170 4746496
Mail: info@mostlymagic.com
Web: www.mostlymagic.com
XING: https://www.xing.com/profile/SeanPatrick_Floyd
GULP: http://www.gulp.de/Profil/mostlymagic.html
-----Original Message-----
From: Sean Patrick Floyd [mailto:seanizer@gmx.net]
Sent: Donnerstag, 17. Juni 2010 17:52
To: users@cxf.apache.org
Subject: RE: CXF problem: IllegalStateException (Already connected)
OK, attached is a small project that reproduces the error.
RE: CXF problem: IllegalStateException (Already connected)
Posted by Sean Patrick Floyd <se...@gmx.net>.
OK, attached is a small project that reproduces the error.
The directory structure is this:
cxf-dummy
- cxf-dummy-api
- cxf-dummy-impl
- cxf-dummy-server
- cxf-dummy-client
- pom.xml
Api contains the service interface, impl the implementation
Server has a dependency to impl, client only to api
Instructions:
1) On the root level do mvn clean install
2) Launch the server project (cxf-dummy-server) using either
a) mvn jetty:run inside the server project or
b) in src/test/java there is a class named
com.mycompany.service.server.Start that starts an embedded jetty and
launches the server
3) Run the client com.mycompany.service.client.MyServiceClient (in project
cxf-dummy-client) and see the error in action
Thanks for your time!
BTW I am using java 1.6:
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing)
Sean
--
MostlyMagic.com - Sean Patrick Floyd
IT-Consultant und Senior Java Developer
Mobile: +49 170 4746496
Mail: info@mostlymagic.com
Web: www.mostlymagic.com
XING: https://www.xing.com/profile/SeanPatrick_Floyd
GULP: http://www.gulp.de/Profil/mostlymagic.html
-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org]
Sent: Donnerstag, 17. Juni 2010 15:56
To: users@cxf.apache.org
Cc: Sean Patrick Floyd
Subject: Re: CXF problem: IllegalStateException (Already connected)
I've never really seen this error before with CXF. Is there any way you
can
create a small sample that shows it?
Dan
Re: CXF problem: IllegalStateException (Already connected)
Posted by Daniel Kulp <dk...@apache.org>.
I've started to debug this a bit and there is definitely an issue with the
http binding. I need to dig in a bit to figure out what it's trying to do
and why.
HOWEVER, the question I have to ask is why are you using the HTTP binding?
For the most part, it's completely deprecated and relatively unsupported in
favor of the JAX-RS stuff. In your case, since it looks like you are just
trying to POST XML, I would suggest the xml binding. Just change the lines:
<import resource="classpath:META-INF/cxf/cxf-extension-binding-http.xml" />
to
<import resource="classpath:META-INF/cxf/cxf-extension-xml.xml" />
and the bindingId things to:
bindingId="http://cxf.apache.org/bindings/xformat"
and everything seems to work fine. (once I fixed the serviceBean entry on
the server element)
Anyway, I'm looking into the http binding to try and fix it, but I would
suggest moving away from it.
Dan
On Friday 18 June 2010 6:15:59 am Sean Patrick Floyd wrote:
> I have now fixed a part of the problem myself by turning chunking off in
> the http conduit.
> But new problems arise.
>
> My new clientContext.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
> xmlns:simple="http://cxf.apache.org/simple"
> xmlns:soap="http://cxf.apache.org/bindings/soap"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:context="http://www.springframework.org/schema/context"
> xmlns:ds="http://www.mycompany.com/services/dummy"
> xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
> default-autowire="byType"
> xsi:schemaLocation="http://www.mycompany.com/services/dummy
> http://www.springframework.org/schema/oxm
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
> http://cxf.apache.org/bindings/soap
> http://cxf.apache.org/schemas/configuration/soap.xsd
> http://cxf.apache.org/simple
> http://cxf.apache.org/schemas/simple.xsd
> http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context-3.0.xsd
>
> http://cxf.apache.org/transports/http/configuration
>
> http://cxf.apache.org/schemas/configuration/http-conf.xsd
> ">
>
> <import resource="classpath:META-INF/cxf/cxf.xml" />
> <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
> <import
> resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml" />
> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>
>
> <http-conf:conduit name="*.http-conduit">
> <http-conf:client AllowChunking="false" />
> </http-conf:conduit>
>
>
> <simple:client id="dummyService"
> wsdlLocation="http://localhost:9999/services/dummy?wsdl"
> serviceName="ds:dummyService"
> endpointName="ds:dummyServicePort"
> transportId="http://schemas.xmlsoap.org/soap/http"
> address="http://localhost:9999/services/dummy"
> bindingId="http://apache.org/cxf/binding/http"
> serviceClass="com.mycompany.service.MyService">
> <simple:dataBinding>
> <bean
> class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
> </simple:dataBinding>
> <simple:binding>
> <soap:soapBinding mtomEnabled="true" version="1.2"
> />
> </simple:binding>
> </simple:client>
>
> </beans>
>
> Now I get this exception:
>
> WARNUNG: Interceptor for
> {http://www.mycompany.com/services/dummy}dummyService has thrown exception,
> unwinding now
> org.apache.cxf.interceptor.Fault: Invalid URL/Verb combination. Verb: POST
> Path:
> at
> org.apache.cxf.binding.http.interceptor.DispatchInterceptor.handleMessage(D
> i spatchInterceptor.java:74)
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
> n .java:243)
> at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationO
> b server.java:110)
> at
> org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestinati
> o n.java:98)
> at
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(Servle
> t Controller.java:423)
> at
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController
> . java:178)
> at
> org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServl
> e t.java:142)
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Abstract
> H TTPServlet.java:179)
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPSer
> v let.java:103)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
> at
> org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPSe
> r vlet.java:159)
> at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
> at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367)
> at
> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
> at
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
> at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
> at
> org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
> at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
> at org.mortbay.jetty.Server.handle(Server.java:295)
> at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:503)
> at
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnecti
> o n.java:827)
> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:511)
> at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:210)
> at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:379)
> at
> org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:2
> 2 6)
> at
> org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:
> 4 42)
>
> Sean
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
RE: CXF problem: IllegalStateException (Already connected)
Posted by Sean Patrick Floyd <se...@gmx.net>.
I have now fixed a part of the problem myself by turning chunking off in the
http conduit.
But new problems arise.
My new clientContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:simple="http://cxf.apache.org/simple"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:ds="http://www.mycompany.com/services/dummy"
xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
default-autowire="byType"
xsi:schemaLocation="http://www.mycompany.com/services/dummy
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/simple
http://cxf.apache.org/schemas/simple.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
<import
resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<http-conf:conduit name="*.http-conduit">
<http-conf:client AllowChunking="false" />
</http-conf:conduit>
<simple:client id="dummyService"
wsdlLocation="http://localhost:9999/services/dummy?wsdl"
serviceName="ds:dummyService"
endpointName="ds:dummyServicePort"
transportId="http://schemas.xmlsoap.org/soap/http"
address="http://localhost:9999/services/dummy"
bindingId="http://apache.org/cxf/binding/http"
serviceClass="com.mycompany.service.MyService">
<simple:dataBinding>
<bean
class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
</simple:dataBinding>
<simple:binding>
<soap:soapBinding mtomEnabled="true" version="1.2"
/>
</simple:binding>
</simple:client>
</beans>
Now I get this exception:
WARNUNG: Interceptor for
{http://www.mycompany.com/services/dummy}dummyService has thrown exception,
unwinding now
org.apache.cxf.interceptor.Fault: Invalid URL/Verb combination. Verb: POST
Path:
at
org.apache.cxf.binding.http.interceptor.DispatchInterceptor.handleMessage(Di
spatchInterceptor.java:74)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain
.java:243)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationOb
server.java:110)
at
org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestinatio
n.java:98)
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(Servlet
Controller.java:423)
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.
java:178)
at
org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServle
t.java:142)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractH
TTPServlet.java:179)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServ
let.java:103)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPSer
vlet.java:159)
at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
at
org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:295)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:503)
at
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnectio
n.java:827)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:511)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:210)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:379)
at
org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:22
6)
at
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:4
42)
Sean
--
MostlyMagic.com - Sean Patrick Floyd
IT-Consultant und Senior Java Developer
Mobile: +49 170 4746496
Mail: info@mostlymagic.com
Web: www.mostlymagic.com
XING: https://www.xing.com/profile/SeanPatrick_Floyd
GULP: http://www.gulp.de/Profil/mostlymagic.html
-----Original Message-----
From: Sean Patrick Floyd [mailto:seanizer@gmx.net]
Sent: Freitag, 18. Juni 2010 10:19
To: users@cxf.apache.org
Subject: RE: CXF problem: IllegalStateException (Already connected)
Sorry once more, the usage instructions were a bit unclear, and jetty:run
wouldn't work.
So here are the revised usage instruction:
OK, I'll try again, this time the project is here:
http://mostlymagic.com/cxf-dummy-service.zip
The directory structure is this:
cxf-dummy
- cxf-dummy-api
- cxf-dummy-impl
- cxf-dummy-server
- cxf-dummy-client
- pom.xml
Api contains the service interface, impl the implementation Server has a
dependency to impl, client only to api
Instructions:
1) inside cxf-dummy execute
mvn clean install
2) Launch the server project (cxf-dummy-server) using either
a)
mvn org.codehaus.mojo:exec-maven-plugin:1.1.1:java
-Dexec.mainClass=com.mycompany.service.server.Start
-Dexec.classpathScope=test
b) from eclipse: in src/test/java there is a class named
com.mycompany.service.server.Start
that starts an embedded jetty and launches the server.
run as -> java application
3) Run the client com.mycompany.service.client.MyServiceClient (in project
cxf-dummy-client) and see the error in action. again either:
a)
mvn org.codehaus.mojo:exec-maven-plugin:1.1.1:java
-Dexec.mainClass=com.mycompany.service.client.MyServiceClient
b)
or in eclipse, find this class in src/main/java and
run as -> java application
result: IllegalStateException(already connected)
Sean
RE: CXF problem: IllegalStateException (Already connected)
Posted by Sean Patrick Floyd <se...@gmx.net>.
Sorry once more, the usage instructions were a bit unclear, and jetty:run
wouldn't work.
So here are the revised usage instruction:
OK, I'll try again, this time the project is here:
http://mostlymagic.com/cxf-dummy-service.zip
The directory structure is this:
cxf-dummy
- cxf-dummy-api
- cxf-dummy-impl
- cxf-dummy-server
- cxf-dummy-client
- pom.xml
Api contains the service interface, impl the implementation Server has a
dependency to impl, client only to api
Instructions:
1) inside cxf-dummy execute
mvn clean install
2) Launch the server project (cxf-dummy-server) using either
a)
mvn org.codehaus.mojo:exec-maven-plugin:1.1.1:java
-Dexec.mainClass=com.mycompany.service.server.Start
-Dexec.classpathScope=test
b) from eclipse: in src/test/java there is a class named
com.mycompany.service.server.Start
that starts an embedded jetty and launches the server.
run as -> java application
3) Run the client com.mycompany.service.client.MyServiceClient (in project
cxf-dummy-client) and see the error in action. again either:
a)
mvn org.codehaus.mojo:exec-maven-plugin:1.1.1:java
-Dexec.mainClass=com.mycompany.service.client.MyServiceClient
b)
or in eclipse, find this class in src/main/java and
run as -> java application
result: IllegalStateException(already connected)
Sean
--
MostlyMagic.com - Sean Patrick Floyd
IT-Consultant und Senior Java Developer
Mobile: +49 170 4746496
Mail: info@mostlymagic.com
Web: www.mostlymagic.com
XING: https://www.xing.com/profile/SeanPatrick_Floyd
GULP: http://www.gulp.de/Profil/mostlymagic.html
-----Original Message-----
From: Sean Patrick Floyd [mailto:seanizer@gmx.net]
Sent: Donnerstag, 17. Juni 2010 23:26
To: users@cxf.apache.org
Subject: RE: CXF problem: IllegalStateException (Already connected)
OK, I'll try again, this time the project is here:
http://mostlymagic.com/cxf-dummy-service.zip
The directory structure is this:
cxf-dummy
- cxf-dummy-api
- cxf-dummy-impl
- cxf-dummy-server
- cxf-dummy-client
- pom.xml
Api contains the service interface, impl the implementation
Server has a dependency to impl, client only to api
Instructions:
[etc...]
RE: CXF problem: IllegalStateException (Already connected)
Posted by Sean Patrick Floyd <se...@gmx.net>.
OK, I'll try again, this time the project is here:
http://mostlymagic.com/cxf-dummy-service.zip
The directory structure is this:
cxf-dummy
- cxf-dummy-api
- cxf-dummy-impl
- cxf-dummy-server
- cxf-dummy-client
- pom.xml
Api contains the service interface, impl the implementation
Server has a dependency to impl, client only to api
Instructions:
1) On the root level do mvn clean install
2) Launch the server project (cxf-dummy-server) using either
a) mvn jetty:run inside the server project or
b) in src/test/java there is a class named
com.mycompany.service.server.Start that starts an embedded jetty and
launches the server
3) Run the client com.mycompany.service.client.MyServiceClient (in project
cxf-dummy-client) and see the error in action
Thanks for your time!
BTW I am using java 1.6:
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing)
Sean
--
MostlyMagic.com - Sean Patrick Floyd
IT-Consultant und Senior Java Developer
Mobile: +49 170 4746496
Mail: info@mostlymagic.com
Web: www.mostlymagic.com
XING: https://www.xing.com/profile/SeanPatrick_Floyd
GULP: http://www.gulp.de/Profil/mostlymagic.html
-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org]
Sent: Donnerstag, 17. Juni 2010 15:56
To: users@cxf.apache.org
Cc: Sean Patrick Floyd
Subject: Re: CXF problem: IllegalStateException (Already connected)
I've never really seen this error before with CXF. Is there any way you
can
create a small sample that shows it?
Dan
Re: CXF problem: IllegalStateException (Already connected)
Posted by Daniel Kulp <dk...@apache.org>.
I've never really seen this error before with CXF. Is there any way you can
create a small sample that shows it?
Also, what version of CXF and what version of the JDK? If not using the
latest of each, definitely try updating.
Dan
On Thursday 17 June 2010 6:21:33 am Sean Patrick Floyd wrote:
> Hello,
>
>
>
> I am a somewhat experienced Java / Spring developer but new to CXF. I am
> trying to hook up a client and server using the simple frontend using these
> spring configs:
>
>
>
> SERVER:
>
>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:simple="http://cxf.apache.org/simple"
>
> xmlns:soap="http://cxf.apache.org/bindings/soap"
> xmlns:context="http://www.springframework.org/schema/context"
>
> xmlns:cs="http://[www.mycompany.com]/coupon/service"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>
> http://cxf.apache.org/bindings/soap
> http://cxf.apache.org/schemas/configuration/soap.xsd
>
> http://cxf.apache.org/simple
> http://cxf.apache.org/schemas/simple.xsd
>
> http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context-3.0.xsd"
>
> default-autowire="byType"
>
>
>
>
>
> <import resource="classpath:META-INF/cxf/cxf.xml" />
>
> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>
> <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
>
> <import
> resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml" />
>
> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
> <import resource="classpath*:persistenceContext.xml" /> <!-my service
> implementation -->
>
>
>
> <!-- serviceClass points to an interface -->
>
> <simple:server id="server" serviceBean="couponService"
>
> serviceClass="[com.mycompany].MyServiceInterface"
>
> bindingId="http://apache.org/cxf/binding/http"
>
> address="/${wsdl.path}"
>
> serviceName="cs:couponService"
>
> endpointName="cs:couponServicePort"
>
>
>
> <simple:dataBinding>
>
> <bean
> class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
>
> </simple:dataBinding>
>
> <simple:binding>
>
> <soap:soapBinding version="1.2" mtomEnabled="true" />
>
> </simple:binding>
>
> </simple:server>
>
>
>
> <context:property-placeholder location="classpath:service.properties"
> />
>
> </beans>
>
>
>
> CLIENT:
>
>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>
> xmlns:simple="http://cxf.apache.org/simple"
> xmlns:soap="http://cxf.apache.org/bindings/soap"
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:aop="http://www.springframework.org/schema/aop"
>
> xmlns:context="http://www.springframework.org/schema/context"
>
> xmlns:oxm=http://www.springframework.org/schema/oxm
>
> xmlns:cs="http://[www.mycompany.com]/coupon/service"
>
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
>
> http://cxf.apache.org/bindings/soap
> http://cxf.apache.org/schemas/configuration/soap.xsd
>
> http://cxf.apache.org/simple
> http://cxf.apache.org/schemas/simple.xsd
>
> http://www.springframework.org/schema/aop
> http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
>
> http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context-3.0.xsd
>
> http://www.springframework.org/schema/oxm
> http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd"
>
> default-autowire="byType"
>
>
>
>
>
>
>
> <import resource="classpath:META-INF/cxf/cxf.xml" />
>
> <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
>
> <import
> resource="classpath:META-INF/cxf/cxf-extension-http-binding.xml" />
>
> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>
>
>
>
>
> <simple:client id="couponService" wsdlLocation="${wsdl.url}?wsdl"
>
> serviceName="cs:couponService"
>
> endpointName="cs:couponServicePort"
>
> transportId="http://schemas.xmlsoap.org/soap/http"
>
> address="${wsdl.url}"
>
> bindingId="http://apache.org/cxf/binding/http"
>
> serviceClass="[com.mycompany].MyServiceInterface">
>
> <simple:dataBinding>
>
> <bean
> class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
>
> </simple:dataBinding>
>
> <simple:binding>
>
> <soap:soapBinding mtomEnabled="true" version="1.2" />
>
> </simple:binding>
>
> </simple:client>
>
>
>
> <context:property-placeholder location="classpath:service.properties"
> />
>
>
>
>
>
> </beans>
>
>
>
> On the client side, I inject the generated service into my web application
> (I am using wicket but that should be irrelevant) and when I call service
> methods on it I get an IllegalStateException from
> java.net.HttpURLConnection saying the connection is already open. Here's
> the stack trace:
>
>
>
> java.lang.IllegalStateException: IllegalStateException invoking
> http://localhost:9999/services/coupon: Already connected
>
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> Method)
>
> at
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAcce
> s sorImpl.java:39)
>
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstru
> c torAccessorImpl.java:27)
>
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(
> H TTPConduit.java:2058)
>
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPCon
> d uit.java:2048)
>
> 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$MessageSenderEndingInte
> r ceptor.handleMessage(MessageSenderInterceptor.java:62)
>
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
> n .java:243)
>
> at
> org.apache.cxf.binding.http.interceptor.DatabindingOutSetupInterceptor.hand
> l eMessage(DatabindingOutSetupInterceptor.java:91)
>
> at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
> n .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.frontend.ClientProxy.invoke(ClientProxy.java:68)
>
> at $Proxy30.createIndividualUserCouponsJob(Unknown Source)
>
> at
> [com.mycompany].coupons.web.app.dummycontent.DummyContentInitializer.addSom
> e IndividualCoupons(DummyContentInitializer.java:84)
>
> at
> [com.mycompany].coupons.web.app.dummycontent.DummyContentInitializer.addSom
> e Coupons(DummyContentInitializer.java:68)
>
> at
> [com.mycompany].coupons.web.app.dummycontent.DummyContentInitializer.init(D
> u mmyContentInitializer.java:50)
>
> at
> org.apache.wicket.Application.callInitializers(Application.java:843)
>
> at
> org.apache.wicket.Application.initializeComponents(Application.java:678)
>
> at
> org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:725)
>
> at
> org.apache.wicket.protocol.http.WicketServlet.init(WicketServlet.java:219)
>
> at javax.servlet.GenericServlet.init(GenericServlet.java:241)
>
> at
> org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:433)
>
> at
> org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:256)
>
> at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
>
> at
> org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:617
> )
>
> at org.mortbay.jetty.servlet.Context.startContext(Context.java:139)
>
> at
> org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1218
> )
>
> at
> org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:500)
>
> at
> org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
>
> at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
>
> at
> org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
>
> at org.mortbay.jetty.Server.doStart(Server.java:220)
>
> at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
>
> at [com.mycompany].coupons.web.test.Start.main(Start.java:45)
>
> Caused by: java.lang.IllegalStateException: Already connected
>
> at
> java.net.HttpURLConnection.setFixedLengthStreamingMode(HttpURLConnection.ja
> v a:103)
>
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.thresholdNotR
> e ached(HTTPConduit.java:1889)
>
> at
> org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutp
> u tStream.java:99)
>
> at
> org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPCon
> d uit.java:1980)
>
>
>
> This happens the first time a service call is made, and the only
> URLConnection that is opened before that is that of the wsdl (I put a
> breakpoint in the constructor of HttpURLConnection).
>
>
>
> I have searched the web for similar problems, but all I found was a bug
> using rest that has already been fixed.
>
> I am trying to use the simple frontend, as my service is not annotated with
> jax-ws annotations and I would like to keep it that way.
>
>
>
> Can someone help? Thanks in advance.
>
>
>
> Sean
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog