0
I use the following plugins to compile and run my web project in Intellij IDEA: pom.xml
//Código do pom.xml omitido
.
.
.
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
.
.
.
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>9090</port>
<path>/path</path>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
//Código do pom.xml omitido
and sometimes it keeps returning these errors, when I run the Tomcat(tomcat7:run). I say "sometimes" because it is only sometimes even, then I build the project and run, sometimes it works right away, but sometimes the error persists.
The mistake is basically package javax.servlet.http does not exist, but the Servlets api is definitely in the project, since sometimes it works and I can run the project smoothly. I don’t understand!!!
Follow the error printed in the console:
"C:\Program Files\Java\jdk1.8.0_131\bin\java" -Dmaven.multiModuleProjectDirectory=C:\Users\.... "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.4\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.4\plugins\maven\lib\maven3\bin\m2.conf" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.4\lib\idea_rt.jar=63077:C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.4\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.4\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2017.1.5 tomcat7:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building bi-cnn 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.2:run (default-cli) > process-classes @ bi-cnn >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ bi-cnn ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ bi-cnn ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 176 source files to C:\Users\.....\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/..../src/main/java/br/com/...../login/ClasseDeControleHttp.java:[10,26] package javax.servlet.http does not exist
[ERROR] /C:/Users/.../src/main/java/br/com/..../login/ControladorHttp.java:[6,26] package javax.servlet.http does not exist
[ERROR] /C:/Users/.../src/main/java/.../login/ControladorHttp.java:[22,5] cannot find symbol
symbol: class HttpSession
location: class br.com......ControladorHttp
[ERROR] /C:/Users/.../src/main/java/br/com/managedbeans/ManagedBean.java:[23,43] package jdk.internal.org.objectweb.asm.tree does not exist
.
.
.
[INFO] 39 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.795 s
[INFO] Finished at: 2017-08-28T13:58:21-03:00
[INFO] Final Memory: 18M/197M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project bi-cnn: Compilation failure: Compilation failure:
[ERROR] /C:/Users/.../src/main/java/br/com/.../Entidade.java:[10,26] package javax.servlet.http does not exist
.
.
.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
You informed the dependency
javax.servletin hispom.xml?– Homer Simpson
yes yes, the dependency is there, so much that it works sometimes yes, sometimes no.
– Henrique Santiago
Put the scope as
provided?– Homer Simpson
edited the post with dependency.
– Henrique Santiago
Run the Maven command with -X in front to run at debug level, maybe show more information.
– Marquezani