java ee api is missing on project classpath while using httpunit for servlet testing in maven

I want to run the servlet testing example available here using maven. Javaee web api should be declared as provided:

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>httpunit</groupId>
        <artifactId>httpunit</artifactId>
        <version>1.7</version>
        <scope>test</scope>
    </dependency>

However, one of the tests in the example throws ServletException. NetBeans complains that java ee api is missing on project classpath. How does one solve this issue?

EDIT

It is not a NetBeans issue, it is a maven issue.

Upvotes: 2

Views: 3218

Answers (2)

Now this is the most debilitating issue I have ever faced in my Java days. And it is followed by the most ridiculous workaround I have ever seen, ever:

<dependency>
    <groupId>httpunit</groupId>
    <artifactId>httpunit</artifactId>
    <version>1.7</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-web-api</artifactId>
    <version>6.0</version>
    <scope>provided</scope>
</dependency>

Yes, permute the declaration of dependencies in the pom.xml (see here for "why") and make javaee-web-api last.

Upvotes: 9

Augusto
Augusto

Reputation: 29927

It means that maven (or netbeans...I haven't used netbeans in 10 years), couldn't download or find that artifact in the local repository.

The scope provided means: I need the jar to compile my source code, but don't bundle the jar in the final package.

Upvotes: 0

Related Questions