I'm evaluating Citrus framework and I have problems with the setup. Following the documentation, I ran mvn archetype:generate -Dfilter=com.consol.citrus.mvn:citrus, selected option "Citrus quickstart project" and defined values for groupId and the others. Then I ran mvn clean verify and it failed with java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException. It seems that not all dependencies are included in the archetype, or that I need to choose another archetype. What is the recommended way to add the JAX-B APIs in my case? Should I use another archetype maybe?
OS: Windows 10 Enterprise amd64; JDK: RedHat OpenJDK 11; IDE: VS Code 1.50.1; Maven: 3.6.3; Citrus version: 2.7.3
Fixed my Citrus framework setup on Java 11 by adding the JAXB Maven dependencies javax.xml.bind:jaxb-api and org.glassfish.jaxb:jaxb-runtime. Plus, I have upgraded maven-failsafe-plugin to version 2.22.2. Now, I can run mvn clean verify without errors and get build success.
See also Java: How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException and https://maven.apache.org/surefire/maven-failsafe-plugin/java9.html
Related
I have a project which is written in java 8. It is kind of complex for me and very dependent to java 8. However I also happen to have a SonarQube and a Jenkins instance which is trying to use java 11 to scan the projects.
When java 11 is used to run:
mvn clean verify
I get java 8 dependency errors in the project and when I use java 8 I can not use sonarscanner.
I could not find and answer yet.
Any solution or suggestions ?
You can use your Jenkins instance (using JDK8) to build and submit the project to your SonarQube instance running on JDK11.
Using SonarQube's recommended scanner you can configure your project to use the remote SQ server:
pom.xml
<properties>
<sonar.host.url>https://sonarqube.cldbz.net/</sonar.host.url>
<sonar.junit.reportsPath>target/surefire-reports</sonar.junit.reportsPath>
<sonar.jacoco.reportPath>target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.sources>src/main</sonar.sources>
</properties>
and then trigger the scanning process on Jenkins with mvn sonar:sonar which would submit your project's scan results to your SQ server.
You can even test this without pom.xml changes:
mvn clean verify sonar:sonar -Dsonar.login=<token> -Dsonar.host.url=https://<sonar-server>:<port>.
SonarQube: 8.2.0.32929
sonar-scanner: 3.0.3.778
jacoco: 0.8.4
jdk: 1.8
mvn: 3.6.3
What are you trying to achieve
I am trying to achieve code coverage by using sonar-scanner but I am getting code coverage 0 in sonarqube dashboard.
What have you tried so far to achieve this
I configured the multi-module java project using https://github.com/SonarSource/sonar-scanning-examples/tree/master/sonarqube-scanner-maven/maven-multimodule
and created sonar-project.properties file in base directory with below configuration
sonar.projectKey=org.sonarqube.sonarscanner-maven-aggregate
sonar.projectName=Sonar Scanner Maven Aggregate
sonar.projectVersion=1.0
sonar.language=java
sonar.java.binaries=.
If I use mvn sonar:sonar it works. but with sonar-scanner it is not working.
It works fine with sonarqube 7.8.
Any insight would be appreciated.
I fixed this issue.
while running sonar-scanner command, I added the xmlReportPaths as a define property like sonar-scanner -Dsonar.coverage.jacoco.xmlReportPaths=tests/target/site/jacoco-aggregate/jacoco.xml,../tests/target/site/jacoco-aggregate/jacoco.xml
If your projects are set up as multi-module, you will have to feed the coverage report from each module to the last module that will run as part of the build (probably integration tests modules)
https://community.sonarsource.com/t/coverage-test-data-importing-jacoco-coverage-report-in-xml-format/12151
https://community.sonarsource.com/t/in-sonarqube-8-2-code-coverage-is-always-showing-0/21666
https://docs.sonarqube.org/latest/analysis/coverage/
https://stackoverflow.com/a/15535970
Following the steps mentioned in this example project by Sonar team helped me
https://github.com/SonarSource/sonar-scanning-examples/tree/master/sonarqube-scanner-maven/maven-multimodule
As you already followed these steps, one thing I was missing was the aggregated report was not generated in the last module and I was doing it in one module before that which was our integration test module. But there was one more deployment module in our case
Is there a tool like jenv, in favor of manage multiple mvn versions(installations)? the problem is that the first version was developed with mvn 3.0.5 and the second version will be develop with mvn 3.3 so when we compile with a on the command line it shows some mvn methods undefined.
Looking for the solution, i found the mvnvm project, it should manage the maven version using the property file mvnvm.properties an set it to an specific version:
$ cat mvnvm.properties
mvn_version=3.0.5
I am trying to create a new maven project using the maven-archetype-quickstart archetype, which incorporates a AppTest.java sample test class and a dependency for Junit version 3.8.1 but I would like to use Junit 4.
How can I change Junit version on the quickstart maven archetype?
Use the prompt or a terminal in eclipse and do this :
mvn -B archetype:generate \
-DarchetypeGroupId=org.apache.maven.archetypes \
-DgroupId=com.mycompany.app \
-DartifactId=my-app
After that you have to import it from Eclipse, IntelliJ or Netbeans as a maven project and you'll got the version of J-Unit 4.X
Apparently, other people also had an issue with this junit version shipped with maven-archetype-quickstart so they filed a Jira issue, which was solved in the archetype version 1.2.
Since that version is not in the default Maven Archetype Catalog, the next task is to find an archetype catalog with the maven-archetype-quickstart 1.2 version and use that catalog for your mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeCatalog=http://your.updated.catalog command.
EDIT: Apparently, according to this answer, you can also create your custom archetype based on a project's POM and then install it in your local archetype catalog.
You should be able to change the version in pom.xml
See this article for in-depth explanation: https://examples.javacodegeeks.com/enterprise-java/maven/junit-maven-example/
I'm trying to import and resolve the developer projects for the NatTable project as explained in their Getting Started tutorial.
I'm getting the following error on mvn -f [path to pom] clean install:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.maven.execution.MavenSession.getRepositorySession()Lorg/sonatype/aether/RepositorySystemSession;
More details:
mvn --version works fine
%MAVEN_HOME% points to [devel]/maven-3.1.0
The NatTable project seems to have configured the Tycho build extension in a version which is not compatible with Maven 3.1.
Either ask the project to switch to a Tycho version which works with Maven 3.1 (0.18.1 or later), or downgrade your local Maven installation to 3.0.5.
The NatTable project recently updated to use Maven Tycho 0.19.0.
Thanks for the hint.