You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Alex Heneveld <al...@cloudsoftcorp.com> on 2019/01/19 00:44:31 UTC

How to configure session handling for CXF JAX-RS with service.xml (karaf and jetty) ?

I cannot for the life of me figure out how to configure session handling 
when setting up CXF from a service.xml blueprint.

Things I'd hope might work -- specify my preferred SessionHandler as a 
provider, or supply a jetty-web.xml in my bundle -- don't have any 
effect.  It's easy enough if you have access to the 
ServletContextHandler or WebAppContext, and for non-jersey webapps the 
snippet at [1] in jetty-web.xml works a treat.  But the link between CXF 
and Jetty seems murky when coming from an OSGi blueprint.  It might work 
to ditch the blueprint and use a web.xml descriptor instead, specifying 
CXFServlet, and expecting a jetty-web.xml to be read for that servlet 
... but that feels like a step backwards.

Isn't this a common use case, persisting sessions among servers or 
across restarts?  Jetty has a whole chapter on it at [1].  But I'm not 
finding anything on it in the CXF docs.

So I welcome help from the experts!

Thanks
Alex


[1] from 
https://www.eclipse.org/jetty/documentation/9.4.x/sessions-usecases.html

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
   <Call id="sh" name="getSessionHandler">
     <Set name="sessionCache">
       <New class="org.eclipse.jetty.server.session.DefaultSessionCache">
         <Arg><Ref id="sh"/></Arg>
         <Set name="sessionDataStore">
            <New 
class="org.eclipse.jetty.server.session.FileSessionDataStore">
              <Set name="storeDir">/tmp/sessions</Set>
            </New>
         </Set>
       </New>
     </Set>
   </Call>
</Configure>


RE: How to configure session handling for CXF JAX-RS with service.xml (karaf and jetty) ?

Posted by Andrei Shakirin <as...@talend.com>.
Hi Alex,

In Apache Karaf you can use PAX Web to setup and start an OSGI HTTP service
If you are declaring relative CXF service addresses, CXF services are exposed through Pax Web jetty instance.
In this case, Jetty is configurable through etc/jetty.xml and etc/org.ops4j.pax.web.cfg.

If you bind on another port, CXF will create a new Jetty instance and a dedicated Jetty connector. If that case, the configuration is on the CXF side.

There are some details in:
http://karaf.apache.org/manual/latest/
http://camel.apache.org/cxf-example-osgi.html

Regards,
Andrei.

> -----Original Message-----
> From: Alex Heneveld [mailto:alex.heneveld@cloudsoftcorp.com]
> Sent: Samstag, 19. Januar 2019 01:45
> To: users@cxf.apache.org
> Subject: How to configure session handling for CXF JAX-RS with service.xml
> (karaf and jetty) ?
>
>
> I cannot for the life of me figure out how to configure session handling when
> setting up CXF from a service.xml blueprint.
>
> Things I'd hope might work -- specify my preferred SessionHandler as a
> provider, or supply a jetty-web.xml in my bundle -- don't have any effect.  It's
> easy enough if you have access to the ServletContextHandler or
> WebAppContext, and for non-jersey webapps the snippet at [1] in jetty-web.xml
> works a treat.  But the link between CXF and Jetty seems murky when coming
> from an OSGi blueprint.  It might work to ditch the blueprint and use a web.xml
> descriptor instead, specifying CXFServlet, and expecting a jetty-web.xml to be
> read for that servlet ... but that feels like a step backwards.
>
> Isn't this a common use case, persisting sessions among servers or across
> restarts?  Jetty has a whole chapter on it at [1].  But I'm not finding anything on
> it in the CXF docs.
>
> So I welcome help from the experts!
>
> Thanks
> Alex
>
>
> [1] from
> https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__www.eclipse.org_jetty_documentation_9.4.x_sessions-
> 2Dusecases.html&d=DwICaQ&c=2w5q_42kFG40MI2alLPgJw&r=bWOqkHjIZE0s
> ZtdpFMIhm-
> lcbhtB3cv08OlIr0lkKR4&m=DDazvFkPZJN1sa4AASsDcM0mSG0CNkfm3naHvFoq
> 60M&s=th2h-o2v2uGak4OxP0sqyGvtBEOimu0PlOfcMKXsds8&e=
>
> <Configure class="org.eclipse.jetty.webapp.WebAppContext">
>    <Call id="sh" name="getSessionHandler">
>      <Set name="sessionCache">
>        <New class="org.eclipse.jetty.server.session.DefaultSessionCache">
>          <Arg><Ref id="sh"/></Arg>
>          <Set name="sessionDataStore">
>             <New
> class="org.eclipse.jetty.server.session.FileSessionDataStore">
>               <Set name="storeDir">/tmp/sessions</Set>
>             </New>
>          </Set>
>        </New>
>      </Set>
>    </Call>
> </Configure>

As a recipient of an email from Talend, your contact personal data will be on our systems. Please see our contacts privacy notice at Talend, Inc. <https://www.talend.com/contacts-privacy-policy/>