cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tong, Gary \(FID\)" <>
Subject Issue with multiple CXF servlets (and proposed fix)
Date Mon, 22 Dec 2008 15:51:27 GMT

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:





This, unfortunately, doesn't work.  My test-servlet.xml file looks like:

<?xml version="1.0"?>
<beans xmlns=""

  <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="/">
      <ref bean="testController"/>
      <entry key="xml" value="application/xml" />

  <bean id="testController" class="test.TestController"/>


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

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.


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
 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).

  • Unnamed multipart/mixed (inline, 7-Bit, 0 bytes)
View raw message