Return-Path: X-Original-To: apmail-cxf-users-archive@www.apache.org Delivered-To: apmail-cxf-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 01F05E684 for ; Mon, 7 Jan 2013 14:21:26 +0000 (UTC) Received: (qmail 79496 invoked by uid 500); 7 Jan 2013 14:21:26 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 79119 invoked by uid 500); 7 Jan 2013 14:21:25 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 79081 invoked by uid 99); 7 Jan 2013 14:21:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Jan 2013 14:21:24 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [78.47.10.19] (HELO root2.cps-server.de) (78.47.10.19) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Jan 2013 14:21:18 +0000 Received: from mars.esw.cps-net.de (router.esw.cps-net.de [217.91.17.223]) by root2.cps-server.de (Postfix) with ESMTPA id 7733C18171 for ; Mon, 7 Jan 2013 15:20:56 +0100 (CET) Received: from [10.0.0.99] (mfe.esw.cps-net.de [10.0.0.99]) by mars.esw.cps-net.de (Postfix) with ESMTPA id 47D7C3305FF for ; Mon, 7 Jan 2013 15:20:56 +0100 (CET) Message-ID: <50EAD9C2.5040507@fernausoft.de> Date: Mon, 07 Jan 2013 15:20:50 +0100 From: Martin Fernau Organization: FERNAUSOFT GmbH User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120723 Thunderbird/14.0 MIME-Version: 1.0 To: users@cxf.apache.org Subject: Re: Programmatically adding a Servlet References: <50E86AC1.2070807@fernausoft.de> <6B812517-924B-4CA4-9269-D5F4E2B699E5@itm.uni-luebeck.de> <50EABA16.4020800@fernausoft.de> <807173FF-0826-4CBC-9988-43D2C2D9ED98@itm.uni-luebeck.de> <86E13662-580E-4DED-80FA-F570E184E7CE@itm.uni-luebeck.de> <8439F2EA-C1E7-47E9-AB99-3726C4D12C9B@itm.uni-luebeck.de> In-Reply-To: <8439F2EA-C1E7-47E9-AB99-3726C4D12C9B@itm.uni-luebeck.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Hm - for me it's not "org.apache.cxf.jaxws.EndpointImpl". I use "javax.xml.ws.Endpoint" in my loadBus Method. Maybe this is your problem. HTH Martin Am 07.01.2013 13:44, schrieb Daniel Bimschas: > I keep running into the same problem. org.apache.cxf.jaxws.EndpointImpl.doPublish(...) still tries to start a new Jetty instance. Also I can't find any setter or similar functionality to pass an existing instance to EndpointImpl... > > On 07.01.2013, at 13:31, Daniel Bimschas wrote: > >> Forget the question! Got it now that this is just your use/test case having this DefaultHTTPServerEngine ;-) I'll try with the snippet... >> >> On 07.01.2013, at 13:16, Daniel Bimschas wrote: >> >>> Martin, >>> >>> that looks like exactly what I'm looking for! Unfortunately there seems to be no class called DefaultHTTPServerEngine. Is this code snippet up to date with the current release (I'm using 2.7.1)? >>> >>> Cheers, >>> Daniel >>> >>> On 07.01.2013, at 13:05, Martin Fernau wrote: >>> >>>> Hi Daniel, >>>> >>>> programmatically adding a WS-Endpoint was a bit more tricky. For this to >>>> work I did the follwoing: >>>> I write a CXFServlet-Class extending from CXFNonSpringServlet like this: >>>> >>>> --- cut >>>> public class CXFServlet extends CXFNonSpringServlet { >>>> private Logger logger = Logger.getLogger(CXFServlet.class); >>>> private DefaultHTTPServerEngine httpServerEngine; >>>> >>>> public CXFServlet(DefaultHTTPServerEngine httpServerEngine) { >>>> super(); >>>> this.httpServerEngine = httpServerEngine; >>>> } >>>> >>>> @Override >>>> public void loadBus(ServletConfig servletConfig) { >>>> super.loadBus(servletConfig); >>>> logger.info("Loading CXF servlet..."); >>>> BusFactory.setDefaultBus(this.getBus()); >>>> >>>> Set endpoints = httpServerEngine.getJaxServices().keySet(); >>>> for (String endpoint : endpoints) { >>>> Endpoint.publish(endpoint, >>>> httpServerEngine.getJaxServices().get(endpoint)); >>>> } >>>> } >>>> } >>>> --- cut >>>> >>>> This CXFServlet I add like this: >>>> >>>> --- cut >>>> CXFServlet servlet = new CXFServlet(httpServerEngine), "/services/*"; >>>> ServletHolder sh = new ServletHolder(servlet); >>>> servletContext.getServletHandler().addServletWithMapping(sh, servletPath); >>>> --- cut >>>> >>>> The "loadBus" method from my CXFServlet gets called automatically from >>>> CXF somewhen. Within this method I just use the reference to my >>>> DefaultHTTPServerEngine Object to obtain a list of my WS-Objects I want >>>> to add to my system. Theoretically you just add all WS-Objects in this >>>> method like this: >>>> >>>> --- cut >>>> Endpoint.publish("myService", objectOfClassImplementingWSInterface); >>>> --- cut >>>> >>>> You need to know that the endpoint "myService" is relative to the path I >>>> used to add my CXFServlet in jetty. As I used "/services/*" for this >>>> path in Jetty, the real path for Endpoint.publish("myService", ...)" is >>>> "/services/myService". >>>> >>>> HTH >>>> Martin >>>> >>>> >>>> Am 07.01.2013 11:31, schrieb Daniel Bimschas: >>>>> 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 martin.fernau@fernausoft.de >>>>>> 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. >>>>>> >>>>> >>>> >>>> >>>> -- >>>> FERNAUSOFT GmbH >>>> Gartenstra�e 42 - 37269 Eschwege >>>> >>>> Telefon (0 56 51) 95 99-0 >>>> Telefax (0 56 51) 95 99-90 >>>> >>>> eMail martin.fernau@fernausoft.de >>>> 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 622 >>>> >>>> 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. >>>> >>>> >>> >> > -- FERNAUSOFT GmbH Gartenstra�e 42 - 37269 Eschwege Telefon (0 56 51) 95 99-0 Telefax (0 56 51) 95 99-90 eMail martin.fernau@fernausoft.de 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 622 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.