File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Confusing Maven Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Confusing Maven Error" Watch "Confusing Maven Error" New topic
Author

Confusing Maven Error

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1066
Trying to run the very first example in Restful Java JAX-RS 2.0 book, but when I import that very first project into Intellij, add the RESTEasy libs, set the Maven directory, I get the following unhelpful error stack:

[ERROR] The project com.oreilly.rest.workbook:jaxrs-2.0-workbook-ex03_1:2.0 (/Users/mike/temp/JAX-RS/ex03_1/pom.xml) has 1 error
[ERROR] Non-resolvable parent POM: Failure to find com.oreilly.rest.workbook:jaxrs-2.0-workbook-pom:pom:1.0 in 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 and 'parent.relativePath' points at wrong local POM @ line 5, column 13 -> [Help 2]

====

This project was imported directly so how could I get this kind of error?

It looks like it at least started to download into the repositories directory (beneath .m2), but promptly gave up.

Any suggestions would be greatly appreciated.

— mike
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3646
    
  16

Import from where?

The problem seems that the parent pom, jaxrs-2.0-workbook-pom was not found. If the book came with a directory structure of examples, you should probably copy the entire directory structure to some location on your hard drive, before attempting to run maven.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9382
    
    2

Looks like the project that you are trying to build depends on another project which is a parent project of the one that you have. Normally in a multi module maven project, the parent pom is always available one level up in the directory tree. So my guess is that Maven tried to look for the parent pom one directory above your current project's pom file and since it was not able find it, it failed with this error.

Since you are following the examples from a book, better download the entire source code for the book into a single directory of your choice and try first building all the projects from the parent pom.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1066
Stephan van Hulst wrote:Import from where?

The problem seems that the parent pom, jaxrs-2.0-workbook-pom was not found. If the book came with a directory structure of examples, you should probably copy the entire directory structure to some location on your hard drive, before attempting to run maven.


Yes, that was it!!!

Thank you so vary much. I appreciate both responses here.

Java Ranch is the best.

-mike
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1066
When I run the "install" maven build command from within Intellij (the maven project which uses jetty), it works great. Prints out the customers from the in-memory DB, using

the JAX-RS Client code: Response response = client.target("http://localhost:8080/services/customers")

Yet, when I take the WAR file and put into Tomcat instead and then try to run the same test code, I get a 404 error.

*** FIGURED IT OUT ****

Needed to add the application path to the Tomcat URL, as in:

Response response = client.target("http://localhost:8080/jaxrs-2.0-workbook-ex03_1-2.0/services/customers")
.request().post(Entity.xml(xml));


Works!!!


-mike
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3646
    
  16

Eesh. This seems like a big nasty if the application ever changes name. I'm not too familiar with JAX-RS, but I'm pretty sure you can use relative paths.
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1066
Stephan van Hulst wrote:Eesh. This seems like a big nasty if the application ever changes name. I'm not too familiar with JAX-RS, but I'm pretty sure you can use relative paths.




Agreed, right now, I'm just trying to get it all working. Looks like I'm on the way.

Thanks again very much.

- mike
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

Two suggestions:

1) Place the URL in a properties file and read it from there. You can use a Maven property in the source properties file to reference the artifact name and let Maven replace the Maven property with the name and version of the artifact. That way you'll always get the right URL.

2) Add a <finalName> entry in the <build> section of your pom.xml. This way your artifact will always have the same name when it is built, making the URL more consistent.


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Confusing Maven Error