Maven- Could not resolve dependency - java

I am a beginner in using Maven.. I tried to add Grobid (for pdf parsing) in maven. The dependency I gave is :
<dependency>
<groupId>org.grobid</groupId>
<artifactId>grobid-core</artifactId>
<version>0.3.4</version>
</dependency>
But on building the pom it shows the following error:
[ERROR] Failed to execute goal on project Miner: Could not resolve dependencies for project Miner:war:1.0-SNAPSHOT: Failed to collect dependencies at org.grobid:grobid-core:jar:0.3.4 -> org.chasen:crfpp:jar:1.0.2: Failed to read artifact descriptor for org.chasen:crfpp:jar:1.0.2: Could not transfer artifact org.chasen:crfpp:pom:1.0.2 from/to 3rd-party-local-repo (file:///${basedir}/lib/): Repository path /${basedir}/lib does not exist, and cannot be created. -> [Help 1]
I have gone through different questions related..I tried after adding pom etc. Still it is not working.. why this error comes..do we have to do extra codes for Grobid..?

add the below repository in pom or .m2/settings.xml
<repositories>
<repository>
<id>Grobid repository</id>
<url>https://mvnrepository.com/artifact/org.grobid/grobid-core</url>
</repository>
</repositories>

Start by downloading maven from http://mirror.vorboss.net/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.zip
Unzip it somewhere, then assuming your're on windows
1) set an environment variable M2_HOME to point at the unziped folder.
2) add %M2_HOME%/bin to your PATH environment variable
3) go to your home directory (probably C:/Users/????? and create a .m2 folder
4) move the settings.xml file from the maven unzippped/conf directory to the directory created in step 3.
5) you may have to set the proxy element correctly in your settings.xml file
It should work.

You might be new to maven, but it explicit the problem here:
Repository path /${basedir}/lib does not exist, and cannot be created.
This means that Maven could not locate the repository path you are trying to access. Or (from the "cannot be created") can't find the directory where to save the content.
As you did not provide pom.xml to look further, you'll have to find all ${basedir}/lib path in your pom.xml and in your maven settings (default to %USERPROFILE%/.m2/settings.xml or $HOME/.m2/settings.xml), then you may want to
try with an absolute path.
use an actual HTTP repository where that dependency and child' dependencies are.
use a repository server such as Sonatype Nexus or Archiva and provide a mirror/copy of it.

Related

Unable to download artifactory from search.maven.org

I'm trying to do a clean install on this project
https://github.com/jberet/jberet-wildfly-samples
I'm stucked with this error:
Could not resolve dependencies for project
org.jberet.samples:clusterInfinispan:war:1.4.0.Alpha-SNAPSHOT: Failed
to collect dependencies at
org.jberet:jberet-wildfly-cluster-infinispan:jar:1.3.0.Final: Failed
to read artifact descriptor for
org.jberet:jberet-wildfly-cluster-infinispan:jar:1.3.0.Final: Failure
to find org.jberet:jberet-wildfly:pom:1.4.0.Alpha-SNAPSHOT
It appears that artifactory is ONLY available on search.maven.org
I tried to do either a force update -U and to manually clean the local repo directory, but nothing changes.
I wonder if I have to manually add the above repo or should automatically seek there
Any hints?
I think he didn't publish 1.4.0.Alpha in maven center.
You can try to change 1.4.0.Alpha to 1.3.0.Final in pom.xml like this
<parent>
<groupId>org.jberet</groupId>
<artifactId>jberet-parent</artifactId>
<version>1.3.0.Final</version>
</parent>
<groupId>org.jberet.samples</groupId>
<artifactId>wildfly-jberet-samples</artifactId>
<version>1.3.0.Final</version>
And use mvn clean install -Pwildfly
Wow, you are right: https://search.maven.org/artifact/org.jberet/jberet-wildfly-cluster-infinispan/1.3.0.Final/jar
I'm not sure if anybody here on Stackoverflow will be able to help you.
Continue your issue with jberet's community: https://github.com/jberet/jberet-wildfly-samples/issues/2 you have to solve it with them.
EDIT:
Now that I think more about it, it's also possible to add their SNAPSHOT repository to your settings.xml file: https://maven.apache.org/settings.html#Repositories but I didn't find link to their repository.
Anyway: witnessing this I would stay away from jberet project, because this is a big failure on their part.
Read the maven error: "failure to find org.jberet:jberet-wildfly:pom:1.4.0.Alpha-SNAPSHOT" means there is a a dependency referencing org.jberet:jberet-wildfly:pom 1.4.0.Alpha-SNAPSHOT.
Either the repository forbids deploying SNAPSHOT (and it make sense for central)
either your configuration forbids downloading SNAPSHOT (see http://maven.apache.org/settings.html#Repositories).
You should check local pom.xml referencing 1.4.0.Alpha-SNAPSHOT and replace it with a non SNAPSHOT (1.4.0.Alpha for beginners).

Project build error with Maven under Eclipse : must specify an absolute path

I created a new project using the following maven command:
mvn archetype:generate -DarchetypeCatalog=local -DarchetypeGroupId=com.github.xlongshu.maven -DarchetypeArtifactId=archetype-quickstart
I then entered the following values:
'groupId': com.example.mycompany
'artifactId': myproject
'version' 1.0-SNAPSHOT: :
'package' com.example.mycompany: :
I received the following warnings:
[WARNING] CP Don't override file /Users/user/workspace/myproject/pom.xml
[WARNING] CP Don't override file /Users/user/workspace/myproject/README.md
I then import this new project into Eclipse Oxygen 4.7.3a (no update available for now) using Import... > Existing Maven Projects
And I then get the following errors (under Eclipse in pom.xml file) :
Project build error: 'dependencyManagement.dependencies.dependency.systemPath' for jdk.lib:jconsole:jar must specify an absolute path but is ${env.JAVA_HOME}/lib/jconsole.jar pom.xml /myproject line 1 Maven pom Loading Problem
Project build error: 'dependencyManagement.dependencies.dependency.systemPath' for jdk.lib:tools:jar must specify an absolute path but is ${env.JAVA_HOME}/lib/tools.jar pom.xml /myproject line 1 Maven pom Loading Problem
However, from command line, everything works well:
mvn validate
mvn compile
The error seems to come from parent POM:
<dependency>
<groupId>jdk.lib</groupId>
<artifactId>jconsole</artifactId>
<version>${jdk.version}</version>
<scope>system</scope>
<systemPath>${jconsolejar}</systemPath>
</dependency>
where jconsolejar property is defined as follow:
<jconsolejar>${env.JAVA_HOME}/lib/jconsole.jar</jconsolejar>
What could I do to solve this error in a clean and efficient way ?
(Maven version: 3.5.3)
I had the same issue when I use a variable to specify a system path for a local jar.
The solution I use is to replace the directory with an absolute path such as
C:\Users\XXXX\eclipse-workspace\PROJECTNAME\src\main\webapp\WEB-INF\lib
The error is gone but a warning is left because this is not recommended

Maven , How to add dependency of local system java-source?

I want to build one jar that includes a child module which depends on other package of my own project.
The output one jar should include all the related class (both from jar and my own project's classes).So the child module's classes is the base classes that should be included in the output jar,and these import some classes of my own project.All the related classes in my own project should be included.
for more detail please visit How to automatically collect all related class into one jar (use maven)?
Here is what I already find:
<project>
<dependencies>
<dependency>
<scope>system</scope>
<systemPath>D:\how\to\write</systemPath>
<groupId>how.to.write</groupId>
<artifactId>how-to-write</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>java-source</type>
</dependency>
</dependencies>
</project>
The error message is : Could not find artifact how.to.write:how-to-write:jar:sources:0.0.1-SNAPSHOT at specified path D:\how\to\write
the path D:\how\to\write contains my own project's classes that could support the build
Your maven dependency will look for a jar file with name how.to.write:how-to-write:jar:sources:0.0.1-SNAPSHOT in D:\how\to\write directory. Since you do not have one, the build will fail.
If your own project does not use maven, then you should create a jar file and place it in D:\how\to\write location and rename it to how.to.write:how-to-write:jar:sources:0.0.1-SNAPSHOT. Then your build mvn clean install will be success.
The command for creating jar file is jar cf jar-file input-file(s).
Have a look at this page on how to create a jar file

importing external jar inside eclipse

I'm writing assignment on coursera.org Java course. I'm using Maven and I have external jars that I have to use in this course (course requirements).
This is part of my pom.xml:
<dependency>
<groupId>org.coursera.algs4part1</groupId>
<artifactId>stdlib</artifactId>
<version>1.0</version>
</dependency>
I can't make java compiler import the external jar file. Below, following errors occur:
The import org.coursera.algs4part1.stdlib cannot be resolved
But I've successfully added the jar to maven:
What am I missing?
You need to do the following steps if you have a eclipse-maven plugin installed.
Run the command mvn eclipse:eclipse
Go to Project Properties > Build Path > Libraries tab > Add Variable... button > Configure Variables... button > New button. Enter the variable name as M2_REPO and its value/path to the Maven Repository path (Usually it's like C:\Users\<username>\.m2\repository.)
1.create a folder src\lib and paste your jar file
2.your pom.xml should be like this.
<groupId>org.coursera.algs4part1</groupId>
<artifactId>stdlib</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${basedir}\src\lib\stdlib.jar</systemPath>
</dependency>
Hopefully this will solve your problem and for more details visit http://noexceptionfound.blogspot.in/

2d vector class for PlayN?

I see the jbox2d Vec2 class in the repository:
http://code.google.com/p/playn/source/browse/gwtbox2d/src/org/jbox2d/common/Vec2.java
How do I make the PlayN port of JBox2D package accessible to my code? I'm using Eclipse but my project does not appear to be aware of the package.
Update:
Following the example here, I've added playn-jbox2d as a dependency in my core/pom.xml file. However, when I load my project I get the following error:
ArtifactDescriptorException: Failed to read artifact descriptor for
com.googlecode.playn:playn-jbox2d:jar:1.1.1:
ArtifactResolutionException: Could not transfer artifact
com.googlecode.playn:playn-jbox2d:pom:1.1.1 from/to central
(http://repo1.maven.org/maven2): Failed to transfer
http://repo1.maven.org/maven2/com/googlecode/playn/playn-jbox2d/1.1.1/playn-jbox2d-1.1.1.pom.
Error code 416, Requested Range Not
Satisfiable pom.xml /myproject-core line 1 Maven Dependency Problem
After a bit of a goose chase, I figured out how to enable this. Following the example here, I manually added playn-jbox2d as a dependency in my core/pom.xml file. Here is what that section of my pom.xml file now looks like:
<dependencies>
<dependency>
<groupId>com.googlecode.playn</groupId>
<artifactId>playn-core</artifactId>
<version>${playn.version}</version>
</dependency>
<dependency>
<groupId>com.googlecode.playn</groupId>
<artifactId>playn-jbox2d</artifactId>
<version>${playn.version}</version>
</dependency>
</dependencies>
Then in Eclipse:
Right-click core directory in Package Explorer window > Maven > Update Dependencies
Thanks to all who offered assistance.
You need to add JBox2D library to your workspace. Follow Basic guide for importing and building JBox2D. There are instructions for eclipse as well. Or you can download JBox2D jars and add them to eclipse. Here is a tutorial how to add jars to your workspace.

Categories

Resources