You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Eugene Dzhurinsky <bo...@redwerk.com> on 2009/12/01 18:30:11 UTC
Working with HTTP sessions in Apache CXF
Hi there!
Can somebody please help me with the following issue:
I defined the method of interface as
@GET
@Path("/image")
@Produces("image/jpeg")
@Consumes(MediaType.WILDCARD)
public BufferedImage loadBodyPart(@Context MessageContext context,
@QueryParam("position") Triple3D position,
@QueryParam("lookdir") Triple3D locationDir);
Now, when I am trying to invoke it from WEB, I am getting the error:
WARNING: Application has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: No SessionHandler or SessionManager
at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:155)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:121)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:130)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:82)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:109)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:312)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:276)
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:536)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:915)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.IllegalStateException: No SessionHandler or SessionManager
at org.mortbay.jetty.Request.getSession(Request.java:1209)
at org.mortbay.jetty.Request.getSession(Request.java:1199)
at nl.greenvalley.hba.web.rest.EndpointService.loadBodyPart(EndpointService.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)
... 24 more
As far as I understood, the error means that I did not configure any session
manager for the underlying Jetty transport.
I am configuring things like this:
JAXRSServerFactoryBean sfb = new JAXRSServerFactoryBean();
sfb.setResourceClasses(EndpointServiceInterface.class);
SingletonResourceProvider srp = new SingletonResourceProvider(
new EndpointService(imageStorage, imageAction,
new DefaultBodyPartStateHandler(),
new BodyPartMapStorageInterface() {
sfb.setResourceProvider(EndpointServiceInterface.class, srp);
sfb.setProviders(Arrays.asList(new ImageBodyWriter(),
new ImageBodyReader()));
sfb.setAddress("http://localhost:9000/");
server = sfb.create();
So at this point I don't see any way to configure Jetty. Can somebody please
advice?
Thank you!
--
Eugene N Dzhurinsky
Re: Working with HTTP sessions in Apache CXF
Posted by Sergey Beryozkin <sb...@progress.com>.
Hi
I'm not sure exactly what to advise, perhaps if you can clarify what exactly you need to test then it may help....
So perhaps you'd like to register a mock Jetty handler which says extends org.mortbay.jetty.servlet.SessionHandler ?
If so then you can get a DestinationFactoryManager extension from the bus and then get a DestinationFactory for say an id "
http://cxf.apache.org/bindings/xformat
"
and cast it to JettyHttpTransportFactory and get JettyDestination from it using an EndpointInfo which you can get from the Service
which JAXRsServerFactoryBean created....Finally, you you can get a list of Jetty Handlers from the destination and add a mock
handler to the list...
Or may be you can add a custom JAXRS invoker to the JAXRsServerFactoryBean, before creating a service ? And intercept the call there
?
cheers, Sergey
On Tue, Dec 01, 2009 at 05:50:20PM -0000, Sergey Beryozkin wrote:
> Hi
>
> You'll probably need to set up an appropriate Jetty handler using httpj:handler, ex :
>
> <httpj:engine-factory bus="cxf" id="jetty-factory">
> <httpj:engine port="8009">
> <httpj:handlers>
> <bean class="org.mortbay.jetty.servlet.SessionHandler">
> <!-- configure it -->
> </bean>
> <bean class="org.mortbay.jetty.handler.DefaultHandler"/>
> </httpj:handlers>
> </httpj:engine>
> </httpj:engine-factory>
>
> Actually, you can probably just set a sessionSupport attribute to true :
>
> http://cwiki.apache.org/CXF20DOC/jetty-configuration.html
>
> let us know please if it helps
>
> cheers, Sergey
Hello, Sergey!
I guess that will help, but my goal is omit configuring everything using
Spring at this stage. I want to use some mock beans to be used with the
endpoint, and setup them in init method of my tests. So I will really prefer
to configure Jetty from Java, if that is possible.
Thank you for quick and prompt response!
--
Eugene N Dzhurinsky
Re: Working with HTTP sessions in Apache CXF
Posted by Eugene Dzhurinsky <bo...@redwerk.com>.
On Tue, Dec 01, 2009 at 05:50:20PM -0000, Sergey Beryozkin wrote:
> Hi
>
> You'll probably need to set up an appropriate Jetty handler using httpj:handler, ex :
>
> <httpj:engine-factory bus="cxf" id="jetty-factory">
> <httpj:engine port="8009">
> <httpj:handlers>
> <bean class="org.mortbay.jetty.servlet.SessionHandler">
> <!-- configure it -->
> </bean>
> <bean class="org.mortbay.jetty.handler.DefaultHandler"/>
> </httpj:handlers>
> </httpj:engine>
> </httpj:engine-factory>
>
> Actually, you can probably just set a sessionSupport attribute to true :
>
> http://cwiki.apache.org/CXF20DOC/jetty-configuration.html
>
> let us know please if it helps
>
> cheers, Sergey
Hello, Sergey!
I guess that will help, but my goal is omit configuring everything using
Spring at this stage. I want to use some mock beans to be used with the
endpoint, and setup them in init method of my tests. So I will really prefer
to configure Jetty from Java, if that is possible.
Thank you for quick and prompt response!
--
Eugene N Dzhurinsky
Re: Working with HTTP sessions in Apache CXF
Posted by Sergey Beryozkin <sb...@progress.com>.
Hi
You'll probably need to set up an appropriate Jetty handler using httpj:handler, ex :
<httpj:engine-factory bus="cxf" id="jetty-factory">
<httpj:engine port="8009">
<httpj:handlers>
<bean class="org.mortbay.jetty.servlet.SessionHandler">
<!-- configure it -->
</bean>
<bean class="org.mortbay.jetty.handler.DefaultHandler"/>
</httpj:handlers>
</httpj:engine>
</httpj:engine-factory>
Actually, you can probably just set a sessionSupport attribute to true :
http://cwiki.apache.org/CXF20DOC/jetty-configuration.html
let us know please if it helps
cheers, Sergey
Hi there!
Can somebody please help me with the following issue:
I defined the method of interface as
@GET
@Path("/image")
@Produces("image/jpeg")
@Consumes(MediaType.WILDCARD)
public BufferedImage loadBodyPart(@Context MessageContext context,
@QueryParam("position") Triple3D position,
@QueryParam("lookdir") Triple3D locationDir);
Now, when I am trying to invoke it from WEB, I am getting the error:
WARNING: Application has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: No SessionHandler or SessionManager
at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:155)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:121)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:130)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:82)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:106)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:236)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:109)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:312)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:276)
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:70)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:536)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:915)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:539)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:405)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.IllegalStateException: No SessionHandler or SessionManager
at org.mortbay.jetty.Request.getSession(Request.java:1209)
at org.mortbay.jetty.Request.getSession(Request.java:1199)
at nl.greenvalley.hba.web.rest.EndpointService.loadBodyPart(EndpointService.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)
... 24 more
As far as I understood, the error means that I did not configure any session
manager for the underlying Jetty transport.
I am configuring things like this:
JAXRSServerFactoryBean sfb = new JAXRSServerFactoryBean();
sfb.setResourceClasses(EndpointServiceInterface.class);
SingletonResourceProvider srp = new SingletonResourceProvider(
new EndpointService(imageStorage, imageAction,
new DefaultBodyPartStateHandler(),
new BodyPartMapStorageInterface() {
sfb.setResourceProvider(EndpointServiceInterface.class, srp);
sfb.setProviders(Arrays.asList(new ImageBodyWriter(),
new ImageBodyReader()));
sfb.setAddress("http://localhost:9000/");
server = sfb.create();
So at this point I don't see any way to configure Jetty. Can somebody please
advice?
Thank you!
--
Eugene N Dzhurinsky