I have a rest Spring Boot REST API that I want to test. I can run the tests manually in Eclipse (without maven and by running the application as JUnit test) and it runs fine and displays the results, but mvn test does not "work" as you will find out below.
Here is my POM file:
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>org.demo</groupId>
<artifactId>rest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>UserRegistrationServices</name>
<description>RESTful API</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- Junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- Spring dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- To deploy to external servlet container -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- For Spring Boot testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>2.4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>json-schema-validator</artifactId>
<version>2.4.1</version>
<scope>test</scope>
</dependency>
<!-- For returning objects as JSON -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.5.4</version><!--$NO-MVN-MAN-VER$ -->
</dependency>
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>jackson-xml-databind</artifactId>
<version>0.6.2</version>
</dependency>
<!-- To decode Base64 data -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
</dependencies>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/snapshot</url>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
This is the result of mvn test:
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building UserRegistrationServices 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # rest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # rest ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 9 source files to C:\Users\pmandayam\git\UserRegistrationServices\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # rest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\pmandayam\git\UserRegistrationServices\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # rest ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to C:\Users\pmandayam\git\UserRegistrationServices\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) # rest ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.768 s
[INFO] Finished at: 2015-07-28T12:07:41-05:00
[INFO] Final Memory: 24M/212M
[INFO] ------------------------------------------------------------------------
Here is a segment of my TestController.java class in src/test/java:
#Test
public void f_findByUsername() {
// Finding user with username 'user1username'
given().auth().basic("User1username", "Testpassword").when().get(
"http://localhost:8080/users/get/ByUsername?username=User1username")
.then().assertThat().body("username", is("User1username"));
}
At the top of the TestController class I have these annotations:
#RunWith(SpringJUnit4ClassRunner.class)
#SpringApplicationConfiguration(classes = Application.class)
#WebAppConfiguration
/* Tells the embedded Tomcat server to start on a random, open port */
#IntegrationTest("server.port:0")
#FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestController {....}
I'm not sure whats wrong. I don't have the surefire plugin but its looking for that it seems.
The code in the class you named TestController isn't a controller, it's a test, but the convention says that it's a controller (perhaps used in testing). By default, Surefire will be looking for tests matching *Test; rename the class to ControllerTest.
Use the below maven jar. It fixed my issue.
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
try checking if you are using the correct package for #Test annotation. In Spring Boot 2.3.6 is org.junit.jupiter.api.Test
Even if this is not recommended (as not standard), you can configure the maven surefire plugin too, as follows:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Test*.java</include>
</includes>
</configuration>
</plugin>
</plugins>
Edit: Wildcard added before /Test*.java
As this question populates first on search engines I thought it would be helpful for the people looking for the solution for the wired behavior of SpringBoot from version 2.4 onwards.
Problem - When you migrate your SpringBoot project from older version to newer like 2.5.x then the existing junit test cases are ignored by maven.
Reason - SpringBoot has been migrated to junit5 and thats why maven is ignoring junit4 test cases. To see detailed test dependencies explore the pom for spring-boot-starter-test.
Solution 1 - Either you write your test cases in junit5 with class level annotation #SpringBootTest and follow Junit5 rules.
Solution 2 - Or you can use junit-vintage dependency in your project to run both junit4 and junit5 test cases together.
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.6.3</version>
<scope>test</scope>
</dependency>
Another reason this may be happening is to have declared another surefire plugin in your pom. In my case I migrated an app to spring boot and left this in the pom.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>false</testFailureIgnore>
<includes>
<include>**/*Test*.java</include>
</includes>
</configuration>
<executions>
<execution>
<phase>clean</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
Spring boot test were executed after remove this part from the pom.
If none of the above works for you and you are using junit 5 with appropriate annotations, issue might be with Maven Surefire and Failsafe plugins.
This is because of some conflict between the JUnit Surefire provider and the JUnit support in the Surefire 2.22.0 plugin release.
Update your POM to require the 2.22.0 releases of the Maven Surefire and Failsafe plugins.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
</plugin>
</plugins>
</build>
Refer here for an example
Adding org.junit.jupiter.api.Test worked for me
With Spring boot 2.5.0
junit-vintage-engine jar isn't added, hence any org.junit.Test won't be run.
Only org.junit.jupiter.api.Test seems to run.
After Adding this jar (junit-vintage-engine) all my old tests(org.junit.Test) run absolutely fine.
This issue can happen because your test class is not public.
this works for my problem to update springboot 2.3.9 to 2.4.3
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.6.3</version>
<scope>test</scope>
</dependency>
If you are facing this issue with spring boot 3, I had to upgrade my surefire plugin version to 3.0.0-M8
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M8</version>
</plugin>
For other people who still have the issue. Personally I resolved that by removing :
<packaging>pom</packaging>
from the pom.xml file.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 months ago.
Improve this question
I'm trying to create an app using the microservices architecture. So now I'm creating the user service, but I faced with a small problem. I use flyway for database migrations and it doesn't work.
So, I have the big global project that looks like this:
And I also have user service project inside of this global project
In the user_service project I installed some maven dependencies and configured the plugin for flyway migrations.
Heres user_service pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>user_service</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>18</maven.compiler.target>
<flyway.user>postgres</flyway.user>
<flyway.password>4122</flyway.password>
<flyway.schemas>working_schema</flyway.schemas>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty-shaded</artifactId>
<version>1.24.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.24.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.24.0</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>com.rabbitmq</groupId>
<artifactId>amqp-client</artifactId>
<version>5.16.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.1.6.Final</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.5.1</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>9.10.0</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.196</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>4.0.0</version>
</dependency>
</dependencies>
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.6.2</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>4.0.3</version>
<configuration>
<url>jdbc:postgresql://localhost:5432/postogramm_users</url>
<user>postgres</user>
<password>4122</password>
<schemas>
<schema>working_schema</schema>
</schemas>
</configuration>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.9.0:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.24.0:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
But when I try to migrate my database by this command:
mvn flyway:migrate
It says me that
Unable to resolve location filesystem:A:/java/projects/postogramm/src/main/java/org/postogramm/service/user_service/src/main/resource
s/db/migration
So what can be the problem? If you know, please tell me. I'd really appreciate it!
Full log of flyway migration:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: windows
[INFO] os.detected.arch: x86_64
[INFO] os.detected.version: 10.0
[INFO] os.detected.version.major: 10
[INFO] os.detected.version.minor: 0
[INFO] os.detected.classifier: windows-x86_64
[INFO]
[INFO] ----------------------< org.example:user_service >----------------------
[INFO] Building user_service 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The artifact org.hibernate:hibernate-core:pom:6.1.6.Final has been relocated to org.hibernate.orm:hibernate-core:pom:6.1.6.Final
[INFO]
[INFO] --- flyway-maven-plugin:4.0.3:migrate (default-cli) # user_service ---
[INFO] Flyway 4.0.3 by Boxfuse
[INFO] Database: jdbc:postgresql://localhost:5432/postogramm_users (PostgreSQL 14.4)
[WARNING] Unable to resolve location filesystem:A:/java/projects/postogramm/src/main/java/org/postogramm/service/user_service/src/main/resource
s/db/migration
[WARNING] Unable to resolve location filesystem:A:/java/projects/postogramm/src/main/java/org/postogramm/service/user_service/src/main/resource
s/db/migration
[WARNING] Unable to resolve location filesystem:A:/java/projects/postogramm/src/main/java/org/postogramm/service/user_service/src/main/resource
s/db/migration
[INFO] Successfully validated 0 migrations (execution time 00:00.010s)
[INFO] Current version of schema "working_schema": << Empty Schema >>
[INFO] Schema "working_schema" is up to date. No migration necessary.
[WARNING] Unable to resolve location filesystem:A:/java/projects/postogramm/src/main/java/org/postogramm/service/user_service/src/main/resource
s/db/migration
[WARNING] Unable to resolve location filesystem:A:/java/projects/postogramm/src/main/java/org/postogramm/service/user_service/src/main/resource
s/db/migration
[WARNING] Unable to resolve location filesystem:A:/java/projects/postogramm/src/main/java/org/postogramm/service/user_service/src/main/resource
s/db/migration
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.806 s
[INFO] Finished at: 2022-12-12T15:03:46+03:00
[INFO] ------------------------------------------------------------------------
Take a look on the marked points I have done for your project structure
You can't have this structure since this is not a standard maven archetype.
I believe you need to remove the marked with green directories and leave out only the red representing the specific user_service java classes and resources.
I have to override dependency in maven plugin: org.apache.maven.plugins:maven-site-plugin:maven-plugin:3.9.1 and in this plugin I have dependency commons-beanutils:commons-beanutils:jar:1.7.0 and I have to override version to ver 1.9.4 and I added dependencies tag with new version of commons-utils but it still doesn't override. When I run mvn dependency:resolve-plugins I still see old version
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.9.1</version>
<dependencies>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>
</dependencies>
</plugin>
[INFO] org.apache.maven.plugins:maven-site-plugin:maven-plugin:3.3:runtime
[INFO] commons-beanutils:commons-beanutils:jar:1.7.0
As we can see in this log common beanutils is nessesery
[INFO] --- maven-dependency-plugin:3.1.2:resolve-plugins (default-cli) # everything ---
Downloading from central: https://repo.maven.apache.org/maven2/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.pom
Downloaded from central: https://repo.maven.apache.org/maven2/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.pom (357 B at 645 B/s)
Downloading from central: https://repo.maven.apache.org/maven2/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar
Downloaded from central: https://repo.maven.apache.org/maven2/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar (189 kB at 586 kB/s)
And I found where this beanutils is used
org.apache.maven.reporting:maven-reporting-impl:2.3
commons-validator:commons-validator:1.3.1
commons-beanutils:commons-beanutils:1.7.0
maven dependency tree doesn't have any beanutils
and plugins which I'm using are:
org.codehaus.mojo.jaxb2-maven-plugin.2.3.1
org.apache.maven.plugin
org.springframework.boot.spring-boot-maven-plugin
org.jacoco.jacoco-maven-plugin.0.8.7
Thanks in advance for help
You can double check your dependencies one by one to find more dependencies which are using maven-reporting-impl:2.3. Somehow I think what could be reason for that is jaxb2-maven-plugin.2.3.1. The maven-checkstyle-plugin is defined in the pom of the plugin. It has a dependence to maven-reporting-impl:2.3
jaxb2-maven-plugin
<reporting>
<plugins>
<!-- Apache plugins in alphabetical order -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
<skip>true</skip>
<configLocation>config/maven_checks.xml</configLocation>
<headerLocation>config/maven-header.txt</headerLocation>
</configuration>
</plugin>
</plugins>
</reporting>
maven-checkstyle-plugin
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>2.3</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
</exclusion>
</exclusions>
</dependency>
You are not possible to override as it comes from another project
I just migrated my Vaadin project from 7.7.6 to 8.0.5. First I wanted to use the Vaadin8 migration tool but my IDE used too many vaadin.* imports so I just did it manually. After hours of work (compatibility package imports) the maven build worked again and I wanted to open the WebApp in my browser but I got the "Failed to load the Widgetset..." error message. I thought that I have to recompile the Widgetset but the vaadin-maven-plugin throws an error:
EDIT 04.05.2017: I removed the QueryDSL dependency "querydsl-apt" and the widgetset is compiling... Does anyone know why this happens?
c:\dev\workspace_intellij\wsi>mvn vaadin:compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building wsi 2.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.querydsl:querydsl-core:jar:3.7.4 is missing, no dependency information available
[INFO]
[INFO] --- vaadin-maven-plugin:8.0.5:compile (default-cli) # wsi ---
[INFO] auto discovered modules [WsiWidgetset]
[INFO] Using com.vaadin:vaadin-client-compiler version 8.0.5
[INFO] Compiling module WsiWidgetset
[INFO] [ERROR] An internal compiler exception occurred
[INFO] com.google.gwt.dev.jjs.InternalCompilerException: Error constructing Java AST
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder.translateException(GwtAstBuilder.java:3944)
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder.getInternalCompilerException(GwtAstBuilder.java:4351)
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder.createMembers(GwtAstBuilder.java:4043)
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder.processImpl(GwtAstBuilder.java:3883)
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder.process(GwtAstBuilder.java:3918)
[INFO] at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater$UnitProcessorImpl.process(CompilationStateBuilder.java:129)
[INFO] at com.google.gwt.dev.javac.JdtCompiler$CompilerImpl.process(JdtCompiler.java:384)
[INFO] at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:470)
[INFO] at com.google.gwt.dev.javac.JdtCompiler.doCompile(JdtCompiler.java:1092)
[INFO] at com.google.gwt.dev.javac.CompilationStateBuilder$CompileMoreLater.compile(CompilationStateBuilder.java:325)
[INFO] at com.google.gwt.dev.javac.CompilationStateBuilder.doBuildFrom(CompilationStateBuilder.java:548)
[INFO] at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:479)
[INFO] at com.google.gwt.dev.javac.CompilationStateBuilder.buildFrom(CompilationStateBuilder.java:465)
[INFO] at com.google.gwt.dev.cfg.ModuleDef.getCompilationState(ModuleDef.java:423)
[INFO] at com.google.gwt.dev.Precompile.precompile(Precompile.java:222)
[INFO] at com.google.gwt.dev.Precompile.precompile(Precompile.java:202)
[INFO] at com.google.gwt.dev.Precompile.precompile(Precompile.java:143)
[INFO] at com.google.gwt.dev.Compiler.compile(Compiler.java:204)
[INFO] at com.google.gwt.dev.Compiler.compile(Compiler.java:155)
[INFO] at com.google.gwt.dev.Compiler.compile(Compiler.java:144)
[INFO] at com.google.gwt.dev.Compiler$1.run(Compiler.java:118)
[INFO] at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:55)
[INFO] at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:50)
[INFO] at com.google.gwt.dev.Compiler.main(Compiler.java:125)
[INFO] Caused by: java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.lookup.MethodBinding.isDefaultMethod()Z
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder.createMethod(GwtAstBuilder.java:4138)
[INFO] at com.google.gwt.dev.jjs.impl.GwtAstBuilder.createMembers(GwtAstBuilder.java:4033)
[INFO] ... 21 more
[INFO] [ERROR] at SVGPathSegLinetoVerticalAbs.java(30): public interface SVGPathSegLinetoVerticalAbs extends SVGPathSeg
[INFO] org.eclipse.jdt.internal.compiler.ast.TypeDeclaration
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.929 s
[INFO] Finished at: 2017-05-02T15:04:34+02:00
[INFO] Final Memory: 35M/434M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.vaadin:vaadin-maven-plugin:8.0.5:compile (default-cli) on project wsi: Command [[
[ERROR] C:\Program Files\Java\jdk1.8.0_102\jre\bin\java -Xmx1G -Dgwt.persistentunitcache=false com.google.gwt.dev.Compiler -logLevel INFO -style OBF -war c:\dev\workspace_intellij\wsi\target\classes\VAADIN\widgetsets -localWorkers 4 -failOnError -XfragmentCount -1 -sourceLevel auto -gen c:\dev\workspace_intellij\wsi\target\.generated WsiWidgetset
[ERROR] ]] failed with status 1
[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/MojoExecutionException
My pom.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
[...]
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<vaadin.version>8.0.5</vaadin.version>
<vaadin.plugin.version>8.0.5</vaadin.plugin.version>
<vaadin.charts.version>4.0.0</vaadin.charts.version>
<vaadin.spring.version>2.0.1</vaadin.spring.version>
<vaadin.context.menu.version>2.0.0</vaadin.context.menu.version>
<vaadin.fontawesome.version>1.3.4</vaadin.fontawesome.version>
<vaadin.componentrenderer.version>2.0.0</vaadin.componentrenderer.version>
[...]
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
<version>${vaadin.spring.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-push</artifactId>
</dependency>
<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>fontawesomelabel</artifactId>
<version>${vaadin.fontawesome.version}</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-server-jndi</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>4.0.1</version><!--$NO-MVN-MAN-VER$-->
</dependency>
<dependency>
<groupId>org.imgscalr</groupId>
<artifactId>imgscalr-lib</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-core</artifactId>
<version>4.1.4</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>4.1.4</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>4.1.4</version>
</dependency>
<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>mediaelementjs-player</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>org.vaadin.patrik</groupId>
<artifactId>GridFastNavigation</artifactId>
<version>0.2.1</version>
</dependency>
<!-- Eigenes Kompilat, da Sourcen nicht attached waren -->
<dependency>
<groupId>org.vaadin.addons.lazyquerycontainer</groupId>
<artifactId>vaadin-lazyquerycontainer</artifactId>
<version>7.6.1.3</version>
</dependency>
<!-- WIDGETSET -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-charts</artifactId>
<version>${vaadin.charts.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-context-menu</artifactId>
<version>${vaadin.context.menu.version}</version>
</dependency>
<dependency>
<groupId>de.datenhahn.vaadin</groupId>
<artifactId>componentrenderer</artifactId>
<version>${vaadin.componentrenderer.version}</version>
</dependency>
<!-- WIDGETSET END -->
[...]
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-compatibility-server</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-compatibility-client</artifactId>
</dependency>
</dependencies>
<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${vaadin.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<!-- Clean up also any pre-compiled themes -->
<configuration>
<filesets>
<fileset>
<directory>src/main/webapp/VAADIN/themes</directory>
<includes>
<include>**/styles.css</include>
<include>**/styles.scss.cache</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- Exclude some unnecessary files generated by the GWT compiler. -->
<packagingExcludes>WEB-INF/classes/VAADIN/gwt-unitCache/**, WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.plugin.version}</version>
<configuration>
<extraJvmArgs>-Xmx1G</extraJvmArgs>
</configuration>
<executions>
<execution>
<goals>
<goal>update-theme</goal>
<goal>update-widgetset</goal>
<goal>compile</goal>
<!-- Comment out compile-theme goal to use on-the-fly theme compilation -->
<goal>compile-theme</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
My Widgetset.gwt.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module>
<!--
Uncomment the following to compile the widgetset for one browser only.
Multiple browsers can be specified as a comma separated list. The supported user agents at the moment of writing were:
ie8,ie9,gecko1_8,safari,opera
The value gecko1_8 is used for Firefox and safari is used for webkit based browsers including Google Chrome.
-->
<!-- <set-property name="user.agent" value="safari"/> -->
<!--
To enable SuperDevMode, uncomment this line.
See https://vaadin.com/wiki/-/wiki/Main/Using%20SuperDevMode for more information and instructions.
-->
<!-- <set-configuration-property name="devModeRedirectEnabled" value="true" /> -->
<!--<inherits name="com.vaadin.DefaultWidgetSet"/>-->
<inherits name="com.vaadin.v7.Vaadin7WidgetSet" />
<inherits name="com.vaadin.addon.charts.Widgetset"/>
<inherits name="de.datenhahn.vaadin.componentrenderer.ComponentRendererWidgetSet"/>
<inherits name="com.vaadin.contextmenu.WidgetSet" />
<inherits name="org.vaadin.patrik.GridFastNavigation" />
</module>
Does anyone know whats going wrong?
Best regards
Generally NoSuchMethodError indicates a classpath problem, in the sense that the library that you have in your cp when writing the code (and your IDE is compiling inline your code to check it for errors) is a different version from the one in the maven compile-time cp. So a method that is available when writing the code is no longer found when compiling or running the code (see late binding).
In your particular case, this is most likely an indirect consequence due to the QueryDSL dependency that uses a JDT version, and the Vaadin maven plugin using a GWT plugin that references another JDT version.
As a workaround, you can explicitly exclude the JDT transitive dependency from either your QueryDSL version or the Vaadin maven plugin, and try to see if that works.
P.S. To see who exactly is referencing the JDT dependency you can run mvn dependency:tree
That worked> Thanks a lot. I added :
<exclusion>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
</exclusion>
in my pom dependency.
I am working on a maven project and i need to exclude all transitive dependencies. I have seen the "exclude"tag that is used inside "dependency"tag. But i have a lot of dependencies and writing this tag in every dependency is a huge task. So there is any method where i can exclude all transitive dependencies in a much easier way?
Ever since Maven 3.2.1, you can use wildcards in dependency exclusions.
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>3.1.0</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
...
</dependencies>
You will still have to insert the wildcard exclusion into every single dependency though.
Here's an example pom with a Groovy script (executed through the Groovy Maven Plugin) that excludes all transitive dependencies:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.test</groupId>
<artifactId>non-transitive-deps</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>exclude-transitive-deps</id>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
def exclusion = new org.apache.maven.model.Exclusion();
exclusion.groupId='*'
exclusion.artifactId='*'
project.dependencies.each{
d -> d.addExclusion(exclusion)
}
</source>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
</dependencies>
</project>
Output for mvn dependency:tree:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # non-transitive-deps ---
[INFO] org.test:non-transitive-deps:jar:1.0-SNAPSHOT
[INFO] \- org.springframework:spring-orm:jar:4.3.7.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:4.3.7.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:4.3.7.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.3.7.RELEASE:compile
[INFO] \- org.springframework:spring-tx:jar:4.3.7.RELEASE:compile
Output for mvn validate dependency:tree:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # non-transitive-deps ---
[INFO] org.test:non-transitive-deps:jar:1.0-SNAPSHOT
[INFO] \- org.springframework:spring-orm:jar:4.3.7.RELEASE:compile
So while this groovy script solves your problem, it only does so when a Maven lifecycle phase is executed (not when you trigger a plugin goal directly). validate is the earliest stage in the lifecycle, long before dependency resolution takes place.
And no, I am not aware of any less verbose solution.
I want to create an executable war/jar like explained in the tomcat7-maven-plugin documentation: http://tomcat.apache.org/maven-plugin-2.2/executable-war-jar.html
But i get a build failure (NullPointerException):
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Gothic Mod Manager 0.1.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.2:exec-war (default-cli) # gmm >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # gmm ---
[INFO] Using 'ISO-8859-1' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # gmm ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # gmm ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # gmm ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # gmm ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) # gmm ---
[INFO] Packaging webapp
[INFO] Assembling webapp [gmm] in [C:\***\GMM\target\gmm-0.1.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\***\GMM\src\main\webapp]
[INFO] Webapp assembled in [963 msecs]
[INFO] Building war: C:\***\GMM\target\gmm-0.1.1-SNAPSHOT.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO]
[INFO] --- tomcat7-maven-plugin:2.2:exec-war-only (executable) # gmm ---
[INFO]
[INFO] <<< tomcat7-maven-plugin:2.2:exec-war (default-cli) # gmm <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.2:exec-war (default-cli) # gmm ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.854s
[INFO] Finished at: Mon Jun 09 18:55:09 CEST 2014
[INFO] Final Memory: 30M/223M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:exec-war (default-cli) on project gmm: Execution default-cli of goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:exec-war failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:exec-war (default-cli) on project gmm: Execution default-cli of goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:exec-war failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:exec-war failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: java.lang.NullPointerException
at java.io.FileInputStream.<init>(FileInputStream.java:134)
at org.apache.tomcat.maven.plugin.tomcat7.run.AbstractExecWarMojo.execute(AbstractExecWarMojo.java:301)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
... 21 more
[ERROR]
[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/PluginExecutionException
The goals tomcat7:deploy, :redeploy, :undeploy and the startup of a local embedded server with tomcat7:run work as expected.
Unlike the documentation i linked above i only have a single .pom file, so i merged the parts from the docu together. My pom now looks like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.gothic-reloaded-mod</groupId>
<artifactId>gmm</artifactId>
<packaging>war</packaging>
<version>0.1.1-SNAPSHOT</version>
<name>Gothic Mod Manager</name>
<url>https://github.com/Katharsas/GMM</url>
<properties>
<org.springframework.version>4.0.4.RELEASE</org.springframework.version>
<org.springframework.security.version>3.2.0.RELEASE</org.springframework.security.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.imgscalr</groupId>
<artifactId>imgscalr-lib</artifactId>
<version>4.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-juli</artifactId>
<version>7.0.52</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${org.springframework.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${org.springframework.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${org.springframework.security.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${org.springframework.security.version}</version>
</dependency>
<!-- Apache Commons Upload -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<!-- Apache Commons Upload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
</pluginManagement>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<path>/GMM</path>
<encoding>UTF-8</encoding>
<username>admin</username>
<password>**********</password>
</configuration>
<executions>
<execution>
<id>executable</id>
<goals>
<goal>exec-war-only</goal>
<goal>exec-war</goal>
</goals>
<phase>package</phase>
<configuration>
<enableNaming>true</enableNaming>
<warRunDependencies>
<warRunDependency>
<dependency>
<groupId>de.gothic-reloaded-mod</groupId>
<artifactId>gmm</artifactId>
<version>0.1.1-SNAPSHOT</version>
<type>war</type>
</dependency>
<contextPath>/</contextPath>
</warRunDependency>
</warRunDependencies>
<extraDependencies>
<extraDependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.1.3.1</version>
</extraDependency>
<extraDependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</extraDependency>
</extraDependencies>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>ISO-8859-1</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
Additional info: Im using Eclipse Kepler, my Run Configuration looks like this:
tomcat7:exec-war -e
I also tried with the commando line, tried :exec-war-only but nothing worked.
I searched and tried different things for days now, so any help is much appreciated! : ]
The NPE is because the plugin does not find the packaged war file, I fixed that error by explicitly adding the package phase to the build, so for example:
mvn clean package tomcat7:exec-war
any phase that produce the war package fits well for avoiding the NPE: package, install, deploy, etc.
So, in your case, where you use a Run Configuration in Eclipse, just add package before tomcat7:exec-war -e
I have a similar issue with version 2.2 of the plugin, but I got it run with 2.1 according to this tutorial.
There is a version 2.3 now where the problem from 2.2 has been fixed!
(had some problems with 2.1 because it is so old)
Sadly its only a snapshot version and needs to be fetched from Apache Snapshots Repository. To get it you need to put this into your pom:
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<name>Apache Snapshots</name>
<url>http://repository.apache.org/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
Then you can use the new version <version>2.3-SNAPSHOT</version>
I received this error with spring boot application. I had to spend quite sometime so putting it here that below plugin needs to be included
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
Also packaging type should be jar
<packaging>jar</packaging>
Start-class should be defined as your main class
<start-class>com.edu.schoolT.SchoolWeb</start-class>
main class or class annotated with #SpringBootApplication should extend SpringBootServletInitializer. For further info...
Create a deployable war file
I have fixed similar issue in my project and given reference below link
tomcat7-maven-plugin custom server.xml
Find pom.xml changes for this issue