Tuesday, May 8, 2012

Spring + CXF + Jetty

I am currently developing a standalone spring application (not in a container). This application needs to serve Servlets and a WebService. So I have chosen apache cxf and jetty.

I managed to get it working but I had two separate instances of Jetty running, one for servlets and another for cxf. So my question is, how do i specify which instance of a Jetty Server to be used by CXF?

Below are extracts of my config.

Setup for http server

<bean id="http-server" class="org.eclipse.jetty.server.Server"
init-method="start" destroy-method="stop">

<property name="connectors">
<bean class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<property name="port" value="8080" />
<property name="handler">
<bean id="handlers" class="org.eclipse.jetty.server.handler.HandlerList">
<property name="handlers">
<ref bean="ServletContainer" />
<bean class="org.eclipse.jetty.server.handler.DefaultHandler" />

The above works well for servlets...

Setup for CXF

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<jaxws:endpoint id="WebService" implementor="com.MyWebServiceImp"
<bean class="org.apache.cxf.feature.LoggingFeature" />
<entry key="faultStackTraceEnabled" value="false" />
<entry key="exceptionMessageCauseEnabled" value="false" />
<entry key="schema-validation-enabled" value="true" />

With the above config the system starts up but the web service is not "published" to the jetty Server and there is nothing "abnormal" in the logs.

I have pretty much tried everything I can thing of or find on Google. Any info or suggestion will be greatly appreciated as I have spent the past couple of days on this.


No comments:

Post a Comment