Search code examples
javamaven-2mavenopenejb

Why servlet-api.jar turns its status from test to compile?


This is what I have in pom.xml:

<dependency>
  <groupId>com.sun.jersey.jersey-test-framework</groupId>
  <artifactId>jersey-test-framework-grizzly</artifactId>
  <version>1.4</version>
  <scope>test</scope>
</dependency>

This is what I see after mvn --debug war:war:

[...]
[DEBUG]    com.sun.jersey.jersey-test-framework:jersey-test-framework-grizzly:jar:1.4:test
[DEBUG]       com.sun.jersey.jersey-test-framework:jersey-test-framework-core:jar:1.4:test
[DEBUG]          org.glassfish:javax.servlet:jar:3.0-b66:test
[DEBUG]       com.sun.grizzly:grizzly-servlet-webserver:jar:1.9.18-i:test
[DEBUG]          com.sun.grizzly:grizzly-http:jar:1.9.18-i:test
[DEBUG]             com.sun.grizzly:grizzly-framework:jar:1.9.18-i:test
[DEBUG]             com.sun.grizzly:grizzly-rcm:jar:1.9.18-i:test
[DEBUG]             com.sun.grizzly:grizzly-portunif:jar:1.9.18-i:test
[DEBUG]          com.sun.grizzly:grizzly-http-servlet:jar:1.9.18-i:test
[DEBUG]             com.sun.grizzly:grizzly-utils:jar:1.9.18-i:test
[DEBUG]          javax.servlet:servlet-api:jar:2.5:compile
[...]

Pay attention to the last line. Why it's not "test", but "compile"?

ps. Indeed it's very weird. This is my complete pom.xml (sorry, it's not short):

[...]
<dependencies>
  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.7</version> <!-- 10 Sep 2010 -->
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>xom</groupId>
    <artifactId>xom</artifactId>
    <version>1.2.5</version> <!-- 13 Oct 2010 -->
  </dependency>
  <dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-all</artifactId>
    <version>1.8.5</version> <!-- 9 Oct 2010 -->
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-io</artifactId>
    <version>1.3.2</version> <!-- 9 Oct 2010 -->
    <scope>test</scope>
  </dependency>
  <dependency>
    <groupId>joda-time</groupId>
    <artifactId>joda-time</artifactId>
    <version>1.6.2</version> <!-- 12 Oct 2010 -->
  </dependency>
  <dependency>
    <groupId>commons-httpclient</groupId>
    <artifactId>commons-httpclient</artifactId>
    <version>3.1</version> <!-- 2 Nov 2010 -->
  </dependency>
  <dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-server</artifactId>
    <!-- version see below in dependencyManagement section -->
  </dependency>
  <dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-client</artifactId>
    <!-- version see below in dependencyManagement section -->
  </dependency>
  <dependency>
    <groupId>com.sun.jersey.jersey-test-framework</groupId>
    <artifactId>jersey-test-framework-grizzly</artifactId>
    <!-- version see below in dependencyManagement section -->
  </dependency>
  <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <!-- version see below in dependencyManagement section -->
  </dependency>
  <dependency>
    <groupId>org.apache.openejb</groupId>
    <artifactId>openejb-ejbd</artifactId>
    <!-- version see below in dependencyManagement section -->
  </dependency>
  <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-jdk14</artifactId>
    <!-- version see below in dependencyManagement section -->
  </dependency>
  <dependency>
    <groupId>hsqldb</groupId>
    <artifactId>hsqldb</artifactId>
    <!-- version see below in dependencyManagement section -->
  </dependency>
  <dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>6.0</version> <!-- 9 Oct 2010 -->
    <scope>provided</scope>
  </dependency>
</dependencies>

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-core</artifactId>
      <version>${jersey.version}</version>
    </dependency>
    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-server</artifactId>
      <version>${jersey.version}</version>
    </dependency>
    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-client</artifactId>
      <version>${jersey.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.sun.jersey.jersey-test-framework</groupId>
      <artifactId>jersey-test-framework-grizzly</artifactId>
      <version>${jersey.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-entitymanager</artifactId>
      <version>${hibernate.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.openejb</groupId>
      <artifactId>openejb-ejbd</artifactId>
      <version>3.1.3</version> <!-- 26 October 2010 -->
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-jdk14</artifactId>
      <version>1.4.2</version> <!-- 29 oct 2010 -->
    </dependency>
    <dependency>
      <groupId>hsqldb</groupId>
      <artifactId>hsqldb</artifactId>
      <version>1.8.0.10</version> <!-- 12 October 2010 -->
      <scope>test</scope>
    </dependency>
  </dependencies>
</dependencyManagement>
[...]

This is how maven-war-plugin is configured:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>2.0</version>
  <configuration>
    <archive>
      <manifestEntries>
        <SCM-Revision>${buildNumber}</SCM-Revision>
      </manifestEntries>
    </archive>
  </configuration>
</plugin>

Solution

  • This is what I've done to solve the problem:

    [...]
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jsp-api</artifactId>
      <version>2.0</version>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>javax.servlet</groupId>
          <artifactId>servlet-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    [...]