-1

Why do I have to import javax package manually ?

I've created a Maven Web Project like this:

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp

Then I added this config in my POM (so eclipse recognize it as a web project):

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <configuration>
        <wtpmanifest>true</wtpmanifest>
        <wtpapplicationxml>true</wtpapplicationxml>
        <wtpversion>2.0</wtpversion>
    </configuration>
</plugin>

(mvn clean compile package) (mvn eclipse:eclipse)

After that I fix the Project Facets where I change the java version from 1.4 to 1.6 ...

So far so good but when I create a Servlet eclipse can't find javax package. (I added Oracle Web Logic as Server so Eclipse can find the package from there, but aint working.

I did the last thing 'cos of this thread --> How do I import the javax.servlet API in my Eclipse project?

To make it work I added manually the javax package from the Oracle Weblogic Server. But I think this absolutly sucks and I'm sure am doing more than 1 thing wrong.

Any ideas ?

Weblogic 10.3 Eclipse Helios 3.6 Maven 3

Community
  • 1
  • 1
code4jhon
  • 5,725
  • 9
  • 40
  • 60
  • you have to add the servlet dependencies to the `pom.xml` file, what you added does **not** have anything to do with a *web project*, it just creates the Eclipse specific files `.classpath, .project`, that is how Maven works, details are easily found in the Internet and are way to involved for this Q&A format, unless they are very specific to a single thing that is a problem, this question is way **Too Broad**. –  Nov 20 '13 at 17:33
  • Dependency added, worked. Thanks. – code4jhon Nov 20 '13 at 17:38

1 Answers1

1

The answer was as Jarrod said in the comment dead simple, just declare de dependency in the pom.

<dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>servlet-api</artifactId>
  <version>2.5</version>
  <scope>provided</scope>
</dependency>
code4jhon
  • 5,725
  • 9
  • 40
  • 60