0

create my first project in Spring and I have some problem. I use JavaConfig to configuration my project and when I start I have this error :

Error:(6, 8) java: cannot access javax.servlet.ServletException class file for javax.servlet.ServletException not found 

I now I have to add javax.servlet api but I do not know where to do it. I create my project in IntelliJ Ultimate 2017.

2 Answers 2

5

It seems like you haven't included the javax.servlet.jar library in your project.

If you're not using any dependency managers, you should add 'javax.servlet.jar' file to your classpath manually with Intellij IDEA: Project Structure (Ctrl+Alt+Shift+S) -> Libraries -> New Project Library -> Java. This jar-file can be downloaded here: http://central.maven.org/maven2/javax/servlet/javax.servlet-api/3.0.1/javax.servlet-api-3.0.1.jar

If you're using Maven, then just add this dependency to maven pom.xml file.

<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency> 
Sign up to request clarification or add additional context in comments.

Comments

0

ran into a similar problem, I already had a dependency implemented

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

However, the problem was solved by changing the version of

<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>6.0.4</version> </dependency> 

to:

<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>5.2.9.RELEASE</version> </dependency> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.