Is it possible to use CXF with Tomcat and without Spring? If so, how?
4 Answers
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!
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.

- 103,016
- 27
- 158
- 194
-
16well, i do believe he's asking how that might be done, not just if it can be done. – liltitus27 Dec 11 '13 at 19:40
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.
Here is the code for the NoSpringServletServer.
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
-
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 Mar 27 '09 at 18:15
-
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. – HMM Mar 27 '09 at 18:38
-
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 Aug 02 '10 at 16:31
-
3Why is it strange you'd want to use CXF without Spring? Assuming you don't already use Spring in your app, it's a HUGE pile of dependencies just to get a webservice working. It's definitely possible to run CXF without even Spring Core. You write more code, but less XML, so it's a trade-off. – pendor Jun 26 '13 at 14:09
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

- 398,947
- 96
- 818
- 769
-
2
-
1I agree the dependency tree will still have transitive spring dependencies, agreed with @bercolax , programmatically the spring api XML config can be avoided – Ashoka Dec 20 '15 at 10:33