maven build with my local-module artifactory (library) - java

I created a project named app-service that uses a core module(app-core). I include this core module in my project as maven dependency through <systemPath> that reside in project base directory.
<dependency>
<groupId>app-group</groupId>
<artifactId>app-core</artifactId>
<version>${project.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/app-core-0.1.1-SNAPSHOT.jar</systemPath>
</dependency>
I configure maven and run goal
mvn clean package install
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 44.733 s
[INFO] Finished at: 2017-04-05T12:27:46+05:30
[INFO] Final Memory: 29M/533M
[INFO] ------------------------------------------------------------------------
After BUILD SUCCESS $CLASSPATH does not contain the app-core.jar file, expect this it include all dependencies that listed in maven <dependencies>
I want to use this app-core module as compile scope. When I try this it prompt error
[ERROR] 'dependencies.dependency.systemPath' for app-group:app-core:jar must be omitted. This field may only be specified for a dependency with system scope. # line 71, column 25
Note: I do not upload this app-core on public repository due to security purpose. I want to use through project base directory because I need to deploy the same on Heroku.
Update
I googled it and found a plugin that installs local repository.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-external</id>
<phase>clean</phase>
<configuration>
<file>${project.basedir}/app-core-0.1.1-SNAPSHOT.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>app-group</groupId>
<artifactId>app-core</artifactId>
<version>${project.version}</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
But the result is same......

You should follow this guide to Adding Unmanaged Dependencies to a Maven Project on Heroku. To summarize the guide, run:
mvn deploy:deploy-file -Durl=file:///path/to/app-group/app-core/ -Dfile=app-core-1.0.jar -DgroupId=app-group -DartifactId=app-core -Dpackaging=jar -Dversion=1.0
Then add this repository to your pom.xml:
<repository>
<id>project.local</id>
<name>project</name>
<url>file:${project.basedir}/repo</url>
</repository>
Then use the dependency i your pom.xml:
<dependency>
<groupId>app-group</groupId>
<artifactId>app-core</artifactId>
<version>1.0</version>
</dependency>

I think the error is telling you to delete part how you setup your dependency.
Try omitting parts of it such as:
<systemPath>${project.basedir}</systemPath>
..and working from there.
Edit:
I would also try the most limited amount of information.
<dependency>
<groupId>app-group</groupId>
<artifactId>app-core</artifactId>
<version>${project.version}</version>
</dependency>
Try changing the project version even. I've had problems with maven dependencies not pulling from repositories because the pom.xml was written incorrectly. The way I ended up solving them was to keep trying different ways of writing the dependency until it actually pulled it correctly.

Related

'mvn clean' vs.'mvn clean install' (when a plugin execution is attached to 'clean')

Let's say I want to install project-local dependencies (jar files) to my local maven repository (~/.m2) prior to compiling the project so I can reference them in my POM just like I would reference any dependency from Maven Central. Currently, I'm using Maven install plugin's install-file goal attached to the 'clean' phase (because my IDE uses it), like so:
<dependencies>
<dependency>
<groupId>group.id</groupId>
<artifactId>artifact.id</artifactId>
<version>artifact.version</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-my-local-dependency</id>
<phase>clean</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>group.id</groupId>
<artifactId>artifact.id</artifactId>
<version>artifact.version</version>
<file>${project.basedir}/lib/local-dep.jar</file>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
When I execute mvn clean (or its equivalent in the IDE), everything runs as I'd expect:
--- maven-clean-plugin:2.5:clean (default-clean) # MyProject ---
--- maven-install-plugin:2.5.2:install-file (install-...) # MyProject ---
Installing ${project.basedir}/lib/local-dep.jar to ~/.m2/repository/group.id/artifact.id/local-dep.jar
But when I execute mvn clean install instead (or its equivalent in the IDE), I get the following error:
Failed to execute goal on project MyProject: Could not resolve dependencies for project com.example.MyProject:jar:1.0: Could not find artifact group.id:artifact.id:jar:artifact.version in central (https://repo.maven.apache.org/maven2) -> [Help 1]
For some reason, Maven install plugin's install-file goal either does not run in this case, or doesn't run soon enough. Why? The other StackOverflow answers I found explain differences between both commands but in my eyes, they do not explain this particular difference as my project has no modules.
Is there a better way of doing the same thing cross-platform, even on build servers (e.g. Jenkins) and with at least one other dependent project?
Should it be any help, I have the following Maven versions:
CLI: 3.6.0
IDE: 3.3.9
Maven first analyses the pom.xml and then calls the goals/phases. The analysis itself is complicated and has different depths, so I guess that calling clean alone will not make Maven analyse the dependencies, but calling clean install does so. Note that the analysis of the POM only happens once, not again for every goal/phase.
Generally, your approach cannot be recommended. Usually, you put project dependencies into remote Maven repositories, so that they can be resolved through them. If you work inside a company, you should set up a Nexus/Artifactory server that handles your artifacts.
If you want people outside your company to build the artifact, you need to find a provider for Maven repositories. I guess that github/gitlab can help you here. Then you need to add those repositories to the POM.

Maven: pass the build even if one module fails

I am trying to generate an aggregate Jacoco code coverage report by following the steps here.
My initial maven project may contain multiple modules and I add an aggregator module aggregator to the main pom dynamically through my code.
The folder structure looks somewhat like this (there can be any number of modules and sub modules in the main project):
/SampleProject/
-- pom.xml
-- module1/
---- pom.xml
---- src/
-- module2/
---- pom.xml
---- src/
-- module3/
---- pom.xml
---- src/
-- aggregator/
---- pom.xml
This is the main pom:
SampleProject/pom.xml . (here, the aggregator module is added dynamically through my code)
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sample</groupId>
<artifactId>sampleProject</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>sampleProject</name>
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
<module>aggregator</module>
</modules>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Each module has its own pom.xml. and the aggregator pom (which is generated by my code) looks something like this (each module is added as a dependency in this pom. This information is fetched from the individual poms of the modules):
aggregator/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>
<parent>
<groupId>com.sample</groupId>
<artifactId>sampleProject</artifactId>
<version>1.0</version>
</parent>
<artifactId>aggregator</artifactId>
<dependencies>
<dependency>
<groupId>com.sample.module1</groupId>
<artifactId>module1</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>com.sample.module2</groupId>
<artifactId>module2</artifactId>
<version>0.1</version>
</dependency>
<dependency>
<groupId>com.sample.module3</groupId>
<artifactId>module3</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<argLine>${argLine} -Xms256m -Xmx2048m</argLine>
<forkCount>1</forkCount>
<runOrder>random</runOrder>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<executions>
<execution>
<id>report-aggregate</id>
<phase>test</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
and, to generate the aggregate report I use the following command:
mvn clean test -DskipTests=false
This generates the aggregate report in 'aggregator/target/site/jacoco-aggregate/index.html'
Now, the problem is if something goes wrong with only the aggregator build, and that build fails (but all other modules' build is successful). Then the maven output will look something like this:
[INFO] module1 .......................................... SUCCESS [ 2.197 s]
[INFO] module2 .......................................... SUCCESS [ 11.287 s]
[INFO] module3 .......................................... SUCCESS [ 6.969 s]
[INFO] aggregator ....................................... FAILURE [ 1.241 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 00:21 min
[INFO] Finished at: 2018-07-26T13:01:12-07:00
[INFO] Final Memory: 258M/1149M
Which means that the overall build is also marked as failed if just the aggregator part fails. This causes problem in the next step in the deployment pipeline.
So, what I want is that even if the aggregator build is failing, the overall build should be marked as passed (i.e. ignore the failing aggregator build) so that I can proceed with the next step in deployment, so that not generating the code coverage report, does not fail my entire deployment process. (I will handle the missing code coverage report later in the process).
Is there some way to achieve this? any help would be appreciated.
UPDATE 1:
I already check this answer and this is not what I want. Using -fae flag in maven would still mark the build as failed at the end.
Also, I do not want the -fn flag either because then I would be ignoring actual build failures in the modules as well, which is not desired.
What I'm looking for is a way to ignore the failures of just one module in maven.
I'm not really sure if doing that is possible, any alternate suggestions are welcome too.
UPDATE 2:
Update and some background info.:
So, I am building this tool as kind of a central tool which runs on all projects so it should be generic enough to cater to different types of configurations, without changing anything in the main project (on which the tests are being run).
As of now, it seems what I am looking for is not possible. So, as a workaround, I am asking the main project's owner to include a config file which tells my tool which packages to be included for code coverage.
Will update here if I find a better solution or workaround.

Bitbucket's pipelines with Java Maven project and JFX

my team and I have a maven project using jdk1.8 (not open jdk) and javaFX for our UI. It's working well and there still a lot of work to do and we'd like to use the pipelines from Bitbucket to make continuous integration on the go.
I tried to use a simple .yml file :
image: maven:3.3.9-jdk-8
pipelines:
default:
- step:
caches:
- maven
script: # Modify the commands below to build your repository.
- mvn -B verify # -B batch mode makes Maven less verbose
But there is my problem, We are developping with IntelliJ and jdk1.8 where javaFX is standard and automatically included in the project. But the pipelines tries to use openjdk1.8, and can't find the javaFX classes (especially the jfxrt.jar file).
If I do nothing and try as it is, the Maven error is :
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[3,26] package javafx.application does not exist
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[4,19] package javafx.fxml does not exist
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[5,20] package javafx.scene does not exist
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[6,20] package javafx.scene does not exist
[ERROR] /opt/atlassian/pipelines/agent/build/src/main/java/JFX/MainJFX.java:[7,20] package javafx.stage does not exist
I tried to include the jfxrt.jar file to maven to my pom.xml as a system dependency like that :
<dependency>
<groupId>javafx</groupId>
<artifactId>jfxrt</artifactId>
<version>${java.version}</version>
<scope>system</scope>
<systemPath>${java.home}/lib/ext/jfxrt.jar</systemPath>
</dependency>
But then Maven warns me he does not find the jfxrt.jar file :
[WARNING] 'dependencies.dependency.systemPath' for javafx:jfxrt:jar refers to a non-existing file /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/ext/jfxrt.jar # line 34, column 25
Mainly because he is using openjdk and not jdk.
I also tried to put the jfxrt.jar file inside the repository and make a dependency to it, it works but Maven warns me it's not proper to do it like that :
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>2.0</version>
<scope>system</scope>
<systemPath>${basedir}/dependency/jfxrt.jar</systemPath>
</dependency>
and the warning :
[WARNING] 'dependencies.dependency.systemPath' for com.oracle:javafx:jar should not point at files within the project directory, ${basedir}/dependency/jfxrt.jar will be unresolvable by dependent projects # line 34, column 25[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
My question is how to either force Maven to use JDK and not OpenJDK, or how to make a nice dependency to javaFX so Maven can verify our project everytime we push and not warn us.
Thank you all for your future responses.
Due to Oracle's licensing of Java, Docker Hub no longer hosts official images containing the Oracle JDK. All the official images, including the Maven one you're using, are now based on OpenJDK instead.
To use Oracle Java, you'll need to build your own Docker image as the Pipelines build environment (relatively simple), or find a trusted source for a Docker image with the JDK in it. (It's pretty easy to find these via Google search, because this is a common problem.)
Frist: JavaFX ist part of the OpenJDK. This setup works for me since the open beta of piplines:
the yaml file
image: maven:3.3.3
pipelines:
default:
- step:
script: # Modify the commands below to build your repository.
- mvn clean install
and here the pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>my.group.id</groupId>
<artifactId>my.artifact.id</artifactId>
<name>my.app.name</name>
<version>1.0.0</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- goal is 'mvn jfx:jar' -->
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.7.0</version>
<configuration>
<mainClass>package.to.my.main.class</mainClass>
</configuration>
<executions>
<execution>
<id>create-jfxjar</id>
<phase>package</phase>
<goals>
<goal>build-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

How resolve conflict with maven

i have pom file: https://gist.github.com/anonymous/2d2abdc47d868250e8f47d74bdd643c2
i build with command: clean compile assembly:single
but i get warning:
[WARNING] 'dependencies.dependency.systemPath' for
com.xxx.backtesting:client:jar should not point at files within the
project directory,
${project.basedir}/lib/client-0.1-jar-with-dependencies.jar will be
unresolvable by dependent projects # line 18, column 25
and this library doesnt exist in jar file:
When i run my jar file, i got:
java -jar backtestingCandlesDownloader-0.1-jar-with-dependencies.jar 1440672480000 1441025280000 60000
task: startDate = 1440672480000, endDate = 1441025280000, period = 60000
Exception in thread "main" java.lang.NoClassDefFoundError: com/xxx/backtesting/client/model/Server
at com.xxx.backtestingCandlesDownloader.Main.main(Main.java:33)
Caused by: java.lang.ClassNotFoundException: com.xxx.backtesting.client.model.Server
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
i dont know how include client-0.1-jar-with-dependencies.jar in jar file.
Your warning is referring to line 16 and 18 of your POM:
<scope>system</scope>
...
<systemPath>${project.basedir}/lib/client-0.1-jar-with-dependencies.jar</systemPath>
These lines identify a systemPath for a library and scope lets Maven know it is provided by the system instead of within the project [1].
Your best approach would be to include it in your local Maven Repository by installing it as part of your build. This will install the client jar file as a maven artifact in your local Maven repository during the clean phase making it available to dependency projects. Installing as part of the lifecycle ensures the artifact is available automatically for all future developers/builds.
<build>
<plugins>
<!-- Installs new artifact in the local repository -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-artifact</id>
<phase>clean</phase>
<configuration>
<file>${project.basedir}/lib/client-0.1-jar-with-dependencies.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>com.xxx.backtesting</groupId>
<artifactId>client</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Once installed, you simply reference it as a dependency as you would any other Maven dependency:
<dependencies>
...
<dependency>
<groupId>com.xxx.backtesting</groupId>
<artifactId>client</artifactId>
<version>0.1</version>
</dependency>
...
</depencencies>
Alternatively, you could install the artifact via command line, but would have to fully qualify the location of your jar file [2]. After installing using the command line method, you would be able to use the library as you would any other dependency in Maven:
mvn install:install-file -Dfile=/path/to/lib/client-0.1-jar-with-dependencies.jar -DgroupId=com.xxx.backtesting -DartifactId=client -Dversion=1.0 -Dpackaging=jar
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
First make sure you have lib/client-0.1-jar-with-dependencies.jar in your project directory,then replace ${project.basedir} with ${pom.basedir}

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile)

I am using Maven 3.0.5 and Spring Tool Source 3.2 with Maven plugin installed. When I try to do 'Run As---> Maven install', I am getting the following error:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Spring Social Twitter4J Sample 1.0.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.maven.plugins:maven-war-plugin:jar:2.1.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.maven.plugins:maven-install-plugin:jar:2.3.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # spring-social-twitter4j ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 15 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # spring-social-twitter4j ---
[WARNING] The POM for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
Jun 21, 2013 2:14:32 AM org.sonatype.guice.bean.reflect.Logs$JULSink warn
WARNING: Error injecting: org.apache.maven.plugin.CompilerMojo
**java.lang.NoClassDefFoundError: org/codehaus/plexus/compiler/CompilerException**
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getDeclaredConstructors(Unknown Source)
at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:245)
at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:98)
at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:629)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:831)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:758)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:255)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:204)
at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:954)
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:987)
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:950)
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1000)
at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:45)
at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:84)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:52)
at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100)
at org.sonatype.guice.plexus.lifecycles.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:138)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:108)
at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
at com.google.inject.internal.InjectorImpl$3$1.call(InjectorImpl.java:965)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1011)
at com.google.inject.internal.InjectorImpl$3.get(InjectorImpl.java:961)
at com.google.inject.Scopes$1$1.get(Scopes.java:59)
at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:83)
at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:49)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:253)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:245)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:455)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.compiler.CompilerException
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
... 54 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.749s
[INFO] Finished at: Fri Jun 21 02:14:32 IST 2013
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
**[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project spring-social-twitter4j: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile failed: A required class was missing while executing org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile: org/codehaus/plexus/compiler/CompilerException**
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-compiler-plugin:2.3.2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/SS%20Computer/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-plugin-2.3.2.jar
[ERROR] urls[1] = file:/C:/Users/SS%20Computer/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: org.codehaus.plexus.compiler.CompilerException
[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/PluginContainerException
Please find below my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.social.samples</groupId>
<artifactId>spring-social-twitter4j</artifactId>
<name>Spring Social Twitter4J Sample</name>
<packaging>war</packaging>
<version>1.0.0</version>
<properties>
<java-version>1.6</java-version>
<org.springframework.social-version>1.1.0.BUILD-SNAPSHOT</org.springframework.social-version>
<org.springframework-version>3.2.1.RELEASE</org.springframework-version>
<org.springframework.security-version>3.1.3.RELEASE</org.springframework.security-version>
<org.slf4j-version>1.7.2</org.slf4j-version>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
<exclusions>
<!-- Exclude Commons Logging in favor of SLF4j -->
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${org.springframework.security-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${org.springframework.security-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${org.springframework.security-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
<version>${org.springframework.social-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-web</artifactId>
<version>${org.springframework.social-version}</version>
</dependency>
<!-- Twitter4J -->
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>2.2.3</version>
</dependency>
<!-- JSR 303 with Hibernate Validator -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.1.0.Final</version>
</dependency>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${org.slf4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${org.slf4j-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.159</version>
</dependency>
<!-- #Inject -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- CGLIB, only required and used for #Configuration usage -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.2</version>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jstl-impl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>org.springframework.maven.release</id>
<name>Spring Maven Release Repository</name>
<url>http://maven.springframework.org/release</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<!-- For testing against latest Spring snapshots -->
<repository>
<id>org.springframework.maven.snapshot</id>
<name>Spring Maven Snapshot Repository</name>
<url>http://maven.springframework.org/snapshot</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<!-- For developing against latest Spring milestones -->
<repository>
<id>org.springframework.maven.milestone</id>
<name>Spring Maven Milestone Repository</name>
<url>http://maven.springframework.org/milestone</url>
<snapshots><enabled>false</enabled></snapshots>
</repository>
</repositories>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<warName>spring-social-twitter4j</warName>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
</plugin>
</plugins>
</build>
</project>
During maven install my goal is war:war to make WAR of my application.
Deleting full .m2/repository local repository solved my problem.
Or else you need to know what plugins are you using exactly with their dependencies as one of the plugin suffered a problem while downloading.
Deleting full .m2 local repository solved my problem, too.
If you don't know where it is, the locations are:
Unix/Mac OS X – ~/.m2/repository
Windows – C:\Documents and Settings\{your-username}\.m2\repository
( %USERPROFILE%\.m2\repository too, as suggested by **MC Empero** )
I am adding more points to the solution by #Rushi Shah
mvn clean install -X helps to identify the root cause.
Some of the important phases of Maven build lifecycle are:
clean – the project is clean of all artifacts that came from previous compilations
compile – the project is compiled into /target directory of project root
install – packaged archive is copied into local maven repository (could in your user's home directory under /.m2)
test – unit tests are run
package – compiled sources are packaged into archive (JAR by default)
The 1.6 under tag refers to JDK version.
We need to ensure that proper jdk version in our dev environment or change the value to
1.7 or 1.5 or whatever if the application can be supported in that JDK version.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
We can find the complete details on Maven build lifecycle in Maven site.
I had the same problem, check the installed jre used by Maven in your Run Configuration...
In your case, I think that the maven-compiler-plugin:jar:2.3.2 needs a jdk1.6
To do this : Run Configuration > YOUR_MAVEN_BUILD > JRE > Alternate JRE
Hope this helps.
Sometimes it is caused due to the project points to JRE rather than JDK.So try this,
1.Right Click on project -->Build Path --> Configure Build Path -->Add Library -->JRE System Library -->Environments--> Installed JREs-->Point to java folder in c: drive (Windows) and select JDK folder and ok.
2.Remove the already present JRE from build path.
None of the other answers suggests downloading just the missing plugin.
Before you delete your whole .m2 repository and re-download all project dependencies and all plugins, you may want to try:
mvn dependency:resolve-plugins
That will download just the missing plugins.
Sometimes this issue comes because the java.version which you have mentioned in POM.xml is not the one installed in your machine.
<properties>
<java.version>1.7</java.version>
</properties>
Ensure you exactly mention the same version in your pom.xml as the jdk and jre version present in your machine.
Usually, define maven-compiler-plugin is sufficient enough. add the following to your compiler plugin definition.
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
I had this problem once, and this is how i resolved it:
Step-1 Clean your .m2/repository
Step-2 execute the maven command(for example mvn clean verify) from the terminal at the current project location(where your project's pom.xml file exist) instead of running maven from eclipse.
Either remove the below code from the pom.xml or correct your java version to make it work.
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
I think you have Two ways to solve this problem
01. Set Properties
Set Java Build Path as jdk
Right click project ->Java Build Path ->Select Libraries tab ->Select JRE System Library ->Click Edit button ->Click Installed JREs-> add tick to box ->click Edit ->Click Directory->Select jdk
Specifi which kind of jdk version you installed
Right click project ->Project Facets ->tick java and select java version->Apply ->Ok
Update project
Right-click on "project"->Go to Maven->Update
02.Delete .m2 file
If you can't solve your problem using above two topic get this action
Close your project. Delete your full .m2 folder
How to fined .m2 file(windows)
Go to Local Disk(C) ->Users ->Select your PC name ->.m2 file
Java 9 incompatible
I got this error when trying to calling mvn install on a project.
I had installed Java 9 on macOS as well as Java 8 Update 144. My Maven project was apparently invoking Java 9 and failing. Removed Java 9 from my Mac, leaving just Java 8 in place. Maven is now happily building my project to successful completion.
Using Apache Maven 3.5.0 on macOS Sierra.
Actually, if you do not want to delete your local .m2/repository/... and you are have a downloaded copy of Maven from Apache, you can have Eclipse /STS use that external Maven and you can edit the {maven}\conf\settings.xml to point your localRepository to a new empty location.
<localRepository>C:\java\repository</localRepository>
Of course, you will have a new repository with all of the maven source downloads in addition to your previous .m2 location.
check the property endorsed.dir tag in your pom.xml.
I also had this problem and I fixed by modifying the property.
Example:
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
Download maven compiler plugin jar from your central repositoy n try
If it is still failing check your jdk version, it is because of your application is built on diff jdk version
For me, restarting Eclipse got rid of this error!
I renamed the .m2 directory, this didn't help yet, so I installed the newest sdk/jdk and restarted eclipse. This worked.
It seems an SDK was needed and I only had installed a JRE.
Which is weird, because eclipse worked on the same machine for a different older project.
I imported a second maven project, and Run/maven install did only complete after restarting eclipse. So maybe just a restart of eclipse was necessary.
Importing yet another project, and had to do maven install twice before it worked even though I had restarted eclipse.
Maybe there is a file got locked in the target folder
Check the JDK version in pom.xml
<properties>
<java.version>11</java.version>
</properties>
Sometimes it may be due to the use of wrong java version. Check the java version supported for the tool you are going to use. In my case, it was due to java 8 be used on maven build and it supposed to be JAVA 11.
Change the version before do mvn clean install
by command for Linux export JAVA_HOME=<path>
I am using Intellij IDE and If you are getting this error don't use terminal. Use Maven tab on IDE and
Select your project and do these steps;
Click clean
Click install
It works for me
Maybe you can add this dependency to your pom.xml. I use this method and solve the problem!
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3.2</version>
</dependency>
for the new users on Mac os ,
find out .m2 folder and delete it, its on your /Users/.m2 directory.
you wont get to see .m2 folder in finder(File Explorer), for this user this command to Show Mac hidden files
$ defaults write com.apple.finder AppleShowAllFiles TRUE
after this press alt and click on finder-> relaunch, you can see /Users/.m2
to hide files again, simply use this
$ defaults write com.apple.finder AppleShowAllFiles false
It's really incredible to be oblige to erase whole .m2/repository content.
I suggest to type this command (On Windows) :
mvn clean
mvn -X package > my_log_file.log
The last command enable Debug option et redirect output to a file. Open the file and search ERROR or WARNING key words. You can find this kind of expression :
DEBUG] =======================================================================
[WARNING] The POM for javax.servlet:javax.servlet-api:jar:4.0.0 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for javax.servlet:javax.servlet-api:4.0.0
[FATAL] Non-parseable POM C:\Users\vifie\.m2\repository\net\java\jvnet-parent\3\jvnet-parent-3.pom: processing instruction can not have PITarget with reserved xml name (position: END_TAG seen ...</profiles>\n\n</project>\n\n<?xml ... #160:7) # C:\Users\vifie\.m2\repository\net\java\jvnet-parent\3\jvnet-parent-3.pom, line 160, column 7
[WARNING] The POM for org.glassfish:javax.json:jar:1.0.4 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for org.glassfish:javax.json:[unknown-version]
[FATAL] Non-parseable POM C:\Users\vifie\.m2\repository\net\java\jvnet-parent\3\jvnet-parent-3.pom: processing instruction can not have PITarget with reserved xml name (position: END_TAG seen ...</profiles>\n\n</project>\n\n<?xml ... #160:7) # C:\Users\vifie\.m2\repository\net\java\jvnet-parent\3\jvnet-parent-3.pom, line 160, column 7
It's esay in this case to understand you have just to delete directory C:\Users\vifie.m2\repository\net\java\jvnet-parent\3
Relaunch compilation, packaging and so on :
mvn package
WARNING disappear just because you delete POM file corrupted at the good location and maven re download it. Normally the new POM file is better.
Often debug mode give you messages with more comprehensive details.
Why I redirect log to a file : Simply because on Windows console don't have enough buffer to store all lines and often you cannot see all lines.
We tried everything listed so far and it still failed. The error also mentioned
(default-war) on project utilsJava: Error assembling WAR: webxml
attribute is required
The solution that finally fixed it was adding this to POM:
<failOnMissingWebXml>false</failOnMissingWebXml>
As mentioned here Error assembling WAR - webxml attribute is required
Our POM now contains this:
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>${project.artifactId}</warName>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
It is because your Jenkins not able to find setting file. If deleting .m2 not work, try below solution
Go to your JOB configuration
than to the Build section
Add build step :- Invoke top level maven target and fill Maven version and Goal
than click on Advance button and mention settings file path as mention in image
It is because your Maven not able to find settings file. If deleting .m2 not work, try below solution
Go to your JOB configuration
than to the Build section
Add build step :- Invoke top level maven target and fill Maven version and Goal
than click on Advance button and mention settings file path as mention in image
In my case, a .properties file (Spring Boot's application.properties) contained an accentuated character at some point. As you can see, it was treated as critical error, due to this IOUtil.copy using a Reader as a source, so it decodes the byte stream while copying, which is always a good source of hard to guess exceptions.
Caused by: java.nio.charset.MalformedInputException: Input length = 1
at java.nio.charset.CoderResult.throwException (CoderResult.java:274)
at sun.nio.cs.StreamDecoder.implRead (StreamDecoder.java:339)
at sun.nio.cs.StreamDecoder.read (StreamDecoder.java:178)
at java.io.InputStreamReader.read (InputStreamReader.java:185)
at java.io.BufferedReader.read1 (BufferedReader.java:210)
at java.io.BufferedReader.read (BufferedReader.java:287)
at java.io.BufferedReader.fill (BufferedReader.java:161)
at java.io.BufferedReader.read (BufferedReader.java:182)
at org.apache.maven.shared.filtering.BoundedReader.read (BoundedReader.java:85)
at org.apache.maven.shared.filtering.MultiDelimiterInterpolatorFilterReaderLineEnding.read (MultiDelimiterInterpolatorFilterReaderLineEnding.java:235)
at org.apache.maven.shared.filtering.MultiDelimiterInterpolatorFilterReaderLineEnding.read (MultiDelimiterInterpolatorFilterReaderLineEnding.java:197)
at java.io.Reader.read (Reader.java:229)
at org.apache.maven.shared.utils.io.IOUtil.copy (IOUtil.java:199)
at org.apache.maven.shared.utils.io.IOUtil.copy (IOUtil.java:181)
at org.apache.maven.shared.utils.io.FileUtils.copyFile (FileUtils.java:1908)
It was a typo in the variableName which was leading me to this issue,
<finalName>${project.artifactId}</finalName>
Had the same issue while converting my project to JDK 11
The suggested removing the .m2/repository did not work
Gone through almost all the suggestions mentioned on the internet but no luck
What I did was remove all the dependencies from the child module pom.xml and add them one by one again. This method was a success and worked like a charm
The problem I had was some of the dependency was changed in the new JDK 11 and need to separately add to the pom.xml. The codebase did not show any error even cleaning the .m2/repository did not. So had to follow use this solution

Categories