Guice servlet's 'servlet-api' dependency should be declared in 'provided'
scope. The sematics of this are described here:
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
In short, a provided dependency is fetched and put in the compile and test
classpaths, but is not packaged, because it is expected to be provided at
runtime by the container/jvm/etc..
...
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>runtime</scope>
</dependency>
...
In this case, the inaccuracy in the pom is not such a big deal. An easy way
around this for guice-servlet users is to declare the servlet-api in their
pom as a provided dependency. Maven will then ignore the servlet-api
dependency during packaging. A purist would say declaring a transitive
dependency as a direct dependency in a parent project to make up for
inaccurate dependency declarations in a library isn't right because the
dependent project may not really use any classes in the dependency.
However, when using guice-servlet, the chances you don't depend on the
servlet api are slim, since the whole point is that you using it for writing
guicy servlet based apps.
-Brandon
On Thu, Mar 11, 2010 at 7:16 PM, Dhanji R. Prasanna <[email protected]>wrote:
>
>
> On Fri, Mar 12, 2010 at 7:10 AM, Brandon Atkinson <
> [email protected]> wrote:
>
>> I have had this problem before.
>>
>> Are you using maven by any chance?
>>
>> If so, make sure that you've made servlet-api a provided dependency.
>>
>> For some reason, guice-servlet's pom declares that it has a compile time
>> dependency on servlet-api. This causes the servlet-api classes to be loaded
>> into your war. Since there are two defined copies of the servlet api
>> classes (in two different class loaders) a CCE occurs.
>>
>
> messy =(
>
> what do you suggest we do to our pom to fix this?
>
> Dhanji.
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-guice%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.