Matt Luongo is a graduating computer science major at Georgia Tech focused on artificial intelligence, networking, and software engineering. He works as an undergraduate assistant for the College of Computing's Technology Services Organization in support of the College's academic resources.


CXF Servlet Issue

Mon, 06/07/2010 - 16:43 - Matt Luongo

Earlier today I ran into a weird error deploying my CXF web service to an embedded Tomcat instance. The error looked a bit like this.

...
SEVERE: Servlet /myServlet threw load() exception
java.lang.ClassCastException:
org.apache.cxf.transport.servlet.CXFServlet
cannot be cast to javax.servlet.Servlet

Annoying. I've seen this before, but never actually had to solve it myself. I figured that my web.xml was misconfigured, but on checking it out, everything seemed fine.

To cut a long story short, servlet.jar is the culprit. I needed the Sun jar to test the web service with JUnit. By including the dependency in my POM, I inadvertently packaged two in my war- one with CXF, and another as a dependency of my project. I changed my dependency scope to test, and continued on my way.