Can't get QueryDsl / APT to generate Q classes - spring

I'm trying to use QueryDsl in a new Spring project. I'm new to QueryDsl, and pretty new to maven and Spring, so I may be missing something fairly basic, but I can't get QueryDsl / maven-apt-plugin to generate my Q classes. The Querydsl reference makes sound so easy; I think I did exactly what it said:
I configured pom.xml with:
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>maven-apt-plugin</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
and:
<repository>
<id>QUERYDSL</id>
<url>http://source.mysema.com/maven2/releases</url>
<layout>default</layout>
</repository>
and:
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>2.5.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
I have two #Entity's in that project.
mvn clean install does not result in any output to target/generated-sources/java/
What am I missing?
I tried mvn apt:process, and it results in:
[ERROR] Failed to execute goal com.mysema.maven:maven-apt-plugin:1.0.3:process (default-cli) on project logging-implementation: Either processor or processors need to be given -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.mysema.maven:maven-apt-plugin:1.0.3:process (default-cli) on project logging-implementation: Either processor or processors need to be given
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
Any suggestions?
Thanks!

OK, I got it.
I don't understand it (I'm a Maven noob), but here's what worked:
In the parent pom.xml, I have
<build>
<pluginManagement>
<plugins>
the maven-apt-plugin definition shown above
</plugin>
<pluginManagement>
</build>
and in the project's POM I have:
<build>
<plugins>
the **exact same** maven-apt-plugin definition shown above
</plugin>
</build>
without the <pluginManagement> level betweeen <build> and <plugins>, following the instructions at http://mojo.codehaus.org/apt-maven-plugin/plugin-info.html

You are calling the goal directly, but the configuration is execution specific. So either use apt via the standard maven lifecycle or make the configuration general.

Related

Junit test works only when renamed test class name

I am using junit4 to run test. My test class is as below in test->java->com.example->ProductIT.java
When I run mvn clean install on my project, below test is not recognized and not run.
However, when I rename the test class to ProductTest, it works.
I do not understand the difference. Why does it work when I rename ?
#ContextConfiguration(locations = {"classpath:META-INF/spring/test-config.xml"})
#RunWith(SpringJunit4ClassRunner.class)
public class ProductIT{
#Autowried
private ProductServiceImpl serviceImpl;
#Test
public void test() throws Exception{
assertNotNull(serviceImpl)
}
}
pom.xml
<dependencyManagement>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core></artifactId>
<version>4.2.4-RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-infrastructure></artifactId>
<version>4.2.4-RELEASE</version>
</dependency>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch></artifactId>
<dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter></artifactId>
<dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test></artifactId>
<scope>test</scope>
<dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
The *IT postfix (for integration test) is the default test identifier for the Maven Failsafe plugin. Spring Boot projects don't contain this plugin by default and you have to explicitly add it to your project.
The *Test postfix is the default test identifier for the Maven Surefire Plugin which is used as part of the test phase of the default lifecycle: mvn test.
This answer sheds more light on the differences between these plugins.
In case you want to split your tests (unit & integration) and run them separately (first unit, then integration), add the Maven Failsafe Plugin to your project:
<project>
<!-- other dependencies -->
<build>
<!-- further plugins -->
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
... and it should recognize your existing ProductIT when you run mvn verify (or mvn install).
For more information on such testing defaults and standards, consider this guide on testing Java applications with Maven.

How to execute JAVA FX 11 JAR without providing VM args via CMD

Java : JDK 12
Build Tool : Maven
IDE : Eclipse
OS : Windows
I have a simple piece of java FX 11 code which displays a simple blank screen.
I have made deployed an executable jar using eclipse.
It works fine when i give the following command using CMD:
As it is visible that i need to provide the modules at time of execution of JAR file.
If we skip this step we get JAR direct execution error:
As I have already tried using maven as :
---Maven pom.xml
<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>com.proj1</groupId>
<artifactId>Proj1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<type>maven-plugin</type>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>13-ea+7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<compilerArgs>
<arg>--add modules</arg><arg> javafx.controls,javafx.fxml,javafx.graphics</arg>
</compilerArgs>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.1</version>
<configuration>
<mainClass>org.openjfx.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
But even when this is done the exported executable JAR still demands the arguments.
Is it possible to somehow avoid this through CMD and make the JAR executable by simply double clicking it using Maven.
I am not asking on how to solve the javaFx runtime exception but on how to solve it by adding dependencies so that when the JAR is distributed the client does not have to pass the runtime arguments and get the job done by simple clicks.
With the JavaFX maven plugin you can execute two goals: run and jlink. The former will just run the project with the required arguments (--module-path, --add-modules), so you can run on command line:
mvn clean javafx:run
Of course, this is not intended for distribution.
javafx:jlink
However, if your project is modular (i.e you have a module-info.java file), you can set your plugin like:
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.2</version>
<configuration>
<mainClass>hellofx/org.openjfx.App</mainClass>
<launcher>app</launcher>
<jlinkImageName>appDir</jlinkImageName>
<jlinkZipName>appZip</jlinkZipName>
</configuration>
</plugin>
and run:
mvn clean javafx:jlink
It will generate a custom runtime image with your project that you can distribute, and you can add a launcher or even zip it. Once extracted you will only need this to run it:
target/appdir/app
See the plugin options here.
Shade plugin
You can also use the maven-shade-plugin.
As explained here you will need a main class that doesn't extend from Application:
Launcher.java
package org.openjfx;
public class Launcher {
public static void main(String[] args) {
App.main(args);
}
}
And now you can add the shade plugin to your pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation=
"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.openjfx.Launcher</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
Run mvn clean package, and it will generate your fat jar that you can distribute and run as:
java -jar target/hellofx-1.0-SNAPSHOT.jar
Cross platform
Note that in both cases (jlink or shade plugin), you will have a jar that you can distribute only to run on the same platform as yours.
However you can make it multiplaform if you include the dependencies for other platforms as well:
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>12.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>12.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>12.0.1</version>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>12.0.1</version>
<classifier>linux</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>12.0.1</version>
<classifier>mac</classifier>
</dependency>

Why can Maven plugin dependencies only be specified within <build> and not <reporting>?

Why can <dependencies> for a <plugin> only be defined within the <build> section, and not the <reporting> section of the pom?
Why does the maven pom.xml syntax disallow <dependencies> in <reporting>?
What if a user wanted to configure a plugin only for <reporting> and set the dependency version too?
How/why does <build> dependency information get used by the plugin in the <reporting> section?
The documentation I have found, I explain below why it didn't answer the question (the confusion from the docs is actually why I'm asking this question here!).
From what I've read, observed, and tried, here is my current understanding:
Plugins in the <build> section of the script can override default dependency information, and that will affect the dependencies of the plugin in the <reporting> section. Therefore, plugin dependency information does not need to be in the <reporting> section, only the <build> section.
Is this correct? Is there a spot in the docs which clarifies this? What details am I missing in order to correctly understand the relationship between <build> and <reporting> plugin configuration for <dependencies>?
From the Maven Documentation
It says on the Maven documentation Using the Reporting vs the Build Tag:
Using the <reporting> Tag VS <build> Tag
Configuring a reporting plugin in the <reporting> or <build> elements in the pom does NOT have the same behavior!
mvn site
It uses only the parameters defined in the <configuration> element of each reporting Plugin specified in the <reporting> element, i.e. site always ignores the parameters defined in the <configuration> element of each plugin specified in <build>.
The documentation explicitly says <configuration> is not shared between <build> and <reporting>, but
my question is about <dependencies> and how/why they only get declared in <build> and never <reporting>.
It seems as if dependencies specified in <build> do carry over to <reporting> plugins. But this is a point I'd like confirmation/explanation for.
Minimal Example
I encountered this question upgrading the dependencies for the CheckStyle plugin at runtime for use with mvn site, so this minimal example POM is demonstrating the issue with the Checkstyle plugin as the example.
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>mylib</artifactId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.15</version> <!-- Update from default 6.18 to 8.15 -->
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<!-- Uncommenting will cause syntax error, Dependencies can't be declared in reporting -->
<!-- <dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.15</version>
</dependency>
</dependencies> -->
</plugin>
</plugins>
</reporting>
</project>
I would say the situation is not so simple here - because <dependencies> are possible in the <reporting> section!
I think the point is the plugin itself (so it might be different for each plugin).
But at first whats the difference between <build> and <reporting>:
<build> is used during compiling, testing - i.e. during generating/analyzing/running code - like with mvn clean install
<reporting> is used during generating documentation with mvn site
So the question is does the checkstyle plugin require your dependency during the documentation generation - I guess not - so checkstyle refuses all dependencies in <reporting>.
So to prove that dependencies within reporting are possible please have a look at spotbugs (another famous analyzer):
<build>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.12.1</version>
<configuration>
<xmlOutput>true</xmlOutput>
<spotbugsXmlWithMessages>true</spotbugsXmlWithMessages>
<spotbugsXmlOutputDirectory>target/site</spotbugsXmlOutputDirectory>
<failOnError>false</failOnError>
<includeTests>true</includeTests>
<dependencies>
<dependency>
<groupId>com.mebigfatguy.fb-contrib</groupId>
<artifactId>fb-contrib</artifactId>
<version>7.4.3.sb</version>
</dependency>
<plugin>
<groupId>com.h3xstream.findsecbugs</groupId>
<artifactId>findsecbugs-plugin</artifactId>
<version>LATEST</version>
</plugin>
</dependencies>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>3.1.12.1</version>
<configuration>
<xmlOutput>true</xmlOutput>
<spotbugsXmlWithMessages>true</spotbugsXmlWithMessages>
<spotbugsXmlOutputDirectory>target/site</spotbugsXmlOutputDirectory>
<failOnError>false</failOnError>
<includeTests>true</includeTests>
<dependencies>
<dependency>
<groupId>com.mebigfatguy.fb-contrib</groupId>
<artifactId>fb-contrib</artifactId>
<version>7.4.3.sb</version>
</dependency>
<plugin>
<groupId>com.h3xstream.findsecbugs</groupId>
<artifactId>findsecbugs-plugin</artifactId>
<version>LATEST</version>
</plugin>
</dependencies>
</configuration>
</plugin>
</plugins>
</reporting>
Please have an eye on this example - because here the <dependencies> are part of the <configuration>. So it is always wise to read the documentation of each plugin carefully.
For a complete maven pom.xml please have a look at my small OpenSource TemplateEngine which includes a lot of best practices not only for maven.

Using Spring Boot without the parent POM [duplicate]

Is there a specific recommended approach to the inclusion of the spring-boot parent pom into projects that already have a required parent POM?
What do you recommend for projects that need to extend from an organizational parent (this is extremely common and even something many/most projects published to Maven central depending on the feeder repos they come from). Most of the build stuff is related to creating executable JARs (e.g. running embedded Tomcat/Jetty). There are ways to structure things so that you can get all the dependencies without extending from a parent (similar to composition vs. inheritance). You can't get a build stuff that way though.
So is it preferable to include all of the spring-boot parent pom inside of the required parent POM or to simply have a POM dependency within the project POM file.
Other options?
TIA,
Scott
You can use the spring-boot-starter-parent like a "bom" (c.f. Spring and Jersey other projects that support this feature now), and include it only in the dependency management section with scope=import.That way you get a lot of the benefits of using it (i.e. dependency management) without replacing the settings in your actual parent.
The 2 main other things it does are
define a load of properties for quickly setting versions of dependencies that you want to override
configure some plugins with default configuration (principally the Spring Boot maven plugin). So those are the things you will have to do manually if you use your own parent.
Example provided in Spring Boot documentation:
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.3.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Update 2022-05-29 with 1.5.9.RELEASE.
I have full code and runable example here https://github.com/surasint/surasint-examples/tree/master/spring-boot-jdbi/9_spring-boot-no-parent (see README.txt to see that you can try)
You need this as a basic
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${springframework.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
But that is not enough, you also need explicitly define goal for spring-boot-maven-plugin (If you use Spring Boot as parent, you do not have to explicitly define this)
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springframework.boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Otherwise you cannot build as executable jar or war.
Not yet, if you are using JSP, you need to have this:
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
Otherwise, you will get this error message:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project spring-boot-09: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executi
ng in update mode) -> [Help 1]
NO NO , this is still not enough if you are using Maven Profile and Resource Filter with Spring Boot with "#" instead of "${}" (like this example https://www.surasint.com/spring-boot-maven-resource-filter/). Then you need to explicitly add this in
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
And this in
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<delimiters>
<delimiter>#</delimiter>
</delimiters>
<useDefaultDelimiters>false</useDefaultDelimiters>
</configuration>
</plugin>
See the example in the link https://www.surasint.com/spring-boot-with-no-parent-example/.
As per Surasin Tancharoen's answer, you may also want to define maven surefire plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
and possibly include fail-fast plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>

Maven throws error while running testng test cases

I have steup Eclipse + Maven + TestNG and I intend to run Selenium Test cases.
This is my POM File:
<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>MyGroupId</groupId>
<artifactId>TestSuite</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.32.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Now when I try to run Maven test, I get following error:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
org.apache.maven.surefire.util.SurefireReflectionException:
java.lang.reflect.InvocationTargetException; nested exception is
java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.apache.maven.surefire.util.ReflectionUtils.instantiateOneArg(ReflectionUtils.java:130)
at org.apache.maven.surefire.booter.SurefireReflector.instantiateProvider(SurefireReflector.java:247)
at org.apache.maven.surefire.booter.ProviderFactory.createProvider(ProviderFactory.java:81)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:171)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
Caused by: java.lang.NoSuchMethodError: org.apache.maven.surefire.providerapi.ProviderParameters.getRunOrderCalculator()Lorg/apache/maven/surefire/util/RunOrderCalculator;
at org.apache.maven.surefire.testng.TestNGProvider.<init>(TestNGProvider.java:67)
... 10 more
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Can someone suggest me what's that I am missing here.
Thanks in advance.
You have to define the maven-surefire-plugin in the pluginManagement section like the following:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
To use testng in relationship with the maven-surefire-plugin you usually only need to add testng as a dependency nothing more.
Furthermore remove the dependency you've given:
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.14.1</version>
</dependency>
Apart from the above this is looking more like an integration tests which is the job of maven-failsafe-plugin and not of maven-surefire-plugin.
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
This means your tests (presumably integration tests based on the selenium dependency) can be run by using:
mvn verify
Maybe will help somebody. Me helped - change version dependency of testng
It was:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>test</scope>
</dependency>
And has become:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.10</version>
<scope>test</scope>
</dependency>
I also had an issue that resulted in this error, but for me it turned out to be missing file access rights for the account running the tests to the test folder.
Might be something to check out
changing the testNG dependency version in pom.xml from 6.14.3 to 6.10 will help out in avoiding the exception cases.
For me it got resolved after adding Surefire plugin in my Pom.XML as showed below:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
and you have to make sure that, testNG.xml must be created.
You need to give the exact file name of testng xml file inside "suiteXmlFile" tag of pom.xml.
As per my understanding, this error was generated because of TestNG not configured with the maven Surefire properly, surefire are used to run our Tests. Since I'm using TestNg it must be configured with surefire.

Resources