maven could not resolve project dependencies? - eclipse

When i try to make a mvn deploy i am getting this error:
[ERROR] Failed to execute goal on project cross-automation-config: Could not resolve dependencies for project com.desp.cross.commons:cross-automation-config:jar:0.0.1-SNAPSHOT: Failed to collect dependencies for [com.desp.qc:automation-commons-config:jar:0.0.7 (compile), com.desp.cross.commons:cross-automation-utils:jar:0.0.1-SNAPSHOT (compile)]: Failed to read artifact descriptor for com.desp.cross.commons:cross-automation-utils:jar:0.0.1-SNAPSHOT: Failure to find com.desp.cross.commons:cross-automation-commons:pom:0.0.1-SNAPSHOT in http://repo.jenkins-ci.org/public/ was cached in the local repository, resolution will not be reattempted until the update interval of repo.jenkins-ci.org has elapsed or updates are forced -> [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/DependencyResolutionException
Into the project (cross-automation-config) i have these dependencies
<dependency>
<groupId>com.desp.qc</groupId>
<artifactId>automation-commons-config</artifactId>
</dependency>
<dependency>
<groupId>com.desp.cross.commons</groupId>
<artifactId>cross-automation-utils</artifactId>
</dependency>
This project has a parent project, which i don't considerate necessary to put in here.
I know that this is a dependencies problem. What i don't understand is why eclipse can download those dependencies, without any error, and maven can not
Do you have an idea about what is going on?

It looks like your maven is not able to find this dependencies in your local repository.
You should try to build first those two projects: automation-commons-config and cross-automation-utils (be careful if there are dependent in each other).

Related

How to fix Missing requirement for javax.imageio while building Eclipse-CDT using Maven?

I downloaded the eclipse cdt source package org.eclipse.cdt-CDT_9_8_1.tar.xz from https://git.eclipse.org/c/cdt/org.eclipse.cdt.git and using maven 3.6.1 i tried to build it with command mvn clean install. Some packages were downloaded from repos and at the end it exited with the below error message
I need to build cdt from source as i want some changes in CDT source code. I am not an expert in Maven, not sure what's going wrong. Please help to resolve the issue
[INFO] Resolving dependencies of MavenProject: org.eclipse.cdt:org.eclipse.cdt.build.gcc.core:1.0.1-SNAPSHOT # D:\Eclipse\Sources\CDT9.8.1_GIT\cdt-releng\org.eclipse.cdt\build\org.eclipse.cdt.build.gcc.core.polyglot.build.properties
[ERROR] Cannot resolve target definition:
[ERROR] Software being installed: com.sun.xml.bind 2.2.0.v201505121915
[ERROR] Missing requirement: com.sun.xml.bind 2.2.0.v201505121915 requires 'java.package; javax.imageio 0.0.0' but it could not be found
[ERROR] Failed to resolve target definition D:\Eclipse\Sources\CDT9.8.1_GIT\cdt-releng\org.eclipse.cdt\releng\org.eclipse.cdt.target\cdt.target: See log for details -> [Help 1]
[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] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MavenExecutionException
The issue here is, that some plugins do not define a RequiredExecutionEnvironment. If such a plugin depends on a JRE package the build fails with the given error.
In Tycho it is possible to define such an environment:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<!-- needed as some plugins do not set a execution environment they would fail to get jre packages (eg. javax.imageio) -->
<executionEnvironment>JavaSE-1.8</executionEnvironment>
</configuration>
</plugin>

Class library resolving error in endpoints-framework:discoveryDocs

I am trying to migrate my project from endpoints v1 to endpoints v2 but cannot create discovery docs. running
$ mvn -DskipTests -X endpoints-framework:discoveryDocs
leads to a build failure
[ERROR] Failed to execute goal com.google.cloud.tools:endpoints-framework-maven-plugin:1.0.0:discoveryDocs (default-cli) on project myproject: Execution default-cli of goal com.google.cloud.tools:endpoints-framework-maven-plugin:1.0.0:discoveryDocs failed: A required class was missing while executing com.google.cloud.tools:endpoints-framework-maven-plugin:1.0.0:discoveryDocs: org/apache/commons/dbutils/ResultSetHandler
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>com.google.cloud.tools:endpoints-framework-maven-plugin:1.0.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/me/.m2/repository/com/google/cloud/tools/endpoints-framework-maven-plugin/1.0.0/endpoints-framework-maven-plugin-1.0.0.jar
[ERROR] urls[1] = file:/Users/me/.m2/repository/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar
...
I can see that the respective .jar file is in the -cp parameters:
..., /Users/me/.m2/repository/commons-dbutils/commons-dbutils/1.6/commons-dbutils-1.6.jar, ...
but not in the error urls (urls[0..48] = ...)
Building and testing runs correctly (mvn verify etc), so the libraries do actually exist and work, but I think it cannot actually run without discovery docs.
Any ideas what I could have missed? There seem to be a huge number of .jar files in that classpath, is there some limit?
You have to update the endpoints-framework-maven-plugin to version 1.0.1:
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>endpoints-framework-maven-plugin</artifactId>
<version>1.0.1</version>
<configuration>
<!-- plugin configuration -->
<hostname>YOUR-APPP-ID.appspot.com</hostname>
</configuration>
</plugin>
There was a bug in version 1.0.0, see here:
https://github.com/GoogleCloudPlatform/endpoints-framework-maven-plugin/issues/32

Installing Tycho via Maven with offline flag

I want to run Tycho in an offline environment. Therefore, I mirrored a demo repository on GitHub and executed the command mvn clean install on a computer with internet access. The build succeeded, however when I try to run mvn -o install to install all dependencies in offline mode, I recieve the following exception:
C:\Users\user\Documents\MVN_Test\itp01>mvn clean -e -o install
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[WARNING] No explicit target runtime environment configuration. Build is platform dependent.
[INFO] Computing target platform for MavenProject: tycho.demo.itp01:tycho.demo.itp01:1.0.0-SNAPSHOT # C:\Users\user\Documents\MVN_Test\itp01\tycho.demo.itp01\pom.xml
[INFO] Adding repository http://download.eclipse.org/releases/helios
[ERROR] Internal error: java.lang.RuntimeException: Failed to load p2 repository with ID 'helios' from location http://download.eclipse.org/releases/helios: Repository system is offline and no local cache available for http://download.eclipse.org/releases/helios -> [Help 1]
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: Failed to load p2 repository with ID 'helios' from location http://download.eclipse.org/releases/helios
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:121)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.RuntimeException: Failed to load p2 repository with ID 'helios' from location http://download.eclipse.org/releases/helios
at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.loadMetadataRepository(TargetPlatformFactoryImpl.java:302)
at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.gatherExternalInstallableUnits(TargetPlatformFactoryImpl.java:270)
at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.createTargetPlatform(TargetPlatformFactoryImpl.java:176)
at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.createTargetPlatform(TargetPlatformFactoryImpl.java:128)
at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.createTargetPlatform(TargetPlatformFactoryImpl.java:1)
at org.eclipse.tycho.p2.manager.ReactorRepositoryManagerImpl.computePreliminaryTargetPlatform(ReactorRepositoryManagerImpl.java:84)
at org.eclipse.tycho.p2.resolver.P2DependencyResolver.computePreliminaryTargetPlatform(P2DependencyResolver.java:223)
at org.eclipse.tycho.core.resolver.DefaultTychoResolver.resolveProject(DefaultTychoResolver.java:109)
at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:95)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:266)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
... 11 more
Caused by: org.eclipse.equinox.p2.core.ProvisionException: Repository system is offline and no local cache available for http://download.eclipse.org/releases/helios
at org.eclipse.tycho.p2.remote.RemoteRepositoryCacheManager.createCache(RemoteRepositoryCacheManager.java:57)
at org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory.getLocalFile(SimpleMetadataRepositoryFactory.java:66)
at org.eclipse.equinox.internal.p2.metadata.repository.SimpleMetadataRepositoryFactory.load(SimpleMetadataRepositoryFactory.java:88)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.factoryLoad(MetadataRepositoryManager.java:57)
at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:768)
at org.eclipse.equinox.internal.p2.repository.helpers.AbstractRepositoryManager.loadRepository(AbstractRepositoryManager.java:668)
at org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager.loadRepository(MetadataRepositoryManager.java:96)
at org.eclipse.tycho.p2.remote.RemoteMetadataRepositoryManager.loadRepository(RemoteMetadataRepositoryManager.java:61)
at org.eclipse.tycho.p2.remote.RemoteMetadataRepositoryManager.loadRepository(RemoteMetadataRepositoryManager.java:53)
at org.eclipse.tycho.p2.target.TargetPlatformFactoryImpl.loadMetadataRepository(TargetPlatformFactoryImpl.java:298)
... 22 more
[ERROR]
[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/InternalErrorException
I have found the following information, these may be a bug:
Demo project which demonstrates offline build failure
The problem is reproducible always with the following steps:
rm -rf ~/.m2/repository
unzip demo-project.zip
cd mvn-demo-parent/releng
mvn clean install
Build succeeds
mvn clean -o clean install
Build fails because "Repository system is offline and no local cache available for http:// download.eclipse.org/releases/mars"
From Bug 474885 - Build with -o flag fails with "Failed to resolve target definition" message:
This was a bug in tycho 0.24.0 and fixed in Tycho 0.25.0.
To use tycho 0.25.0 From Tycho/Release Notes/0.25
Tycho 0.25.0 is currently in development. To try out the most recent snapshot build of 0.25.0, simply add the following snippet to your (parent) pom.xml or settings.xml, and set the property for the Tycho version (e.g. tycho-version) to 0.25.0-SNAPSHOT.
<pluginRepositories>
<pluginRepository>
<id>tycho-snapshots</id>
<url>https://repo.eclipse.org/content/repositories/tycho-snapshots/</url>
</pluginRepository>
</pluginRepositories>

What type of new project for the Hibernate tutorial?

I am trying to follow this Hibernate tutorial:
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/tutorial.html
which seems pretty easy & straightforward, but I got stuck on the very 1st decision point: When selecting File > New Project to use the tutorial's suggested pom.xml, which of the many type of projects should I select?
Intuitively, I thought of creating a new Maven project:
Maven > Maven Project [Next]
[v] Create a simple project (skip archtype selection) [Next]
But at step #3 it prompts me for the very same information provided by the tutorial's pom.xml. So I am thinking the tutorial was aiming at creating a "blank project" and then manually adding the suggested pom.xml to it?
But what type of "blank project" would that be?
Java?
Java EE?
EJB?
JAXB?
JPA?
Maven?
Does it matter?
(sorry, don't have much experience (yet) with this new jargon, will get there eventually)
UPDATE 1: Actually, the proposed method of selecting a Maven project (regardless whether starting with bogus or correct info) doesn't work:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.hibernate.tutorials:hibernate-tutorial
POM Location: C:\Users\Daniel\Workspace\First Hibernate Tutorial\pom.xml
Validation Messages:
[0] 'dependencies.dependency.version' is missing for org.hibernate:hibernate-core:jar
[1] 'dependencies.dependency.version' is missing for javax.servlet:servlet-api:jar
[2] 'dependencies.dependency.version' is missing for org.slf4j:slf4j-simple:jar
[3] 'dependencies.dependency.version' is missing for javassist:javassist:jar
Reason: Failed to validate POM for project org.hibernate.tutorials:hibernate-tutorial at C:\Users\Daniel\Workspace\First Hibernate Tutorial\pom.xml
I am going to check now whether creating a plain Java project, then converting it to a Maven (after copying that tutorial's pom.xml) will do the trick.
UPDATE 2: Creating a plain Java project, then converting it to a Maven (after copying that tutorial's pom.xml) produces the same errors.
What am I missing?
UPDATE 3: Thanks to #cowls tip below I found that "I" was missing were the version numbers for the Maven dependencies. "I" because it's the tutorial that was missing them (what kind of a tutorial is this?)
Once I used some known version numbers, e.g.:
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.5.6-Final</version>
</dependency>
<!-- Because this is a web app, we also have a dependency on the servlet api. -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>1.2_02</version>
</dependency>
<!-- Hibernate uses slf4j for logging, for our purposes here use the simple backend -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.5.10</version>
</dependency>
<!-- Hibernate gives you a choice of bytecode providers between cglib and javassist -->
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.8.0.GA</version>
</dependency>
</dependencies>
I have been able to get rid of that scary FATAL ERROR message. That error message's "tip" BTW was counter-productive as it was pointing to the wrong direction:
[INFO] Error building POM (may not be this project's POM).
Now... I am still getting a build error, albeit much less scary:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building First Hibernate Tutorial
[INFO] task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\dben\ws-study\First Hibernate Tutorial\src\main\resources
Downloading: http://repo1.maven.org/maven2/javax/servlet/servlet-api/1.2_02/servlet-api-1.2_02.pom
[INFO] Unable to find resource 'javax.servlet:servlet-api:pom:1.2_02' in repository central (http://repo1.maven.org/maven2)
Downloading: http://repo1.maven.org/maven2/javax/servlet/servlet-api/1.2_02/servlet-api-1.2_02.jar
[INFO] Unable to find resource 'javax.servlet:servlet-api:jar:1.2_02' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) javax.servlet:servlet-api:jar:1.2_02
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=javax.servlet -DartifactId=servlet-api -Dversion=1.2_02 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=javax.servlet -DartifactId=servlet-api -Dversion=1.2_02 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.hibernate.tutorials:hibernate-tutorial:jar:1.0.0-SNAPSHOT
2) javax.servlet:servlet-api:jar:1.2_02
----------
1 required artifact is missing.
for artifact:
org.hibernate.tutorials:hibernate-tutorial:jar:1.0.0-SNAPSHOT
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
Interesting tutorial: I was expecting to learn some Hibernate but instead I am finding myself learning Maven. :)
UPDATE 4: I corrected the javax.servlet version to 2.4 and all is well now.
LESSONS LEARNED:
Maven's pom.xml requires a <version> for each & every dependency.
That <version>'s value must be valid.
Creating a new Maven project, then replacing its pom.xml entirely would work, but it still creates it with the incorrect subdirectory under Workspace because there is no way to define the <name> in the wizard-based creation process.
Creating a plain Java Project, then adding the pom.xml to its directory, then refreshing the Package Explorer view is the recommended way to go (no subdirectory renaming necessary).
That tutorial recommends Maven's "standard layout" but then breaks it by using the declared package "org.hibernate.tutorial.domain" which does not match the expected package "main.java.org.hibernate.tutorial.domain"... Do take Eclipse's fix suggestion to rename the package to "main.java.org.hibernate.tutorial.domain". (and move Event.java to the newly renamed package!)
The Hibernate configuration command (mvn exec:java -Dexec.mainClass="org.hsqldb.Server" etc.) must be run from the directory where pom.xml resides.
Easiest is to create a new maven project and use the maven-archetype-quickstart archetype.
This will create a basic maven project and you should be able to go from there.
Note that a maven project is just a Java project that uses Maven to build it, hence you will see a pom.xml file in your project.
Using this pom file you can build the project, include external dependencies and much more. I would suggest using the m2e plugin if you are developing with eclipse to help you manage the maven projects better: http://eclipse.org/m2e/
Each dependency you specify should have a version number associated with it.
e.g.
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
To get the correct version number, just google artifactid maven dependency. E.g. hibernate-core maven dependency.
Look for the link for the maven central repository - i.e. http://mvnrepository.com. If you cant find it on Google you can search directly on the site, however I find its search feature quite poor.
Put your Java code in src/main/java and your resources in src/main/resources (e.g. xml files etc).
You can then build the project using mvn clean install

Maven compile dependency error javax.mail missing

I am following the instructions in the lift guide book for set up the basic hello world application (On windows 7 using cygwin)
After doing this to start
mvn archetype:generate -U -DarchetypeGroupId=net.liftweb \
-DarchetypeArtifactId=lift-archetype-blank -DarchetypeVersion=2.0 \
-DarchetypeRepository=http://scala-tools.org/repo-releases \
-DgroupId=demo.helloworld -DartifactId=helloworld \
-Dversion=1.0-SNAPSHOT
Then
cd helloworld
mvn jetty:run
I get the following error
[ERROR] Failed to execute goal on project helloworld: Could not resolve dependencies for project demo.helloworld:helloworld:war:1.0-SNAPSHOT: Failed to collect dependencies for [net.liftweb:lift-mapper:jar:2.0 (compile), javax.servlet:servlet-api:jar:2.5 (provided), junit:junit:jar:4.7 (test), org.mortbay.jetty:jetty:jar:[6.1.6,7.0) (test), org.scala-lang:scala-compiler:jar:2.7.7 (test)]: No versions available for javax.mail:mail:jar:[1.4,1.4.3) within specified range -> [Help 1]
Before that there were two warning for checksum errors for the metadata.xml file. I put the checksum ignore in my pom file.
I downloaded the mailx API package from Oracle and put it in my classpath. After trying various solutions found for similar sounding errors nothing seems to work. Can someone suggest something?
PS: I searched for two days for the answers and tried all the solutions that came up in various threads but found no answer in them.
You need to explicitly add java.net repository to your pom.xml. (Which is very weird)
<repositories>
<repository>
<id>Java.Net</id>
<url>http://download.java.net/maven/2/</url>
</repository>
<!-- other repos -->
</repositories>