Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project. while 'Run as Maven test' - eclipse

I am trying to create my own custom rules for Z PL/SQL Analyzer plugin by Felipebz. For that, I am following this tutorial.
I downloaded the mentioned Github Directory in that tutorial and imported it in Eclipse. Now, when I try to Run it as "Maven test", I get Following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project plsql-custom-rules: There are test failures.
There are some more errors in the log:
[INFO] Running com.company.plsql.ForbiddenDmlCheckTest
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.284 s <<< FAILURE! - in com.company.plsql.ForbiddenDmlCheckTest
[ERROR] test(com.company.plsql.ForbiddenDmlCheckTest) Time elapsed: 0.181 s <<< ERROR!
java.lang.NoSuchMethodError: org.assertj.core.api.Assertions.assertThat(Ljava/lang/String;)Lorg/assertj/core/api/AbstractStringAssert;
at com.company.plsql.ForbiddenDmlCheckTest.test(ForbiddenDmlCheckTest.java:10)
Does someone know any solution to this particular problem?
I want to create a jar for testing it in my SonarQube Server. But, before changing anything in the code, I wanted to test it first as it is; because I reckon that there is a sample rule already provided in the downloaded Project template. I can make further changes in the code once I get to test it as a jar file at first place.

Carefully check build configuration below, targeted xml that include your test objects name should be correct and commands should correct. Configuration example:
Eg for correct way :
clean install -Drelease.testng=inventoryAndWarehouseModuleSmoke.xml
This error may also be due to this.

As Raphael Alves suggested, I solved it by adding the following dependency to pom.xml
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.11.1</version>
<scope>test</scope>
</dependency>
You might want to check for the latest version of this dependency on Maven Repository

Related

Eclipse Tycho: Compile error when using the java.xml.bind module?

I think the problem is the same as described in this blog post but I get this for Java 10: I have an Eclipse RCP application that uses Java 10 features but also JAXB classes. In Eclipse, I have to add the java.xml.bind module to the build path configuration of my project (as described here) to let the compile errors go away.
However, when building the product with Tycho 1.2.0 I get the following error, exactly for the class that uses JAXB:
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.2.0:compile (default-compile) on project epd-editor: Compilation failure: Compilation failure:
[ERROR] ...app\src\app\editors\XmlPage.java:
[ERROR] package app.editors;
[ERROR] ^
[ERROR] Internal compiler error: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.BinaryModuleBinding.create(BinaryModuleBinding.java:64)
[ERROR] java.lang.NullPointerException
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.BinaryModuleBinding.create(BinaryModuleBinding.java:64)
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.getModuleFromAnswer(LookupEnvironment.java:427)
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForTypeFromModules(LookupEnvironment.java:367)
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:228)
[ERROR] at org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding.resolve(UnresolvedReferenceBinding.java:105)
Is there a way to configure the Tycho compiler plugin so that it can see modules like java.xml.bind or is there another reason for this error?
Thanks.
Java EE modules are deprecated for removal and not resolved by default and will be removed in Java 11.
The best way to handle this is to use a third-party dependency, but as you observe JDT trips over its own feet when that is done. I opened an issue and it was fixed some time ago, but it's not easy to find an artifact that contains the change and works on Java 10. The first artifact I know of comes from Eclipse Photon I20180531-0700.
Execute the following in Eclipse's plugins folder (#people from the future: you may have to update the version):
mvn install:install-file \
-Dfile=org.eclipse.jdt.core_3.14.0.v20180528-0519.jar \
-DgroupId=org.eclipse.tycho \
-DartifactId=org.eclipse.jdt.core \
-Dversion=3.14.0.v20180528-0519 \
-Dpackaging=jar
You can then use it as follows as dependencies for Maven's compiler plugin:
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-jdt</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<!-- unreleased version that was pulled from Eclipse Photon I20180531-0700
contains the fix and compiles Java 10 -->
<version>3.14.0.v20180528-0519</version>
</dependency>
The problem is also described on java9.wtf with a demo project on GitHub. (I forgot to push, so it's only online for about five minutes now. 😒)
There are three ways you can include modules from the java.se.ee aggregator module, which is not included for compile or runtime in JDK 10. (As of JDK 11, these modules will be removed from the JDK).
The simplest is to use the command line option, --add-modules java.xml.bind. This will use the version that is still included in the JDK.
Find a JAXB implementation jar. Maven central is a good place to go for this, there is also a reference implementation for JSR 222 (JAXB), which is part of the Java Web Services Developer Pack (http://www.oracle.com/technetwork/java/webservicespack-jsp-140788.html) but this is waaaay old and may not be the best choice. You can add where you've downloaded the jar to the upgrade module path using --upgrade-module-path {path}
An alternative to 2 is to simply put the jar containing JAXB on the classpath.
I'm not familiar with Tycho but you would need to figure out how to use one of these methods with its configuration.

Linking JSF libraries from JBoss in Maven

I have a very simple web project in Eclipse that uses JSF and runs with a JBoss 4.2.3. I have 'Mavenized' the project and a pom.xml is generated. The pom.xml is empty with no dependencies, but I can install this maven project and I see my web page when I run the JBoss from eclipse. All fine till here.
Now I need to extend the logic of the java code and I need to add a new artifact generated from another project, and here is where my problem starts. When I add a dependency to this new artifact and I try the make a 'install' I am getting this error:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(default-compile) on project MyTest: Compilation failure: Compilation
failure:
[ERROR]
/home/daniel/workspace/valais/voba-switch/src/ch/steria/scada/sw/web/controller/SwitchController.java:[7,24]
package javax.faces.model does not exist
[ERROR]
/home/daniel/workspace/valais/voba-switch/src/ch/steria/scada/sw/web/controller/SwitchController.java:[45,13]
cannot find symbol
[ERROR] symbol : class SelectItem
I see the libraries missing are in the jboss-web.deployer directory of the JBoss. How can I link this libraries in the pom.xml or how can I get the right ones from the jboss maven repository for my jboss vesion?
Thanks,
Dani.
I just had to set the artifacts from JBoss as 'provided'.

Maven offline build fails when it encouners google guava url with invalid character

I need to make my Tycho-Maven build work in offline mode, so I can deploy it to environments with no Internet connection and let people run the build from the previously downloaded artifacts for the third party code my app depends on. The product being built is an Eclipse RCP product, using the org.eclipse.tycho:target-platform-configuration plug-in to load the dependencies from an RCP target file.
First I run mvn -Dmaven.repo.local=/some/path/ -DgeneratePom=true clean install to create the artifacts, and that build succeeds. Then when I run mvn -Dmaven.repo.local=/some/path/ -o clean install it fails because it's running in offline mode and there is no local cache available for http://download.eclipse.org/tools/cdt/releases/8.6
So then I run mvn -Dmaven.repo.local=/some/path/ dependency:go-offline to make it download all the artifacts it needs for the build, but it fails with this message:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-dependency-plugin:2.8:resolve-plugins
(resolve-plugins) on project : Nested: Could not transfer
artifact com.google.guava:guava:jar:[10.0.1,14.0.1] from/to central
(https://repo.maven.apache.org/maven2): Illegal character in path at
index 60:
https://repo.maven.apache.org/maven2/com/google/guava/guava/[10.0.1,14.0.1]/guava-[10.0.1,14.0.1].jar
Index 60 is the "[" character in the version range specifier for the guava jar. I have no idea where that URL gets created and why it's not URL-encoded. It would be nice to get the dependency:go-offline goal to complete execution, but I don't think it's the source of my problem.
The reason I say that is when I run that goal, I see this in the output
[INFO] Adding repository
http://download.eclipse.org/tools/cdt/releases/8.6 [INFO] Fetching
p2.index from http://download.eclipse.org/tools/cdt/releases/8.6/r/
(0B at 0B/s)
I don't know why it downloads 0 Bytes, but I assume this is why I can't find a cache of the CDT bundles when I try to do an offline build.
If anyone has an idea how to work around this failure, or any other approach to make an offline build work, that would be very helpful.
I created this Maven bug report in the issue tracker.
In the course of creating a stripped down project to demonstrate the problem, I discovered the cause. The presence of org.eclipse.xtend:xtend-maven-plugin in the pom was causing the problem. The plug-in is not used, and was perhaps misconfigured, per a message I saw in the build output.

GWT Development Mode with Eclipse/Maven

I am just starting with GWT. I use Eclipse and have installed the GWT plugin.
I have followed the directions here Maven GWT 2.0 and Eclipse to set up a GWT project using the gwt-maven-plugin. When I run the Maven goals gwt:compile gwt:run, GWT Development Mode is launched and I can copy the url from it to my browser and view the label.
However, the project has this problem:
Description: The web.xml file does not exist
Resource: WEB-INF
Path: /GWTExample/war
Location: Unknown
Type: Google Web App Problem
If I try to run the project as a Google Web Application, I get this warning:
[WARN] No startup URLs supplied and no plausible ones found -- use -startupUrl
I can get rid of the problem by copying the web.xml to the war directory, but I still get the URL issue when running as a Google Web App.
If I'm using Maven and GWT in Eclipse, should I just ignore the web.xml problem and always run applications in development mode via the Maven goals? Or is there a way to set things so I can run as a Google Web App?
EDIT: Related to the above, is it possible to debug a GWT app running in development mode started by gwt:compile gwt:run? I have added breakpoints to my application but it doesn't stop on them. I'm not sure if it is something I've configured wrong or if it's just not possible.
Update:
In response to Prem's answer...
When I run a compile gwt:run, the web.xml file isn't copied. When I run the install gwt:run, I get this error:
[INFO] --- gwt-maven-plugin:1.2:test (default) # SampleGWT ---
[INFO] using GWT jars from project dependencies : 2.0.4
[INFO] establishing classpath list (scope = test)
[ERROR] java.lang.NoClassDefFoundError: org/codehaus/mojo/gwt/test/MavenTestRunner
[ERROR] Caused by: java.lang.ClassNotFoundException: org.codehaus.mojo.gwt.test.MavenTestRunner
[ERROR] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[ERROR] at java.security.AccessController.doPrivileged(Native Method)
[ERROR] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
[ERROR] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[ERROR] at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
[ERROR] Could not find the main class: org.codehaus.mojo.gwt.test.MavenTestRunner. Program will exit.
[ERROR] Exception in thread "main"
I’m guessing that bug http://jira.codehaus.org/browse/MGWT-24 is included in version 1.2 of the gwt-maven-plugin. Normally I wouldn’t run install on a project that builds a war file, but I would expect to at least get past the test phase of the build cycle.
Does anybody have any idea why I would get this error on the install but not the compile goals? Also, should I be expecting either goal to copy the web.xml file from src/main/webapp/WEB-INF/web.xml to the /war directory?
Description: The web.xml file does not exist
gwt-maven-plugin creates a project with 'war' packaging format (it's a web app so no surpirse here). Web.xml for this project will be under 'src/main/webapp' folder which will be copied to the 'war' directory (which is set as the output directory) as part of the 'resources' phase in the maven build life-cycle. You should always use
mvn compile gwt:run
or
mvn install gwt:run
so that resources are copied, all java files are compiled and gwt:compile is also invoked (since it is bound to the 'compile' phase automatically)
[WARN] No startup URLs supplied and no plausible ones found -- use -startupUrl
As per the stackoverflow link you used as reference, only your maven build file is setup with startupUrl. In order for it to work in Eclipse, you must edit the Run Configuration of your project and add the '-statupUrl' command line arguments to the existing arguments in the "Arguments" panel.
However, this is just a warning and it should not stop you from running your GWT application from eclipse. If you are facing the same "web.xml" problem here as well, it could be because you did not compile your project in your IDE before invoking "Run as Web Application". I suggest you to disable "Build Automatically" option for this project and always build it manually and invoke "GWT Compile" and then try "Run as web application"
EDIT: Related to the above, is it possible to debug a GWT app running in development mode started by gwt:compile gwt:run?
In general you must use "Remote Application" debug configuration for remote debugging a process. However I am not sure if it will work for GWT projects.
I got me too this warning:
No startup URLs supplied and no plausible ones found
when I have followed this gwt tutorial
In that screenshot there is no checkbox with "Generate sample code" . In my IDE ( sdk 2.5) it is, so I have unchecked...
It wasn't created any of the server and client packages, I have created the client manually, as the tutorial required. The tutorial until that step doesn't say I must have a server package too. That and his configuration is missing from project.
If you right-click on your project and go to Properties -> Google -> Web Application, your WAR directory might be something like either war or src/main/webapp/WEB-INF/classes.
Change that to src/main/webapp.
Also un-check the box next to "Launch and delploy from this directory..."
That's what fixed this problem for me. It also fixed the "can't find gwt-servlet.jar" problem at the same time.

Installing Enclosure with Netbeans

I am having trouble installing Enclosure and getting it to work. I have followed this guide http://www.enclojure.org/gettingstarted and successfully installed Enclosure (I think). However, when I try to build the sample application (labrepl) I get a bunch of errors and a failed build. I haven't used Java in a long time and I've never used Netbeans, and the error doesn't seem very helpful with my limited knowledge of this domain. I'm using the latest Netbeans and the Enclosure URL from the guide. Since I am on Windows, I can't use git to clone the repo, so I'm not sure what to do from here.
Anyway, here are the error messages.
WARNING: You are running embedded Maven builds, some build may fail due to incompatibilities with latest Maven release.
To set Maven instance to use for building, click here.
Scanning for projects...
[#process-resources]
[resources:resources]
Using default encoding to copy filtered resources.
[#compile]
[ERROR]Transitive dependency resolution for scope: compile has failed for your project.
[ERROR]Error message: Missing:
[ERROR]----------
[ERROR]1) org.clojure:clojure-contrib:jar:1.2.0-master-SNAPSHOT
[ERROR] Try downloading the file manually from the project website.
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId=org.clojure -DartifactId=clojure-contrib -Dversion=1.2.0-master-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
[ERROR] Alternatively, if you host your own repository you can deploy the file there:
[ERROR] mvn deploy:deploy-file -DgroupId=org.clojure -DartifactId=clojure-contrib -Dversion=1.2.0-master-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR] Path to dependency:
[ERROR] 1) labrepl:labrepl:jar:0.0.1
[ERROR] 2) org.clojure:clojure-contrib:jar:1.2.0-master-SNAPSHOT
[ERROR]----------
[ERROR]1 required artifact is missing.
[ERROR]for artifact:
[ERROR] labrepl:labrepl:jar:0.0.1
[ERROR]from the specified remote repositories:
[ERROR] central (http://repo1.maven.org/maven2),
[ERROR] clojars (http://clojars.org/repo/),
[ERROR] incanter (http://repo.incanter.org),
[ERROR] clojure-snapshots (http://build.clojure.org/snapshots),
[ERROR] clojure (http://build.clojure.org/releases),
[ERROR] clojure-releases (http://build.clojure.org/releases)
[ERROR]Group-Id: labrepl
[ERROR]Artifact-Id: labrepl
[ERROR]Version: 0.0.1
[ERROR]From file: C:\Users\chloey\Documents\NetBeansProjects\RelevanceLabRepl\pom.xml
------------------------------------------------------------------------
For more information, run with the -e flag
------------------------------------------------------------------------
BUILD FAILED
------------------------------------------------------------------------
Total time: 1 second
Finished at: Wed Jun 09 21:53:04 CDT 2010
Final Memory: 72M/172M
------------------------------------------------------------------------
Thanks all.
the missing artifact is the artifact itself. What command are you using to build it? Try mvn clean install on the command line if everything else fails.
I had the same problem so I did a clean install of Netbeans followed by and install of maven both to no avail.
When I went to download the missing artifact I noticed that clojure-contrib version 1.2.0 was not available for download. Changing the pom.xml to look for version 1.1.0 resulted in a successful build.
Open the pom.xml and change
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure-contrib</artifactId>
<version>1.2.0-master-SNAPSHOT</version>
</dependency>
to
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure-contrib</artifactId>
<version>1.1.0-master-SNAPSHOT</version>
</dependency>
By the looks of things some additional functionality within 1.2.0 is needed for labrepl not sure from where to download it.