Java Maven project refuses to build locally - java

I'll add more information as needed, since I'm not entirely sure where to start. So please, bear with me for a while.
A running Java Maven project, which is in production and in use and running in a Tekton environment.. It's an end-2-end-framework for Selenium, and several projects are using it as we speak.
All I've done with it so far, is run projects that import and use parts of the framework. Never had any problems.
But, seeing as I have to make changes to it, and update it (among others, from selenium 3.x to 4.x), I'm running into problems from the very start.
I've cloned the project form the GitHub environment to my local Ubuntu development environment, and opened it in IntelliJ.
I can build the individual modules in the project. But when I try to do a "mvn clean install", I get this error when it comes to the second module. It only takes about 3 seconds for the install to fail:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.716 s
[INFO] Finished at: 2022-09-26T18:43:06+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project selenium: Fatal error compiling: java.lang.ExceptionInInitializerError: com.sun.tools.javac.code.TypeTags -> [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
None of the information provided there give me any clue AFAICS. Neither does it when I use the -e switch:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project felles: Fatal error compiling: java.lang.ExceptionInInitializerError: com.sun.tools.javac.code.TypeTags -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project felles: Fatal error compiling
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Fatal error compiling
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1086)
....
....
Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.code.TypeTags
at java.lang.ClassLoader.findClass (ClassLoader.java:719)
at java.lang.ClassLoader.loadClass (ClassLoader.java:589)
I cannot find anything related to Mojo in the project.
Any ideas where to start? To clarify: This is a project running in a Tekton environment, and it's in daily use by several projects. So it most certainly builds and runs in that environment. But I'm not able to compile and run it locally.

This is a bit outside of my realm, but here goes... Are you sure that the maven and java versions are usable on your ubuntu platform? I noticed that you didn't say or at least post that you did the -x switch for more logged info.
I found this on a similar post here :
update-ca-certificates -f
According to the man page:
update-ca-certificates is a program that updates the directory /etc/ssl/certs to
hold SSL certificates and generatescertificates.crt, a concatenated single-file
list of certificate
Maven with Ubuntu 15.10, getting errors with: mvn clean install;
I hope this helps. Sorry for being out of my element

Related

MAVEN Build failure do to node permission denied

While building my project in my local I am getting a Build Failure for UI apps, seems to be related to NPM.
Not sure if its related to Node or to some Java issues regarding the JDK. Any info on this very issue?
Is there some internal permissions configs I must change?
sh: /Users/test.gc/Desktop/git/test-dot-com/test-dot-com/ui.apps/node_modules/.bin/npm-run-all: Permission denied
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 126 (Exit value: 126)
at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:804)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:751)
at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:313)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for jll-dot-com 21.5.0:
[INFO]
[INFO] jll-dot-com ........................................ SUCCESS [ 0.246 s]
[INFO] jll-dot-com - Core ................................. SUCCESS [ 15.429 s]
[INFO] jll-dot-com - Groovy Console Extension ............. SUCCESS [ 0.933 s]
[INFO] jll-dot-com - UI apps .............................. FAILURE [ 8.991 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26.590 s
[INFO] Finished at: 2021-05-10T08:57:09-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (npm-run-build) on project jll-dot-com.ui.apps: Command execution failed.: Process exited with an error: 126 (Exit value: 126) -> [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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :jll-dot-com.ui.apps
What are the steps to complete this build with no failures.
sh: /Users/test.gc/Desktop/git/test-dot-com/test-dot-com/ui.apps/node_modules/.bin/npm-run-all: Permission denied
The first line says it all.
I suggest you try to run the same command in the code repo with npm directly and see what kind of permission you are getting.
npx npm-run-all
Each file has 3 attributes: Read, Write, and Execute
total 0
0 drwx------# 6 samuel staff 192 Apr 27 17:28 Applications
It is likely you do not have permission to execute the file. This can be caused by many possible reasons. For example, if you download, then copy and paste them. If the permission issue is indeed caused by insufficient permission, change the permission by using the following command.
chmod +x YOUR_REPO_DIR/.bin/*
This will grant the execution permission to the commands.

NetBeans on windows works fine but on ubnutu 20.04.2 LTE it shows me that:

When I run my code with NetBans on Windows it works fine but on ubnutu 20.04.2 LTE it shows me that:
cd /home/sulayman/NetBeansProjects/Clases; JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 /snap/netbeans/41/netbeans/java/maven/bin/mvn "-Dexec.args=-classpath %classpath clases.Clases" -Dexec.executable=/usr/lib/jvm/java-11-openjdk-amd64/bin/java org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
Scanning for projects...
------------------------< com.mycompany:Clases >------------------------
Building Clases 1.0-SNAPSHOT
--------------------------------[ jar ]---------------------------------
--- exec-maven-plugin:3.0.0:exec (default-cli) # Clases ---
Error: Se ha producido un error de enlace al cargar la clase principal clases.Clases
java.lang.UnsupportedClassVersionError: clases/Clases has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 55.0
Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:166)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:982)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:929)
at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:457)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.707 s
Finished at: 2021-02-28T14:01:07+01:00
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project Clases: Command execution failed.: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
This
java.lang.UnsupportedClassVersionError: clases/Clases has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 55.0
is the reason.
You are trying to run classes that have been compiled for Java 15, but you are trying to use/compile them with Java 11
You either need to recompile those classes with Java 11, or use Java 15 on your Ubuntu computer

Surefire maven plugin does not execute one of the tests

I have a project with four packages. With three of them everything is fine. I have generated JUnit tests and they are executed during the build or while I am running mvn test command.
But my fourth package, containing just one class. I have created a JUnit test for it, but when I am running the build, Surefire does not see this test class. All other eight test classes are executed, but this one is ignored.
When I am trying to execute just this one test class explicitly using
mvn -Dtest=com.company.dpt.prj.pkg.MySpecificClassTest test
I am getting these messages
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.058 s
[INFO] Finished at: 2020-12-19T23:58:01-08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project my-project-name: No tests were executed! (Set -DfailIfNoTests=false to ignore this 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
I went through the test code line by line and couldn't find any reasons for such behavior.
I even deleted the test file and regenerated a very basic one. It is still not executed.
Has anyone encountered something similar? Any hint will be greatly appreciated, as I couldn't find any clues.
I am using JUnit 4.11
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<version>4.11</version>
</dependency>
All tests were originally generated using Netbeans v.12 "Tools->Create/Update Test" and than edited to reflect methods functionality.
However, all test but this one are working fine both in Netbeans GUI and CLI "mvn test". This one is ignored. The purpose of method I want to test is to build HttpEntity for the REST API client. Here is the code of the test:
/**
* Test of prepareRequest method, of class BatchServiceClient.
* #throws java.net.URISyntaxException
*/
#Test
public void testPrepareRequest() throws URISyntaxException {
System.out.println("prepareRequest");
ObjectMapper mapper = Json.mapper();
URL configFileUrl = this.getClass().getClassLoader().getResource("config_f.json");
if (configFileUrl == null) {
fail("Missing configuration file");
} else {
File configFile = new File(configFileUrl.toURI());
BatchConfig config = BatchConfigLoader.loadConfig(configFile);
assertNotNull(config);
boolean validated = config.validate();
assertTrue(validated);
BatchServiceClient client = new BatchServiceClient(config, null, null, null, null, null, null);
List<Object> requestData = Arrays.asList("16759408", "", "", "", "The Home Depot", "",
"Baltimore", "MD", "", "840", "", "", "", "", "", "", "", "", "", "", 10, "",
true, true, "merchantName", "merchantName", "merchantName");
HttpEntity<String> request = client.prepareRequest(requestData);
assertNotNull(request);
}
}
My problem is that it is not failing within the test code. I will be happy if it would, because I will be able to debug it than. It is just not executing.
I tried to upgrade JUnit to v.4.13.1 and surefire maven plugin to v.3.0.0-M5 but it did not have any affect.
I tried to run mvn with -e option and got the following stack trace, but it still did not give me any clues on why it is happening.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoFailureException: No tests were executed! (Set -DfailIfNoTests=false to ignore this error.)
at org.apache.maven.plugin.surefire.SurefireHelper.reportExecution (SurefireHelper.java:149)
at org.apache.maven.plugin.surefire.SurefirePlugin.handleSummary (SurefirePlugin.java:364)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked (AbstractSurefireMojo.java:1041)
at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute (AbstractSurefireMojo.java:857)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:564)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
You cannot use this patter:
-Dtest=com.company.dpt.prj.pkg.MySpecificClassTest
because the Surefire and Failsafe plugin does not support fully qualified class name. It makes a lookup on the file system and therefore I showed you on how to use the slashes in the configuration. The documentation is specifying this option, read it again here:
NOTE: Use syntax e.g. "foo/MyTest.java", "/MyTest.java", "MyTest" for "test" parameter (see includes/excludes).**
Gary, your problem is that you are talking about the JUnit but which one? There are two versions 4 anf 5, and even more specifically you can post a source code to our Apache JIRA (or to Stackoverflow) and then me as a committer can have a look into your code. Really it cannot be reproduced without it because only a pure text in the stackoverflow cannot make your problem reproducible on my side. So please attach always a link the next time and we will have a look. One guy did it last week and it was very helpful.
Regarding the import of the Test annotation, it was not Surefire plugin that did not recognize the #Test import. :-) Really, it was your fault you did not write proper source code including the POM and the compiler has compiled the code as it was even if you combine JUnit4 and JUnit5 in the POM. Then the Surefire triggered the JUnit libraries which are then responsible for recognizing the annotations - not the Surefire. The Surefire algorithm would prefer using JUnit5 if you combine JUnit4 and JUnit5-Jupiter and that's the reason why the annotation org.junit.Test was ignored because the Jupiter does not find it and Jupiter's annotation.
I did find the cause of the problem.
Somehow, when IDE generated (and regenerated) that test file it placed the wrong import for the #Test annotation. Instead of
import org.junit.jupiter.api.Test;
it placed
import org.junit.Test;
Therefore, jupiter engine, ran by surefire did not recognized #Test annotation.
After I corrected import test was executed.
I had this issue in a Spring Boot Project together with the Maven Surefire plugin 3.0.0-M5. Spring Boot is providing dependencies for junit4 and junit5. Maven Surefire has a precedence when selecting a provider and is choosing junit5 first if available:
if the JUnit 5 Platform Engine is present in the project
use junit-platform
if the JUnit version in the project >= 4.7 and the <<>> configuration parameter has ANY value
use junit47 provider
if JUnit >= 4.0 is present
use junit4 provider
else
use junit3.8.1
All my test were junit4 test and hence no test were found to be executed. I have migrated all tests, look out in the documentation to find an option to set the provider, maybe there is any.
Please see the documentation.
In your case the command should become:
mvn -Dtest=com/company/dpt/prj/pkg/MySpecificClassTest.java test

nexus: Could not transfer artifact from/to nexus (http://localhost:8081/repository/maven-proxy-test/)

I installed nexus repository manager 3 in my system. I configured maven2 proxy repository, when i tried to clean pom.xml file using 'mvn clean' command, I am getting below error.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.sample.app:nexus-proxy-test >-------------------
[INFO] Building nexus-proxy-test 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from nexus: http://localhost:8081/repository/maven-proxy-test/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.377 s
[INFO] Finished at: 2019-10-03T19:04:32+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to nexus (http://localhost:8081/repository/maven-proxy-test/): Not authorized -> [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/PluginResolutionException
Error stack trace looks like below.
Caused by: org.apache.maven.wagon.authorization.AuthorizationException: Not authorized
at org.apache.maven.wagon.providers.http.wagon.shared.AbstractHttpClientWagon.resourceExists (AbstractHttpClientWagon.java:838)
at org.apache.maven.wagon.providers.http.wagon.shared.AbstractHttpClientWagon.resourceExists (AbstractHttpClientWagon.java:809)
at org.eclipse.aether.transport.wagon.WagonTransporter$PeekTaskRunner.run (WagonTransporter.java:512)
at org.eclipse.aether.transport.wagon.WagonTransporter.execute (WagonTransporter.java:435)
at org.eclipse.aether.transport.wagon.WagonTransporter.peek (WagonTransporter.java:406)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$PeekTaskRunner.runTask (BasicRepositoryConnector.java:390)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run (BasicRepositoryConnector.java:364)
at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run (RunnableErrorForwarder.java:75)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute (BasicRepositoryConnector.java:644)
at org.eclipse.aether.connector.basic.BasicRepositoryConnector.get (BasicRepositoryConnector.java:262)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads (DefaultArtifactResolver.java:499)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:401)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:229)
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact (DefaultArtifactResolver.java:207)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom (DefaultArtifactDescriptorReader.java:240)
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor (DefaultArtifactDescriptorReader.java:171)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor (DefaultRepositorySystem.java:255)
at org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver.resolve (DefaultPluginDependenciesResolver.java:106)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getPluginDescriptor (DefaultMavenPluginManager.java:182)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getMojoDescriptor (DefaultMavenPluginManager.java:286)
at org.apache.maven.plugin.DefaultBuildPluginManager.getMojoDescriptor (DefaultBuildPluginManager.java:244)
at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.setupMojoExecution (DefaultLifecycleExecutionPlanCalculator.java:169)
at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.setupMojoExecutions (DefaultLifecycleExecutionPlanCalculator.java:154)
at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan (DefaultLifecycleExecutionPlanCalculator.java:130)
at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan (DefaultLifecycleExecutionPlanCalculator.java:144)
at org.apache.maven.lifecycle.internal.builder.BuilderCommon.resolveBuildPlan (BuilderCommon.java:97)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:111)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Reference
https://help.sonatype.com/learning/repository-manager-3/first-time-installation-and-setup/lesson-2%3A-proxy-and-hosted-maven-repositories
This is authorization issue. Open settings.xml file from folder where maven is installed and correct the user ID and password. It should solve your problem.
Jar is not getting downloaded because of incorrect passwords.
If you have made sure your settings.xml file has the correct user and password and it still doesn't work, make sure you are pointing to the right version of Maven. I had this error and it turned out my IDE was defaulting to a different version of Maven, one without a corrected settings.xml file.

Maven plugin failed to execute

Maven configuration failed this line just ruined my Friday night and still i am unable to solve it.
Well,I am a big fan of visual studio code so i just decided to switch on vscode to eclipse for java development. but this is not the problem,Problem raise when i just try to add an external java library.I am unable to use it and i just get an error something like Class-not-Found or so on.
Well,this is my project structure in vscode
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project in.blackpaper.topdf: Compilation failure
This is error message which i get while install mvn plugin.
mvn clean install
[DEBUG] incrementalBuildHelper#beforeRebuildExecution
[INFO] Compiling 1 source file to E:\Documents\Java\in.blackpaper.topdf\target\classes
[DEBUG] incrementalBuildHelper#afterRebuildExecution
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.086 s
[INFO] Finished at: 2018-04-17T11:23:29+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project in.blackpaper.topdf: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project in.blackpaper.topdf: Compilation failure
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (Unknown Source)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (Unknown Source)
at java.lang.reflect.Method.invoke (Unknown Source)
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)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1161)
at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:168)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (Unknown Source)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (Unknown Source)
at java.lang.reflect.Method.invoke (Unknown Source)
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)
[ERROR]
[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
Well,i also try to solve my problem with vscode developers but still i can't solve it.
This is the issue i raised in vscode-github
vscode-java/issue#509
Well,my problem is different from all the previously asked questions about maven-plugins and I tried all available solution but unable to get the point.
Thanks in advance.
The Java installation you're using is not a Java Development Kit (you can understand the difference by looking at this question).
To solve your problem, download and install the JDK (such as from here, or from here, depending on the version you prefer), if you haven't installed it already. After installing and/or extracting (if you're on linix, better done in an init script):
export JAVA_HOME=<path_to_the_extracted_jdk_directory>
On Windows, create an environment variable named JAVA_HOME, with a value set to the full path to the installation directory.
To verify that Maven picks up the correct Java installation, you can try
mvn -version
The output includes a line for the Java installation Maven is seeing, such as:
...Maven home: [path to maven]
Java version: 1.8.0_152, vendor: Oracle Corporation
Java home: /home/user/jdk/jdk1.8.0_152/jre
...
Please check the terminal, the process holds the lock. So the application files are still used by somewhere. So first we need to stop the process, then start your task it will work.

Categories

Resources