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">
<list>
<bean class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<property name="port" value="8080" />
</bean>
</list>
</property>
<property name="handler">
<bean id="handlers" class="org.eclipse.jetty.server.handler.HandlerList">
<property name="handlers">
<list>
<ref bean="ServletContainer" />
<bean class="org.eclipse.jetty.server.handler.DefaultHandler" />
</list>
</property>
</bean>
</property>
</bean>


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"
address="/ws">
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature" />
</jaxws:features>
<jaxws:properties>
<entry key="faultStackTraceEnabled" value="false" />
<entry key="exceptionMessageCauseEnabled" value="false" />
<entry key="schema-validation-enabled" value="true" />
</jaxws:properties>
</jaxws:endpoint>


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.



Thanks





No comments:

Post a Comment