I am following the Hibernate documentation and trying to create a Maven project in my eclipse. I have created a new maven project by selecting default options shown in eclipse except for groupId, artifactId and version details which I have selected (org.hibernate.tutorials, hibernate-tutorial, 1.0.0-SNAPSHOT respectively) based on the information present in pom.xml shown in Hibernate documentation. After that I have replaced the pom.xml file in my project with the one shown in documentation. Then I have added version details for each of the dependencies which are missing in the documentation. Here is my final pom.xml file:
<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>org.hibernate.tutorials</groupId>
<artifactId>hibernate-tutorial</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>First Hibernate Tutorial</name>
<build>
<!-- we dont want the version to be part of the generated war file name -->
<finalName>${artifactId}</finalName>
</build>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.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>2.5</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.6</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
</dependencies>
Now in eclipse I see below errors:
1) Maven Configuration Problem:
Failure to transfer
org.apache.maven.plugins:maven-resources-plugin:pom:2.5 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.plugins:maven-resources-plugin:pom:2.5 from/to
central (http://repo.maven.apache.org/maven2): The operation was
cancelled.
2) Maven Problems:
CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 (): ArtifactDescriptorException: Failed to read artifact descriptor for org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1: UnresolvableModelException: Failure to transfer org.codehaus.plexus:plexus-containers:pom:1.0.3 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.codehaus.plexus:plexus-containers:pom:1.0.3 from/to central (http://repo.maven.apache.org/maven2): The operation was cancelled.
3) Maven Problem:
CoreException: Could not get the value for parameter compilerId for plugin execution default-testCompile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be resolved: Failure to transfer org.codehaus.plexus:plexus-utils:jar:1.4.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.codehaus.plexus:plexus-utils:jar:1.4.1 from/to central (http://repo.maven.apache.org/maven2): The operation was cancelled.
4) Maven Problem:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (execution: default-compile, phase: compile)
5) Maven Problem:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (execution: default-testCompile, phase: test-compile)
6) Maven Problem:
Project configuration is not up-to-date with pom.xml. Run Maven->Update Project or use Quick Fix.
Update: When I build the project in eclipse I am getting below error:
Errors occurred during the build.
Errors running builder 'Maven Project Builder' on project 'hibernate-tutorial'.
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5
Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5
Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5
Please help me how can I fix these issues. I am blocked at first step of learning Hibernate.
Thanks in advance.
Exit eclipse
Remove (or rename to be safe) your .m2/repository directory, it will be located in your home directory on your machine.
Start eclipse, right click your project, select Update Maven Project, check Force Update of Snapshots/Releases, press OK
It did not allow me to rename .m2 dir. Below are the detailed steps which resolved my error:
* I removed project from Eclipse
* Exited Eclipse
* Deleted (not shift deleted) .m2 folder from C/Users/Kshitija/ location
* Opened Eclipse, created maven project again
* Right clicked on the project -> Maven -> update project -> selected an option of "check Force Update of Snapshots/Releases", press OK
as soon as project is built, the error disappeared
Related
I was just about to get started with the vaadin start project (https://start.vaadin.com/). I downloaded it and imported it into eclipse. However after that I got a Maven import error on line 112+ telling me there is a "Missing artifact org.vaadin.artur:a-vaadin-helper:jar:1.5.0"
<dependency>
<groupId>org.vaadin.artur</groupId>
<artifactId>a-vaadin-helper</artifactId>
<version>1.5.0</version>
</dependency>
All other dependencies can be resolved. I do not have a custom settings.xml for maven. Refreshing does not help.
The artifact is located in the Vaadin Addons repository (for which there is a definition in the pom.xml). Perhaps you are using a Maven proxy that does not include this repository?
as im trying mvn install on my project i get this :
[WARNING] The POM for com.bramosystems.oss.player:bst-player-api:jar:2.0.3 is missing, no dependency information available.
[ERROR] Failed to execute goal on project myproject-web: Could not resolve dependencies for project com.myproject:myproject-web:war:0.0.1-SNAPSHOT: Failure to find com.bramosystems.oss.player:bst-player-api:jar:2.0.3 in http://repo.geosdi.org was cached in the local repository, resolution will not be reattempted until the update interval of geosdi.org has elapsed or updates are forced ->
my main pom :
<dependency>
<groupId>com.bramosystems.oss.player</groupId>
<artifactId>bst-player-api</artifactId>
<version>2.0.3</version>
</dependency>
myproject-web pom :
<dependency>
<groupId>com.bramosystems.oss.player</groupId>
<artifactId>bst-player-api</artifactId>
<scope>provided</scope>
</dependency>
also in eclipse i have error shown on this dependency which says :
Missing artifact com.bramosystems.oss.player:bst-player-api:jar:2.0.3
i have no clue what to do..
It is up again after my post. I had the same problem.
https://groups.google.com/forum/#!topic/bst-player/onB1PNLc6kk
I have a Maven project in Eclipse and if I try to run Maven > Update project I get the following error
Failure to transfer org.apache.maven.plugins:maven-resources-plugin:pom:2.5 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.plugins:maven-resources-plugin:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): java.net.ConnectException: connection timed out to http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom
I tried to run Maven with the embedded installation and an external one - same result.
I don't have any proxy set up in Eclipse and I don't need one.
I do not reference the plugin in my POM.
Running mvn eclipse:eclipse in console works perfectly.
I'm using Eclipse Kepler and m2e 1.4.0.201.
The parent POM is
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>
Anyone have any idea why?
Adding
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
</pluginManagement>
solved the problem.
Here's the error I was getting initially:
Failure to transfer org.sonatype.oss:oss-parent:pom:9 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.sonatype.oss:oss-parent:pom:9
from/to central (http://repo.maven.apache.org/maven2): Address family
not supported by protocol family: connect
I didn't need to introduce any additional maven plugins, simply enclosing the existing plugins inside <pluginManagement> tag as described here: How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds solved it for me - hopefully it will help someone else as well.
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
I recently installed Eclipse 3.7 (Indigo) and now a wanted to start a new project using the integrated Maven plugins.
Problem is, I can't download any dependencies from the central maven 2 repository http://repo1.maven.org/maven2
After creating a new simple Maven project (without an archetype), i constantly get these Error messages:
Description Resource Path Location Type
CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2: ArtifactResolutionException: The repository system is offline but the artifact org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.2 is not available in the local repository. pom.xml /JAVA line 1 Maven Project Build Lifecycle Mapping Problem
Description Resource Path Location Type
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 pom.xml /JAVA line 1 Maven Build Problem
Description Resource Path Location Type
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (execution: default-compile, phase: compile) pom.xml /JAVA line 1 Maven Project Build Lifecycle Mapping Problem
Description Resource Path Location Type
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (execution: default-testCompile, phase: test-compile) pom.xml /JAVA line 1 Maven Project Build Lifecycle Mapping Problem
Using an archetype doesn't work at all.
Am I right to just add another repository mirror to get the needed dependencies?
If so, how do I add another one?
Update: I wrote a D:\Users\.m2\settings.xml manually and the m2e-plugin recognized it correctly:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers/>
<mirrors>
<mirror>
<id>dotsrc.org</id>
<url>http://mirrors.dotsrc.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
Problem is: I can't find a complete mirror of the Maven central repository. I tried every single one I could find on the net, but all are missing some dependencies, archetypes, etc.
Any help out there?
Try one of these.