You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by gingming <gi...@healthlink.net> on 2009/07/11 08:10:20 UTC

Problem in using servicemix-cxf-bc and cxf-se in Tomcat

Hi,

I've the following components which makes use of the servicemix-cxf-bc and
servicemix-cxf-se:

			<sm:activationSpec>
				<sm:component>
					<cxfbc:component>
						<cxfbc:endpoints>
							<cxfbc:consumer
								wsdl="classpath:messageExchange.wsdl"
								targetService="hms:MessageExchangeWSService"
								targetInterface="hms:MessageExchangeWS">
							</cxfbc:consumer>
						</cxfbc:endpoints>					 
					</cxfbc:component>
				</sm:component>
			</sm:activationSpec>

			<sm:activationSpec componentName="MessageExchangeWSService">
				<sm:component>
					<cxfse:component>
						<cxfse:endpoints>
							<cxfse:endpoint>
								<cxfse:pojo>
									<bean class="example.MessageExchangeWSImpl"
										parent="baseComponentBean">
										<property name="namespacesMap" ref="namespacesMap"/>
									</bean>
								</cxfse:pojo>
							</cxfse:endpoint>
						</cxfse:endpoints>
					</cxfse:component>
				</sm:component>
			</sm:activationSpec>

Everything works fine and I can access the service by using the Jetty
exposed URL.

However, I would like to deploy it to Tomcat and access it through the URL
exposed by Tomcat.

I read that I need to use the CXFServlet, and I found an example of the
CXFManagedServlet in apache-servicemix-web.

I added the servlet mapping to the CXFManagedServlet in the web.xml and
changed the cxf-bc component to:

			<sm:activationSpec>
				<sm:component>
					<cxfbc:component>
						<cxfbc:endpoints>
							<cxfbc:consumer
								wsdl="classpath:messageExchange.wsdl"
								targetService="hms:MessageExchangeWSService"
								targetInterface="hms:MessageExchangeWS"
							
locationURI="http://localhost:8080/example-route/services/MessageExchangeWSService">
							</cxfbc:consumer>
						</cxfbc:endpoints>					 
					</cxfbc:component>
				</sm:component>
			</sm:activationSpec>

NOTE  that I can't put /MessageExchangeWSService in the locationURI property
as documented as it throws the following exception:

Caused by: java.net.MalformedURLException: no protocol:
/MessageExchangeWSService
	at java.net.URL.<init>(URL.java:567)
	at java.net.URL.<init>(URL.java:464)
	at java.net.URL.<init>(URL.java:413)
	at
org.apache.cxf.transport.http_jetty.JettyHTTPDestination.<init>(JettyHTTPDestination.java:91)
	at
org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory.createDestination(JettyHTTPTransportFactory.java:116)
	at
org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory.getDestination(JettyHTTPTransportFactory.java:103)
	at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:90)
	at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:58)
	at
org.apache.servicemix.cxfbc.CxfBcConsumer.validate(CxfBcConsumer.java:498)
	... 43 more

Now, my problem is, sometimes I can access the through:
http://localhost:8080/example-route/services/MessageExchangeWSService
successfully,
but sometimes it throws the following error:

org.apache.cxf.transport.servlet.ServletController invoke
WARNING: Can't find the request for
http://localhost:8080/example-route/services/MessageExchangeWSService's
Observer 

I put a breakpoint in the service method of the CXFManagedServlet, before it
calls the parent's mathod:

	protected void service(HttpServletRequest arg0, HttpServletResponse arg1)
throws ServletException, IOException {
		super.service(arg0, arg1);
	}

What I found out is that when the Tomcat URL works, it DOES NOT go through
the CXFManagedServlet's service method.  It will
go directly to my Pojo method, and everything works fine.

Now if I stop the Tomcat service and restart without cleaning the Tomcat
working directorty (and republish the lib), 
the request will fail.  I found out that it goes through the service method
of the CXFManagedServlet, and always gives the following error:
	org.apache.cxf.transport.servlet.ServletController invoke
	WARNING: Can't find the request for
http://localhost:8080/example-route/services/MessageExchangeWSService's
Observer 
At this point, I can't even retrieve the WSDL of my service. Nothing works.

I don't understand how it can behave so differently.  Can anybody tell me
how to properly deploy the servicemix-cxf-bc into Tomcat server?

For your information, I'm running in debug mode under the Eclipse IDE with
Tomcat 6.0.

Thanks for your help.
-- 
View this message in context: http://www.nabble.com/Problem-in-using-servicemix-cxf-bc-and-cxf-se-in-Tomcat-tp24437574p24437574.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.