cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Mazza <glen.ma...@gmail.com>
Subject Re: Issue with multiple CXF servlets (and proposed fix)
Date Tue, 23 Dec 2008 01:33:40 GMT

I would highly recommend waiting until Dan K. reviews this.  He (and perhaps
Willem) would be in position best to know about all moving parts that may be
affected by this change.  I suspect he is on holiday leave this week (and
possibly the next), however.

Could the problem also be that you specified
<load-on-startup>1</load-on-startup> for *both* the servlets defined,
instead of giving them distinct values?  Somehow I doubt that's the issue
though.

Glen



Tong, Gary (FID) wrote:
> 
> Hello,
> 
> I'm having issues with creating multiple CXFServlets.  I'm trying to
> insantiate 2 independent CXF servlets and deploy them at different URLs. 
> The relevant part of the web.xml looks like:
> 
>   <servlet>
>     <servlet-name>test</servlet-name>
>    
> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
>     <load-on-startup>1</load-on-startup>
>     <init-param>
>       <param-name>config-location</param-name>
>       <param-value>/WEB-INF/test-servlet.xml</param-value>
>     </init-param>
>   </servlet>
> 
>   <servlet-mapping>
>     <servlet-name>test</servlet-name>
>     <url-pattern>/t/*</url-pattern>
>   </servlet-mapping>
> 
>   <servlet>
>     <servlet-name>foo</servlet-name>
>    
> <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
>     <load-on-startup>1</load-on-startup>
>     <init-param>
>       <param-name>config-location</param-name>
>       <param-value>/WEB-INF/foo-servlet.xml</param-value>
>     </init-param>
>   </servlet>
> 
>   <servlet-mapping>
>     <servlet-name>foo</servlet-name>
>     <url-pattern>/f/*</url-pattern>
>   </servlet-mapping>
> 
> This, unfortunately, doesn't work.  My test-servlet.xml file looks like:
> 
> <?xml version="1.0"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xmlns:jaxrs="http://cxf.apache.org/jaxrs"
>        xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
> 
>   <import resource="classpath:META-INF/cxf/cxf.xml" />
>   <import
> resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
>   <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
> 
>   <jaxrs:server id="cxfMapping" address="/">
>     <jaxrs:serviceBeans>
>       <ref bean="testController"/>
>     </jaxrs:serviceBeans>
>     <jaxrs:extensionMappings>
>       <entry key="xml" value="application/xml" />
>     </jaxrs:extensionMappings>
>   </jaxrs:server>
> 
>   <bean id="testController" class="test.TestController"/>
> 
> </beans>
> 
> And foo-servlet.xml looks much the same.  This configuration gives me a
> "No service was found." response.  However, if I move the import
> statements to the base spring application context, both the test and foo
> servlets end up serving up test-servlet.xml and foo-servlet.xml gets
> ignored.
> 
> As far as I can tell, this problem occurs because the configs specified in
> config-location aren't loaded until the majority of the servlet has been
> initialized.  Because of this, most of the settings in test-servlet.xml
> and foo-servlet.xml are ignored during initialization.
> 
> The order of initialization in CXFServlet seems to be:
> 
> 1. Find the spring app context.
> 2. Create a new bus based on the app context.
> 3. Set up the servlet transport factory
> 4. Create the controller
> 5. Load the additional configuration from the config-location servlet
> param
> 
> My proposed fix is to change the order of initialization to:
> 
> 1. Find the spring app context.
> 2. Load the additional configuration from the config-location servlet
> param
> 3. Create a new bus based on the new child context (or original spring app
> context if there is no additional configuration)
> 4. Set up the servlet transport factory
> 5. Create the controller
> 
> The attached diff does this and fixes the problem that I have with
> creating two CXFServlets.  Hopefully this is the right way to do this.
> 
> Thanks,
> Gary
> --------------------------------------------------------
> 
> This is not an offer (or solicitation of an offer) to buy/sell the
> securities/instruments mentioned or an official confirmation.  Morgan
> Stanley may deal as principal in or own or act as market maker for
> securities/instruments mentioned or may advise the issuers.  This is not
> research and is not from MS Research but it may refer to a research
> analyst/research report.  Unless indicated, these views are the author's
> and may differ from those of Morgan Stanley research or others in the
> Firm.  We do not represent this is accurate or complete and we may not
> update this.  Past performance is not indicative of future returns.  For
> additional information, research reports and important disclosures,
> contact me or see https://secure.ms.com/servlet/cls.  You should not use
> e-mail to request, authorize or effect the purchase or sale of any
> security or instrument, to send transfer instructions, or to effect any
> other transactions.  We cannot guarantee that any such requests received
> via e-mail will be processed in a timely manner.  This communication is
> solely for the addressee(s) and may contain confidential information.  We
> do not waive confidentiality by mistransmission.  Contact me if you do not
> wish to receive these communications.  In the UK, this communication is
> directed in the UK to those persons who are professional and eligible
> counterparties (as defined in the UK Financial Services Authority's
> rules).
> 
> 

-- 
View this message in context: http://www.nabble.com/Issue-with-multiple-CXF-servlets-%28and-proposed-fix%29-tp21129999p21138164.html
Sent from the cxf-dev mailing list archive at Nabble.com.


Mime
View raw message