3

I am starting on a legacy project and trying to get it to build using Maven. I'm using Eclipse EE and Tomcat v7.0. The error in the Title line above arises when I run "mvn package" in Terminal. This error is really stumping me because in my pom.xml file I have the following dependency

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>

I've also checked in the Properties>Targeted Runtimes and made sure Tomcat v7.0 is the selected runtime. I'm fairly certain it's a problem with my eclipse environment, and would like some suggestions on how to fix it.

EDIT: Here's some additional information. The first output after I run "mvn package" is

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project myProject: Compilation failure: Compilation failure:

This is followed by another strange error that I forgot to include in the original posting. I say it's weird because, like the package javax.servlet, org.apache.catalina should also be included in tomcat

[ERROR] /path/to/Main.java:[7,26] error: package org.apache.catalina does not exist

Also, I think I mixed up the meaning of legacy project, because this isn't an old project. It's just a project that already had a lot of work done on that I'm now helping the original creator with.

almel
  • 7,178
  • 13
  • 45
  • 58

2 Answers2

5

The dependency you're missing is probably the Servlet API.

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
</dependency>

Be sure to import the correct version of the API. For a legacy project, that could be an older version than 2.5.

As mentionned by Grzegorz, you should also use the scope provided since the Servlet API should be provided by your application server (e.g. Tomcat).

LaurentG
  • 11,128
  • 9
  • 51
  • 66
0

Add server runtime to your project. Example - for Tomcat

1 - right click on your project

2- select build path

3- Go to Libraries tab

4- Add Library

5- Select Server Run time

6- Here you should get the Apache Tomcat

enter image description here

If you don't get Apache Tomcat in here you need to add your server in Project Facets as below -

1- right click on your project

2- Select Project Facets

3- If you dont get options click on the link 'Convert to faceted form'

4- Go to Runtime tab at right side and select your runtime

enter image description here

Puneet Pandey
  • 960
  • 2
  • 14
  • 28