views:

2259

answers:

4
+3  Q: 

CXF without Spring

Hi there, Is it possible to use CXF with Tomcat and without Spring?

+8  A: 

I suppose you mean to create a Web Service with CFX that it would run in Tomcat? This is totally possible and Spring is optional. You don't have to use it, if you don't want to.

kgiannakakis
+3  A: 

CXF is meant to be used with spring. It is strange you want to use it without it.

You could try NoSpringServletServer and use the ServerFactoryBean or JaxWS API.

There is an example on the CXF source distribution on:

http://svn.apache.org/repos/asf/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java

But you will still need spring as a dependency. The basic JaxWS can be done without spring. But for almost anything else you will need at the very least spring-core.jar

Marcelo Morales
Well actually, I was thinking about building a webapp that would be deployed as a war file in tomcat, not a standalone server. So I don't need Jetty neither.
Maurice Perry
A webapp deploys on tomcat just as in any other servlet container (almost). The example shows a standalone server, but the servlet can be referenced from a web.xml. CXFNonSpringServlet extends Servlet you know.
Marcelo Morales
That link appears to be no longer valid. Here's an alternate source of information: http://cxf.apache.org/docs/servlet-transport.html#ServletTransport-UsingtheservlettransportwithoutSpring
Jim Rush
A: 

I dont think it is possible to use CXF completely independent of spring in Tomcat.

Reason is that when I do a Maven dependency tree list (mvn dependency:tree) for a bare minimum CXF webservice, the following is listed (which shows that it needs Spring)

     +- org.apache.cxf:cxf-rt-core:jar:2.2.2:compile
[INFO] |  |  +- com.sun.xml.bind:jaxb-impl:jar:2.1.9:compile

[INFO] |  |  +- org.springframework:spring-core:jar:2.5.5:compile

[INFO] |  |  +- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:jar:1.6:compile

    org.apache.cxf:cxf-rt-transports-http:jar:2.2.2:compile
[INFO]    \- org.springframework:spring-web:jar:2.5.5:compile

[INFO]       +- commons-logging:commons-logging:jar:1.1.1:compile
+3  A: 

You can configure CXF programmatically without Spring. See the code examples here. Putting the web application context path together with the end point extension--Greeter in the code example--will display a summary page in the browser with a link to the WSDL.

No Spring necessary, giving CXF a very small footprint. I found the only jars necessary to be (for CXF 2.2.1):

  • XmlSchema-1.4.5.jar
  • cxf-2.2.3.jar
  • wsdl4j-1.6.2.jar

I believe neethi-2.0.4.jar may also be necessary for some configurations, but I haven't needed it.

Have fun!