Reputation: 4860
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
Upvotes: 0
Views: 4550
Reputation: 22948
Here is a bit different answer, you would have you application created as you do it now trough spring but using maven you would publish you app while building it here is how, you pom.xml plugin configuration:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.0.2.v20100331</version>
<configuration>
<webAppConfig>
<contextPath>/yourapplication</contextPath>
<descriptor>
${basedir}/src/main/webapp/WEB-INF/jetty/jetty-web.xml
</descriptor>
</webAppConfig>
<scanIntervalSeconds>5</scanIntervalSeconds>
<stopPort>9966</stopPort>
<stopKey>foo</stopKey>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>9080</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
Your web xml is jetty-web.xml
specified in the pom above. So having your cxf web service published to jetty server would be easy. Assuming everything is setup-ed right, just mvn clean install
would publish your service to jetty.
Upvotes: 1