Hi Martin,

thank you for this answer. I actually already did this myself and it works fine 
for adding a normal servlet. But when I add an JAX-RS application using 
JAXRSServerFactoryBean (or a JAX-WS endpoint using Endpoint.publish(...)) it 
tries to start another Jetty instance on the same port :-(.

It is pretty obvious to me that a "ServerFactory" creates a new Jetty instance. 
However, I did not find another way yet to programmatically add a JAX-WS/JAX-RS 
service instance to the root context.

https://gist.github.com/4473947 shows how I construct my server instance.

So, to me it seems that I have to let the CXF framework know of the existence 
of the Jetty instance. Does somebody have an idea?

Best,
Daniel

On 05.01.2013, at 19:02, Martin Fernau wrote:

> Not sure if there is a way to do this with CXF - but I do it with jetty 
> itself:
> 
> servletContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
> servletContext.setContextPath("/");
> ContextHandlerCollection contexts = new ContextHandlerCollection();
> contexts.setHandlers(new Handler[] { securityHandler, servletContext, 
> webAppContext });
> // Regiser on server
> server.setHandler(contexts);
> // For each servlet you want to add do this
> ServletHolder sh = new ServletHolder(servlet);
> String servletPath = "/some/where";
> servletContext.getServletHandler().addServletWithMapping(sh, servletPath);
> 
> Regards
> Martin
> 
> 
> Am 05.01.2013 17:47, schrieb Daniel Bimschas:
>> Hi list,
>> 
>> Is there a way with CXF to programmatically add a good old HttpServlet 
>> instance to an already running instance of the embedded Jetty container?
>> 
>> This way I would be able to add a WebSocketServlet to Jetty...
>> 
>> Best regards,
>> Daniel
> 
> 
> -- 
> FERNAUSOFT GmbH
> Gartenstraße 42 - 37269 Eschwege
> 
> Telefon (0 56 51) 95 99-0
> Telefax (0 56 51) 95 99-90
> 
> eMail [email protected]
> Internet http://www.fernausoft.de
> 
> Handelsregister Eschwege, HRB 1585
> Geschäftsführer: Axel Fernau, Ulrich Fernau, Martin Fernau
> Steuernummer 025 233 00041
> USt-ID-Nr. DE 178 554 522
> 
> Diese E-Mail und alle beigefügten Dateien sind vertraulich und nur für den 
> Adressaten bestimmt.
> Wenn Sie nicht der richtige Adressat sind, leiten Sie diese E-Mail bitte 
> nicht weiter, öffnen Sie etwaige Anhänge nicht, machen Sie keine Kopien und 
> speichern Sie diese E-Mail nicht. Informieren Sie uns bitte, indem Sie uns 
> eine Antwort-Mail senden oder uns telefonisch unter +49 (0)5651 9599-0 
> verständigen. Löschen Sie bitte anschließend die erhaltene E-Mail aus Ihrem 
> System.
> Vielen Dank!
> 
> This email is only intended for the addressee. The content of this email, 
> including all attachments is confidential and includes privileged material.
> If you are not the intended recipient, please do not forward or disclose this 
> email, do not open any attachments or make copies or save this email 
> anywhere. Please inform us about the error by returning this email or by 
> calling us on our phone +49 (0)5651 9599-0. Please then finally delete this 
> email from your system.
> Thank you very much.
> 

Reply via email to