I'm here to ask a question that others already asked but every answers I found don't fix my problem.
I'm currently using struts2
with maven
and jetty-maven-plugin
, but eclipse is throwing errors about my JSPs
files saying that it can't find the /struts-tag.tld
file.
Also, when I launch the jetty:run command, it says:
[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.3.0.M2:run (default-cli) on project starservice: Execution default-cli of goal org.eclipse.jetty:jetty-maven-plugin:9.3.0.M2:run failed: An API incompatibility was encountered while executing org.eclipse.jetty:jetty-maven-plugin:9.3.0.M2:run: java.lang.NoSuchMethodError: org.apache.logging.log4j.ThreadContext.getThreadContextMap()Lorg/apache/logging/log4j/spi/ReadOnlyThreadContextMap;
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.eclipse.jetty:jetty-maven-plugin:9.3.0.M2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/user/.m2/repository/org/eclipse/jetty/jetty-maven-plugin/9.3.0.M2/jetty-maven-plugin-9.3.0.M2.jar
[ERROR] urls[1] = file:/C:/Users/user/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.1.1/sisu-inject-bean-2.1.1.jar
[ERROR] urls[2] = file:/C:/Users/user/.m2/repository/org/sonatype/sisu/sisu-guice/2.9.4/sisu-guice-2.9.4-no_aop.jar
[...]
[ERROR] urls[45] = file:/C:/Users/user/.m2/repository/org/apache/taglibs/taglibs-standard-impl/1.2.1/taglibs-standard-impl-1.2.1.jar
[ERROR] urls[46] = file:/C:/Users/user/.m2/repository/javax/transaction/javax.transaction-api/1.2/javax.transaction-api-1.2.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
And the pom
<groupId>xx.xx</groupId>
<artifactId>xxxxx</artifactId>
<packaging>war</packaging>
<version>1</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.5.10.1</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.7.Final</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.8</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<finalName>starserv</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warName>${project.artifactId}</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.0.M2</version>
<configuration>
<scanIntervalSeconds>5</scanIntervalSeconds>
<war>${project.basedir}/target/${project.artifactId}.war</war>
<webApp>
<webInfIncludeJarPattern>^$</webInfIncludeJarPattern>
<containerIncludeJarPattern>^$</containerIncludeJarPattern>
</webApp>
</configuration>
</plugin>
</plugins>
</build>
Does anyone know how to fix it? Because nothing's working.
I've found the problem.
You just need to add the log4j api to the same version of log4j in struts. For me it was
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.8.1</version>
</dependency>
In hope It will help someone!