开发者

Maven "Could not resolve dependencies" for openid4java

开发者 https://www.devze.com 2023-03-16 09:33 出处:网络
Summary: Running \"mvn war:war\" fails with errors including: \"The following artifacts could not be resolved: org.openid4java:openid4java:jar:0.9.6\".

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 c开发者_Go百科ould 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?


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...


This is what I did to make it compile and run:

  1. Go to your m2 or maven central repository,
  2. org->openID4java->openID4java->0.9.6 and edit openid4java-0.9.6.pom file and add pom to the dependencies which does not have jar
  3. org->openID4java->openid4java-consumer-SampleConsumer->0.9.6 and edit openid4java-consumer-SampleConsumer-0.9.6.pom file and add pom to the artifact of openId-consumer
  4. org->openID4java->openid4java-openid4java-server-SampleServer->0.9.6 and edit openid4java-server-SampleServer-0.9.6.pom file and add pom to the artifact of openId- server
  5. org->openID4java->openid4java-server-JdbcServerAssociationStore-0.9.6 and open the pom file and add the pom to the openID-server artifact.

fusing Eclipse, then right click project and maven and update dependency you are ready to go, for maven tool user, directly compile and you are ready to roll


Another way to resolve the dependency in Grails is to add maven repository "https://oss.sonatype.org/content/repositories/openid4java/" and put "openid4java-nodeps" as the artifact.

repositories {
    grailsPlugins()
    grailsHome()
    grailsCentral()
    mavenCentral()      
    mavenRepo "https://oss.sonatype.org/content/repositories/openid4java/"
}

dependencies {
    runtime('mysql:mysql-connector-java:5.1.19',
            'org.apache.httpcomponents:httpclient:4.2',
            'org.openid4java:openid4java-nodeps:0.9.6') { excludes "xml-apis" }
}


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

You need to either add a <repository> to your project containing these artifacts or install them to your local repository.

Try https://oss.sonatype.org/content/repositories/openid4java/ (found at MavenHowTo)


Do the maven install package for every depency openid4java-xxx failed as folow:

  1. run the ant build task inside your openid4java-0.9.6 directory

  2. then execute:

    mvn install:install-file -DgroupId=org.openid4java -DartifactId=openid4java-consumer -Dversion=0.9.6 -Dpackaging=jar -Dfile=<<change_this_path_to>>build\openid4java.jar
    
    mvn install:install-file -DgroupId=org.openid4java -DartifactId=openid4java-server -Dversion=0.9.6 -Dpackaging=jar -Dfile=<<change_this_path_to>>build\openid4java.jar
    
    mvn install:install-file -DgroupId=org.openid4java -DartifactId=openid4java-server-JdbcServerAssociationStore -Dversion=0.9.6 -Dpackaging=jar -Dfile=<<change_this_path_to>>build\openid4java.jar
    
    mvn install:install-file -DgroupId=org.openid4java -DartifactId=openid4java-consumer-SampleConsumer -Dversion=0.9.6 -Dpackaging=jar -Dfile=<<change_this_path_to>>build\openid4java.jar
    
    mvn install:install-file -DgroupId=org.openid4java -DartifactId=openid4java-server-SampleServer -Dversion=0.9.6 -Dpackaging=jar -Dfile=<<change_this_path_to>>build\openid4java.jar
    

And that should do it!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号