maven project creation fails - java

I try to generate a new project in an empty folder on Windows 10. I am sure the directory is EMPTY. Reference: Error when creating a new maven project
C:\Projects\Java\>mvn -version
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-25T02:41:47+08:00)
Maven home: C:\Program Files\apache-maven-3.6.0\bin\..
Java version: 11.0.1, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-11.0.1
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
C:\Projects\Java>mvn -B archetype:generate -DarchetypeGroupdId=org.apache.maven.archetypes -DgroupdId=com.mycompany.app -DartifactId=HelloWorld -DarchetypeArtifactId=maven-archetype-quickstart
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.0.1:generate (default-cli) > generate-sources # standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.0.1:generate (default-cli) < generate-sources # standalone-pom <<<
[INFO]
[INFO]
[INFO] --- maven-archetype-plugin:3.0.1:generate (default-cli) # standalone-pom ---
[INFO] Generating project in Batch mode
[WARNING] Property groupId is missing. Add -DgroupId=someValue
[WARNING] Property package is missing. Add -Dpackage=someValue
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.625 s
[INFO] Finished at: 2018-11-05T10:43:49+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.0.1:generate (default-cli) on project standalone-pom: Archetype org.apache.maven.archetypes:maven-archetype-quickstart:1.0 is not configured
[ERROR] Property groupId is missing.
[ERROR] Property package is missing.
[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

Fixed. It was due to typo: "-DgroupId".

Related

Executing Project through Maven Invoker is throwing a compilation error

I am trying to execute the maven project from java main
Please refer the code below.
public static void main(String args[]) throws MavenInvocationException
{
InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile( new File( "C:\\Users\\DPKA764\\git\\be.axa.testautomation.phoenixiard\\pom.xml" ) );
request.setGoals( Arrays.asList( "clean", "install" ) );
Invoker invoker = new DefaultInvoker();
invoker.setMavenHome(new File("C:\\J\\apache-maven-3.5.3"));
System.out.println(""+invoker.getMavenHome());
invoker.execute( request );
System.out.println("suites are completed");
}
and when i execute the code as 'Java Application' it is throwing the following error.
[WARN] Maven will be executed in interactive mode, but no input stream has been configured for this MavenInvoker instance.
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< be.axa.PhoenixIARD:PhoenixIARD >-------------------
[INFO] Building git-training 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) # PhoenixIARD ---
[INFO] Deleting C:\Users\DPKA764\git\be.axa.testautomation.phoenixiard\target
[INFO]
[INFO] --- properties-maven-plugin:1.0.0:read-project-properties (default) # PhoenixIARD ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # PhoenixIARD ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\DPKA764\git\be.axa.testautomation.phoenixiard\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # PhoenixIARD ---
[INFO] Compiling 57 source files to C:\Users\DPKA764\git\be.axa.testautomation.phoenixiard\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
C:\Program Files\Java\jre7\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.885 s
[INFO] Finished at: 2020-02-03T18:24:34+05:30
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "metadata" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project PhoenixIARD: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre7\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR]
[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
but when i execute the project directly as Maven Test It will run fine.Please suggest any changes i have to do

Java EE 8 tutorial - Maven archetype does not exist

I'm trying to do this tutorial from Java EE 8 tutorial.
I'm following the instructions on how to install tutorial archetypes, which I've downloaded from this repository.
Error message printed in the bottom.
Is this related to the fact that the repository is archived, and the tutorials are outdated, or am I doing something wrong?
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:3.1.0:generate (default-cli) > generate-sources # standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:3.1.0:generate (default-cli) < generate-sources # standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:3.1.0:generate (default-cli) # standalone-pom ---
[INFO] Generating project in Batch mode
[WARNING] Archetype not found in any catalog. Falling back to central repository.
[WARNING] Add a repository with id 'archetype' in your settings.xml if archetype's repository is elsewhere.
[WARNING] The POM for org.glassfish.javaeetutorial:jaxrs-service-archetype:jar:4.0.0 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.765 s
[INFO] Finished at: 2019-06-10T20:16:02+02:00
[INFO] Final Memory: 15M/195M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:3.1.0:generate (default-cli) on project standalone-pom: The desired archetype does not exist (org.glassfish.javaeetutorial:jaxrs-service-archetype:4.0.0) -> [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

Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project jraft: No license for governance

I'm trying to setup SonarQube.com on travis for a maven project, but I see the following exception on build:
[INFO] User cache: /home/travis/.sonar/cache
[INFO] Load global settings
[INFO] Load global settings (done) | time=456ms
[INFO] User cache: /home/travis/.sonar/cache
[INFO] Load plugins index
[INFO] Load plugins index (done) | time=16ms
[INFO] Download sonar-scm-cvs-plugin-1.0.jar
[INFO] Download sonar-scm-svn-plugin-1.3.jar
[INFO] Download sonar-plsql-plugin-2.9.0.901.jar
[INFO] Download sonar-csharp-plugin-5.8.0.660.jar
[INFO] Download sonar-java-plugin-4.7.1.9272.jar
[INFO] Download sonar-web-plugin-2.5.0.476.jar
[INFO] Download sonar-flex-plugin-2.3.jar
[INFO] Download sonar-xml-plugin-1.4.2.885.jar
[INFO] Download sonar-vbnet-plugin-3.0.3.346.jar
[INFO] Download sonar-swift-plugin-2.0.0.1127.jar
[INFO] Download sonar-python-plugin-1.7.0.1195.jar
[INFO] Download sonar-github-plugin-1.4.0.699.jar
[INFO] Download sonar-cfamily-plugin-4.6.0.7071.jar
[INFO] Download sonar-auth-github-plugin-1.3.jar
[INFO] Download sonar-rpg-plugin-2.1.0.736.jar
[INFO] Download sonar-scm-mercurial-plugin-1.1.1.jar
[INFO] Download sonar-googleanalytics-plugin-1.1.jar
[INFO] Download sonar-widget-lab-plugin-1.8.1.jar
[INFO] Download sonar-pli-plugin-1.5.0.702.jar
[INFO] Download sonar-javascript-plugin-2.21.0.4409.jar
[INFO] Download sonar-groovy-plugin-1.4.jar
[INFO] Download sonar-cobol-plugin-3.3.1.1636.jar
[INFO] Download sonar-scm-git-plugin-1.2.jar
[INFO] Download sonar-php-plugin-2.10.0.2087.jar
[INFO] Download sonar-abap-plugin-3.3.jar
[INFO] Download sonar-governance-plugin-2.0.0.1789.jar
[INFO] Download qualinsight-sonarqube-badges-3.0.1.jar
[INFO] SonarQube version: 6.3.0
[INFO] Default locale: "en_US", source code encoding: "UTF-8"
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:42 min
[INFO] Finished at: 2017-04-03T09:47:20+00:00
[INFO] Final Memory: 70M/468M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli) on project jraft: No license for governance -> [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
Here is the .travis.yml:
language: java
jdk:
- oraclejdk8
addons:
sonarqube:
organization: ${SONAR_ORGANIZATION}
token:
secure: ${SONAR_TOKEN}
script:
- ./travis.sh
cache:
directories:
- $HOME/.m2/repository
- $HOME/.sonar
- $HOME/jvm
- $HOME/maven
Here is the travis.sh:
#!/bin/bash
set -e
INITIAL_VERSION=1.0-SNAPSHOT
export MAVEN_OPTS="-Xmx1G -Xms128m"
mvn package sonar:sonar \
$MAVEN_ARGS \
-Dsonar.host.url=$SONAR_HOST_URL \
-Dsonar.login=$SONAR_TOKEN \
-Dsonar.projectVersion=$INITIAL_VERSION
Why I am seeing this error No license for governance as I am not using any commercial sonar component (only sonar-java I suppose)?
The problem seems to be related to the fact that one of the plugins needs a commercial key, but How I can tell Travis to only install the java plugin?
Taking a look at your repository, you should not override the various parameters that the Travis Add-on is specifying for you.
More specifically, when you override SONAR_TOKEN on the Maven command line (at line 12), the consequence is that the token that you have encrypted and passed at line 11 of your .travis.yml file is completely wiped out. Because of this, your analysis is run like if you were anonymous.
So please follow the Get Started guide and simply run the following Maven command:
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar
sonar-governance plugin is commercial plugin.
check here
.....
[INFO] Download sonar-governance-plugin-2.0.0.1789.jar
......
For me the below works from my jenkins pipeline
node{
stage 'Code Quality'
sh "mvn sonar:sonar -Dsonar.host.url=http://<hostname>:9000"
}

Build RPM on Debian with Maven

In theory, using the rpm-maven-plugin/ and having alien install (which provides both rpm and rpmbuild binaries) it should be rather easy. But I alway get it failing with a cryptic error (because some macros are nor expanded):
$ mvn package
...
[INFO] --- rpm-maven-plugin:2.1.5:rpm (build-rpm) # dist ---
[WARNING] rpm version string truncated to 0.2.2
[INFO] Creating directory /home/wikier/projects/foo/dist/target/rpm/foo
[INFO] Creating directory /home/wikier/projects/foo/dist/target/rpm/foo/BUILD
[INFO] Creating directory /home/wikier/projects/foo/dist/target/rpm/foo/RPMS
[INFO] Creating directory /home/wikier/projects/foo/dist/target/rpm/foo/SOURCES
[INFO] Creating directory /home/wikier/projects/foo/dist/target/rpm/foo/SPECS
[INFO] Creating directory /home/wikier/projects/foo/dist/target/rpm/foo/SRPMS
[INFO] Creating directory /home/wikier/projects/foo/dist/target/rpm/foo/tmp-buildroot
[INFO] Creating directory /home/wikier/projects/foo/dist/target/rpm/foo/buildroot
[INFO] Copying files to /home/wikier/projects/foo/dist/target/rpm/foo/SOURCES
[INFO] Copying files to /home/wikier/projects/foo/dist/target/rpm/foo/tmp-buildroot/usr/share/foo-magic-api
[INFO] Creating spec file /home/wikier/projects/foo/dist/target/rpm/foo/SPECS/foo.spec
[INFO] error: Unknown icon type: Icon_foo.png
[INFO] Building target platforms: x86-64-pc-linux
[INFO] Building for target x86-64-pc-linux
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.578 s
[INFO] Finished at: 2016-07-04T14:16:49+02:00
[INFO] Final Memory: 42M/1237M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:rpm-maven-plugin:2.1.5:rpm (build-rpm) on project dist: RPM build execution returned: '1' executing '/bin/sh -c cd '/home/wikier/projects/foo/dist/target/rpm/foo/SPECS' && 'rpmbuild' '-bb' '--target' 'x86-64-pc-linux' '--buildroot' '/home/wikier/projects/foo/dist/target/rpm/foo/buildroot' '--define' '_topdir /home/wikier/projects/foo/dist/target/rpm/foo' '--define' '_build_name_fmt %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm' '--define' '_builddir %{_topdir}/BUILD' '--define' '_rpmdir %{_topdir}/RPMS' '--define' '_sourcedir %{_topdir}/SOURCES' '--define' '_specdir %{_topdir}/SPECS' '--define' '_srcrpmdir %{_topdir}/SRPMS' 'foo.spec'' -> [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
Anybody has some experience in a similar environment?
Got it! the log [INFO] error: Unknown icon type: Icon_foo.png should be actually ERROR, because later causes an error calling rpmbuild.

Maven - JAVA_HOME location and Compilation failure executing javac

---skippable part---
Hi all, first time here and hopefully I'm not writing a clone of anything else. I spent days looking for cases like mine and all the things I tried failed to work, or couldn't simply find the correct solution for me.
I'm trying to use Maven on another student's project I'm working on (have to continue what he already did) for a school project, on a pc with Ubuntu 14.04. I'm in my project directory downloaded from github and I need to create a .war file and use that for Tomcat.
I was following a guide of that student, and probably I'm a little confused on what to do.
---tl:dr i need help---
So when I launch mvn -version, I get this:
Java version: 1.7.0_101, vendor: Oracle Corporation Java home:
/usr/lib/jvm/java-7-openjdk-amd64/jre Default locale: it_IT, platform
encoding: UTF-8 OS name: "linux", version: "3.19.0-58-generic", arch:
"amd64", family: "unix"
Few days ago I had problems with $JAVA_HOME environment variable and probably solved it managing the /etc/environment file, in fact I don't get any error about this. Now when I do a mvn package I get
[INFO] Scanning for projects... [INFO]
[INFO]
------------------------------------------------------------------------ [INFO] Building GWT Maven Archetype 2.6.0-SNAPSHOT [INFO]
------------------------------------------------------------------------ [INFO] [INFO] --- maven-enforcer-plugin:1.3.1:enforce
(enforce-versions) # webprotege --- [INFO] [INFO] ---
gwt-maven-plugin:2.7.0:generateAsync (default) # webprotege --- [INFO]
[INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) #
webprotege --- [INFO] Source directory:
/home/wapaolo/Documenti/data/webprotege/webprotege/target/generated-sources/gwt
added. [INFO] [INFO] --- maven-resources-plugin:2.3:resources
(default-resources) # webprotege --- [INFO] Using 'UTF-8' encoding to
copy filtered resources. [INFO] Copying 10 resources [INFO] [INFO]
--- maven-compiler-plugin:2.3.2:compile (default-compile) # webprotege --- [INFO] Compiling 1744 source files to /home/wapaolo/Documenti/data/webprotege/webprotege/target/webprotege-2.6.0-SNAPSHOT/WEB-INF/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : [INFO]
------------------------------------------------------------- [ERROR] Failure executing javac, but could not parse the error: javac: invalid
target release: 1.8 Usage: javac use -help
for a list of possible options
[INFO] 1 error [INFO]
------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]
------------------------------------------------------------------------ [INFO] Total time: 5.241s [INFO] Finished at: Mon May 09 16:54:04 CEST
2016 [INFO] Final Memory: 18M/295M [INFO]
------------------------------------------------------------------------ [ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(default-compile) on project webprotege: Compilation failure [ERROR]
Failure executing javac, but could not parse the error: [ERROR] javac:
invalid target release: 1.8 [ERROR] Usage: javac [ERROR] use -help for a list of possible options [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
So what should I do to proceed now? I've no clue..
Your maven project wants java 1.8 but your compiler is 1.7. Look in the pom.xml file for something like
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
and change that to 1.7 OR download the 1.8 jdk.

Categories