users@jersey.java.net

[Jersey] Tomcat can't load com.sun.jersey.spi.container.servlet.ServletContainer, but Glasfish can

From: Sven Strittmatter <weltraumschaf_at_googlemail.com>
Date: Tue, 14 Feb 2012 13:24:07 +0100

Hello List,

I'm trying to write a simple webapp which serves static files (css/js
etc.), JSPs, Servlets and especially Jersey resources using Netbeans and
Maven. The purpose is to learn about Javas web tier. I also want to
deploy the webapp to different containers. In my case Glassfish, Tomcat
and Jetty. Also for learning. I realized during my experiments that it
does not matter in which servlet container a webapp runs. Always the
same stuff in web.xml and same directory structure.

Everything works fine for me when I deploy the webapp to Glassfish. I
use that one bundled with Netbeans. But when I deploy to Tomcat (also
bundled with Netbeans) it complains that it is not possible to load the
class "com.sun.jersey.spi.container.servlet.ServletContainerm" which I
reference in the web.xml for Jersey. I do not put any jar files into
WEB-INF/lib, because I found out that Maven will do this for me. And
yes, when I inspect the generated war with jar -tf there are all Jersey
jars (-core, -server, -json, -client) and a lot of others in the
WEB-INF/lib.

I tried to find com.sun.jersey.spi.container.servlet.ServletContainerm
in one of my Jersey dependenies[1], but I can't find. So I guess that
this special class is not in one of the artefacts I depend on. And I
guess that Glassfish has this class and other components somewhere built
in. When I download the Jersey bundled jar and put it by hand into
WEB-INF/lib/ then Tomcat can load the class and everything is fine. But
I don't want to do that by hand, because Maven should manage this.

I'm searching the web for a solution since some days and can't find one.
May someone help me and point out what I'm doing wrong? I'm not sure if
it is a problem with my Maven config or with Tomcat.

The whole source code is on GitHub[2]

[1] https://github.com/Weltraumschaf/Citer/blob/master/pom.xml
[2] https://github.com/Weltraumschaf/Citer

Kind regards
Sven