Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven can not find package and symbol

Tags:

java

maven

I have an app with these class: (part of class):

@SessionScoped
@Named
public class UserSessionBean implements Serializable {

    @javax.ws.rs.core.Context private HttpServletRequest httpRequest;

and during mvn compile, I have this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.1:compile (default-compile) on project highway-web: Compilation failure: Compilation failure:
[ERROR] /home/kelevra/java/git/ttkHighway/highway-web/src/main/java/com/kmware/ttk/highway/beans/session/UserSessionBean.java:[28,25] package javax.servlet.http does not exist
[ERROR] 
[ERROR] /home/kelevra/java/git/ttkHighway/highway-web/src/main/java/com/kmware/ttk/highway/beans/session/UserSessionBean.java:[40,38] cannot find symbol
[ERROR] symbol  : class HttpServletRequest
[ERROR] location: class com.kmware.ttk.highway.beans.session.UserSessionBean
[ERROR] -> [Help 1]

While making in IDEA there is no such problems. What it could be?

like image 519
Kirill Bazarov Avatar asked Nov 19 '12 15:11

Kirill Bazarov


1 Answers

Java file UserSessionBean can not find the class HttpServletRequest.

You should check the dependencies declared in the pom file. Make sure that you include

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

Could you try a mvn clean install and see if it produces the same error.

P.S. Are you running the project from console or from an IDE.

like image 116
javaG Avatar answered Oct 19 '22 19:10

javaG