Search code examples
javamavenopenid4java

Maven "Could not resolve dependencies" for openid4java


Summary:
Running "mvn war:war" fails with errors including:
"The following artifacts could not be resolved: org.openid4java:openid4java:jar:0.9.6".

I'd chalk it up to the fact that I'm a Maven noob but I see that other people have posted to the openid4java web site stating jars are missing from Maven central for openid4java.

Details:
I'm trying to get up to speed with openid4java by running the Simple-OpenID sample app that's included in the latest version of openid4java (0.9.6.662).

According to the Readme "This demo requires apache Maven2 to build". The Readme also states "The mvn war:war task should create a war file which can be deployed by copying the war file".

Up to now I've been getting by with Ant and the Mavent Ant Tasks but I figured I'd bite the bullet today and install Maven 3.0.3. I followed the install instructions and can now successfully run "mvn --version"

When I run "mvn war:war" a number of files do indeed get downloaded to my local repository but ultimately the build fails with the following excerpted message:

[ERROR] Failed to execute goal on project simple-openid: Could not resolve dependencies for project org.openid4java:simple-openid:war:0.9.6: The following artifacts could not be resolved: org.openid4java:openid4java:jar:0.9.6, org.openid4java:openid4java-consumer:jar:0.9.6, org.openid4java:openid4java-server:jar:0.9.6, org.openid4java:openid4java-server-JdbcServerAssociationStore:jar:0.9.6, org.openid4java:openid4java-consumer-SampleConsumer:jar:0.9.6, org.openid4java:openid4java-server-SampleServer:jar:0.9.6: Failure to find org.openid4java:openid4java:jar:0.9.6 in http://repo1.maven.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 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project simple-openid: Could not resolve dependencies for project org.openid4java:simple-openid:war:0.9.6: The following artifacts could not be resolved: org.openid4java:openid4java:jar:0.9.6, org.openid4java:openid4java-consumer:jar:0.9.6, org.openid4java:openid4java-server:jar:0.9.6, org.openid4java:openid4java-server-JdbcServerAssociationStore:jar:0.9.6, org.openid4java:openid4java-consumer-SampleConsumer:jar:0.9.6, org.openid4java:openid4java-server-SampleServer:jar:0.9.6: Failure to find org.openid4java:openid4java:jar:0.9.6 in http://repo1.maven.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
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:196)

Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project org.openid4java:simple-openid:war:0.9.6: The following artifacts could not be resolved: org.openid4java:openid4java:jar:0.9.6, org.openid4java:openid4java-consumer:jar:0.9.6, org.openid4java:openid4java-server:jar:0.9.6, org.openid4java:openid4java-server-JdbcServerAssociationStore:jar:0.9.6, org.openid4java:openid4java-consumer-SampleConsumer:jar:0.9.6, org.openid4java:openid4java-server-SampleServer:jar:0.9.6: Failure 

Caused by: org.sonatype.aether.resolution.DependencyResolutionException: The following artifacts could not be resolved: org.openid4java:openid4java:jar:0.9.6, org.openid4java:openid4java-consumer:jar:0.9.6, org.openid4java:openid4java-server:jar:0.9.6, org.openid4java:openid4java-server-JdbcServerAssociationStore:jar:0.9.6, org.openid4java:openid4java-consumer-SampleConsumer:jar:0.9.6, org.openid4java:openid4java-server-SampleServer:jar:0.9.6: Failure to find org.openid4java:openid4java:jar:0.9.6 in 

Am I doing something wrong here or are the jars actually missing from the Maven repository?


Solution

  • I was able to resolve this problem by adding <type>pom</type> to the pom.xml. I found the answer in the OpenID4Java google group in this thread.

    Here's what the thread in the google group said:

    I mean you should add "pom" to the dependency section of openid4java in your pom.xml:

       <dependency>
             <groupId>org.openid4java</groupId>
             <artifactId>openid4java-consumer</artifactId>
             <!--artifactId>openid4java-server</artifactId-->
             <!--artifactId>openid4java-infocard</artifactId-->
             <!--artifactId>openid4java-xri</artifactId-->
             <!--artifactId>openid4java</artifactId-->
             <!--artifactId>openid4java-full</artifactId-->
             <version>0.9.6</version>
             <type>pom</type> <-----------------------This line can not be omitted.
        </dependency>
    

    The type of openid4java-consumer/openid4java-server/.... are all "pom" not "jar". The jar file is in openid4java-nodeps which is depended by openid4java-consumer/openid4java-server...