Eclipse | Maven : Multiple annotations found at this line - java

I'm trying to import a maven project into Eclipse.
I'm using Helios. I've downloaded m2eclipse. I've imported the project.
But I'am having so much troubles to compile the project.
The full project contains 5 Eclipse projects, ie: prj1, prj2, prj3, prj4 and prj5
If I look the (Eclipse) marker at prj1/pom.xml I have this troubles:
Multiple annotations found at this line:
- Missing artifact log4j:log4j:jar:1.2.15:compile
- Missing artifact org.apache.xmlbeans:xmlbeans-xpath:jar:2.4.0:compile
- Missing artifact org.apache.ws.commons.axiom:axiom-dom:jar:1.2.5:compile
- Missing artifact org.apache.httpcomponents:httpcore:jar:4.0-alpha5:compile
.... and so many more ...
If I understood how maven works those dependecies must be downloaded my maven, am I wrong?
Why is it that those dependencies are not being downloaded? Should I download one by one, by hand?

It is not a unique issue, happens every now and then (sometimes due to a slow connection and sometimes due to proxy servers not allowing to download)
You can get rid of this by either of the following ways:
1) Force Update: Right Click on the Project in Eclipse -> Maven -> Update Project
On this screen select the check box Force Update for Snapshots/Releases
2) Clearing Maven Cache: If you are still facing a problem, go to the local repository on your system, which might be present at C:\Users\myusername\.m2\repository and delete the .cache folder and then follow step 1.
If you're still facing issues after this, manually go to the org/apache folder and delete everything and then follow step 1. (This will definitely solve the issue.)

Make sure your build path is going to /target/classes
to check:
right click on your project and go to properties
-> choose java build path
-> then go to the source tab
the default output folder is on the bottom

With Eclipse/Maven projects, I've always had more luck building from the command line (mvn clean package) first in order to download all of the dependencies. Once that completes without errors, then I import the project into Eclipse.

It can be a mistake in pom repository / dependency definition
i.e. I want include in pom groupId:org.clapper artifactId:javautil
The home page of clapper say use:
http://software.clapper.org/javautil
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<id>clapper-org-maven-repo</id>
<name>org.clapper Maven Repo</name>
<url>http://maven.clapper.org/</url>
<layout>default</layout>
</repository>
...
</repositories>
and
<dependency>
<groupId>org.clapper</groupId>
<artifactId>javautil</artifactId>
<version>3.1.2</version>
</dependency>
It don't work! I got "Multiple annotations found at this line"!!!
If I use dependency from
https://github.com/shilad/wikibrain/blob/master/wikibrain-utils/pom.xml
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<id>clapper-org-maven-repo</id>
<name>org.clapper Maven Repo</name>
<url>http://maven.clapper.org/</url>
<layout>default</layout>
</repository>
+
<dependency>
<groupId>org.clapper</groupId>
<artifactId>javautil</artifactId>
<version>3.1.1</version>
</dependency>
It work fine!!!

Related

Dependency 'me.sargunvohra.lib:pokekotlin:2.3.0' not found

I'm trying to use the PokeAPI for a Java Project. It should work, however, when I try to add the dependancy to my pom.xml, it doesn't recognise it. I have the files downloaded from the github, and have the following code in my pom.xml:
<dependency>
<groupId>me.sargunvohra.lib</groupId>
<artifactId>pokekotlin</artifactId>
<version>2.3.0</version>
</dependency>
files
But I keep getting this error:
Could not find artifact me.sargunvohra.lib:pokekotlin:pom:2.3.0 in
central (https://repo.maven.apache.org/maven2)
Does anyone know how to properly add this dependency? The code below does not work when I try to use it.
PokeApi pokedex = new PokeApiClient ();
PokemonSpecies pokemon = pokedex.getPokemonSpecies (1);
System.out.println(pokemon);
P.S. I have tried to invalidate cache and restart, that does not work either.
The artifact is located at Spring Plugins repository (https://repo.spring.io/plugins-release/) so you need to add it to your pom.xml as follows:
<repositories>
<repository>
<id>spring-plugins-release</id>
<name>Spring Plugins</name>
<url>https://repo.spring.io/plugins-release/</url>
</repository>
</repositories>

"Unable to create Maven project from repository."

I'm currently getting this error doing Maven Site:
Unable to create Maven project from repository.
My configuration:
<url>grocery.com</url>
<distributionManagement>
<repository>
<id>grocery</id>
<url>grocery.com</url>
</repository>
</distributionManagement>
As far as I understand Maven Site, at the end of the process, it should pop a report website link and this link would work locally. So, I can use any url or do I need a specific one?
Here is the full bug report:
https://codeshare.io/5XbJe8
My complete pom.xml:
https://codeshare.io/ad0nr4

Not able to load maven depedency for spark-cloudant. getting Missing artifact cloudant-labs:spark-cloudant:jar:2.0.0-s_2.11

In Java I am adding below maven dependency,
<dependency>
<groupId>cloudant-labs</groupId>
<artifactId>spark-cloudant</artifactId>
<version>2.0.0-s_2.11</version>
</dependency>
but it is not loading package even in pom.xml file showing below error,
Missing artifact cloudant-labs:spark-cloudant:jar:2.0.0-s_2.11
Can anyone help me please why it is causing issue?
I am able to add another maven dependencies but particularly this is not working..
It's not in the official maven repository. (http://search.maven.org/#search%7Cga%7C1%7Cspark-cloudant)
But when you check: https://mvnrepository.com/artifact/cloudant-labs/spark-cloudant/2.0.0-s_2.11 there is note:
Note: this artifact it located at Spark Packages repository
(https://dl.bintray.com/spark-packages/maven/)
So you will need to add following to your pom.xml:
<repositories>
<repository>
<id>bintray</id>
<name>bintray.com</name>
<url>https://dl.bintray.com/spark-packages/maven/</url>
</repository>
</repositories>
EDIT:
According to https://spark.apache.org/news/new-repository-service.html
Bintray, the original repository service used for https://spark-packages.org/, is in its sunset process, and will no longer be available from May 1st. To consume artifacts from the new repository service, please replace “dl.bintray.com/spark-packages/maven” with “repos.spark-packages.org” in the Maven pom files or sbt build files in your repositories.
So this should work:
<repositories>
<repository>
<id>bintray</id>
<name>bintray.com</name>
<url>https://repos.spark-packages.org</url>
</repository>
</repositories>
Check your maven repo to verify that the file name and version matches what you've specified. Most Maven repo's give you an example of what to use, copy/paste.
ex: Sonatype Nexus is a repo that I use and they let you search and get snippets so you never have to worry about typing things wrong.

Plugin org.apache.maven.plugins:maven-compiler-plugin or one of its dependencies could not be resolved

I'm having some issues to configure properly my eclipse to work with maven.
I create a new project, this one is correctly build with maven in command line (mvn install), but in Eclipse I got this error:
CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:3.1 (): ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-settings:jar:2.2.1: ArtifactResolutionException: Failure to transfer org.apache.maven:maven-settings:pom:2.2.1 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-settings:pom:2.2.1 from/to central : NullPointerException pom.xml /test line 9 Maven Project Build Lifecycle Mapping Problem
Here is my settings.xml conf :
<proxy>
<active>true</active>
<protocol>http</protocol>
<username>myuser</username>
<password>$mymdp</password>
<host>myhost</host>
<port>8080</port>
<nonProxyHosts>some.host.com</nonProxyHosts>
</proxy>
....
<repository>
<id>central</id>
<name>central repo m2</name>
<url>http://central.maven.org/maven2</url>
</repository>
I choose the correct maven installation (in Preference -> Maven -> Install)
I also direct my user settings on the correct settings.xml (Preferences -> Maven -> User Settings)
But I still got this error in Eclipse and everything goes well with maven command line. Do you have and idea?
You only need to delete one folder it is throwing error for. Just go to your M2 repo and org/apache/maven/plugins/maven-compiler-plugins and delete the folder 2.3.2
Have you tried to remove the proxy username and password? A similar poster encountered that issue:
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-jar-plugin:2.3.2 or one of its dependencies could not be resolved
Failing that I found the following worked:
Delete project in Eclipse (but do not delete the contents on disk)
Delete all files in your Maven repository
Re-download all Maven dependencies:
mvn dependency:resolve
Start up Eclipse
Ensure that Eclipse is configured to use your external Maven installation (Window->Preferences->Maven->Installations)
Re-import the existing project(s) into Eclipse
Ensure that there are no Maven Eclipse plugin errors on the final screen of the project import
I was getting this problem when using IBM RSA 9.6.1 when building a brand new development machine. The problem for me ended up being because of HTTPS on the Global Maven repository. My solution was to create a Maven settings.xml that forced it to use HTTP.
The key to me was that the central repository was empty when I exploded it under Maven Repositories -- > Global Repositories
Using the following settings file worked for me:
<settings>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>insecurecentral</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>insecurecentral</id>
<!--Override the repository (and pluginRepository) "central" from the Maven Super POM -->
<repositories>
<repository>
<id>central</id>
<url>http://repo.maven.apache.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://repo.maven.apache.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
I got the idea from this stackoverflow question.
The issue has been resolved while installation of the maven settings is provided as External in Eclipse. The navigation settings are Window --> Preferences --> Installations. Select the External as installation Type, provide the Installation home and name and click on Finish. Finally select this as default installations.
I accidentally turned on offline mode.
To disable it: in the Maven tool window, click The Toggle Offline Mode button.
I also got the same issue and not able to create a jar, and I found that in Windows-->Prefernces-->Java-->installed JREs By default JRE was added to the build path of newly
created java project so just changed it to your prefered JDK.
Find your Maven local repository, navigate to maven-compiler-plugin, delete the 3.8.1 folder, so that the Maven will redownload it again.
For example:
C:\Users\mkyong.m2\repository\org\apache\maven\plugins\maven-compiler-plugin

maven: how to prevent plugin updates

Similar to this question, I can't do a glassfish deploy because some server in Australia is down at the moment. I've had the artifacts cached locally for months.
How can I tell maven to not attempt to update the plugin (and its dependencies)? I tried adding the following to my pom, but it didn't help:
<pluginRepositories>
<pluginRepository>
<id>ocean</id>
<url>http://maven.ocean.net.au</url>
<releases>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
I also tried the command line switches. There's -npu, which didn't seem to help with Maven 2.2.1. On Maven 3 the docs say "Ineffective, only kept for backward compatibility", so I don't have a lot of hope for that one.
We will be moving to Nexus soon, but there ought to be a simple way to tell maven not to attempt a plugin update.
Use the -o or --offline switch to work offline - this should make Maven not bother to check any repositories for new updates or snapshots, as if you did not have network access.
Additionally - are you specifying the <version> for each of your plugins? There should be no need to check for updates to release versions of a plugin.
If you use maven 2 there's a file called plugin-registry.xml where you can specify the version of each plugin. The ugly thing about this file, is that it has to be copied / installed on each box that uses maven (ci server, dev boxes, etc).
The benefit is that you can specify a version, and one it's downloaded, it won't be updated again.
If you migrate to maven 3, this has been sorted out, and you can specify the version you want on the pom.

Categories

Resources