Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: missing net.sf.json-lib

Tags:

maven-2

I found net.sf.json-lib in the central repository. Copy-pasted the dependency (with version 2.3), and then when I build I get this error:

[INFO] Unable to find resource 'net.sf.json-lib:json-lib:jar:2.2.3' in repository central (http://repo1.maven.org/maven2)

[ERROR] BUILD ERROR
[INFO] ---------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) net.sf.json-lib:json-lib:jar:2.3

  Try downloading the file manually from the project website.

I tried using version 2.2.3, but I'm getting the same error. Why am I getting this error? I can override it by installing it locally, but I want to understand what the problem is.

Edit - I deleted the package from my local repository, and tried again, this time getting a checksum error. I guess I should file a bug report with json-lib.

[WARNING] *** CHECKSUM FAILED - Error retrieving checksum file for net/sf/json-lib/json-lib/2.3/json
-lib-2.3.pom - IGNORING
like image 260
ripper234 Avatar asked Nov 13 '10 15:11

ripper234


4 Answers

Looking at the maven-central repo, you need to specify a classifier for this dependency.

Either jdk13 or jdk15, like this:

<dependency>
    <groupId>net.sf.json-lib</groupId>
    <artifactId>json-lib</artifactId>
    <version>2.4</version>
    <classifier>jdk15</classifier>
</dependency>
like image 117
Petar Tahchiev Avatar answered Dec 06 '22 00:12

Petar Tahchiev


For gradle as sample

compile 'net.sf.json-lib:json-lib:2.4:jdk15'

OR

compile group: 'net.sf.json-lib', name: 'json-lib', version: '2.4', classifier: 'jdk15'

I searched for more classifier's could not find anything other than jdk15 (don't go looking or jdk16 or jdk17)

like image 32
Rinat Mukhamedgaliev Avatar answered Dec 06 '22 01:12

Rinat Mukhamedgaliev


Barring khimarbaise's comment about trustworthiness, you can install it locally using maven install:

  • http://maven.apache.org/plugins/maven-install-plugin/examples/specific-local-repo.html
mvn install:install-file  -Dfile=path-to-your-artifact-jar
                          -DgroupId=your.groupId
                          -DartifactId=your-artifactId
                          -Dversion=version
                          -Dpackaging=jar
                          -DlocalRepositoryPath=path-to-specific-local-repo
like image 22
icyrock.com Avatar answered Dec 06 '22 02:12

icyrock.com


For ivy users, after trying many different iterations to configure my ivy.xml to properly find this dependency, this finally worked for me:

  <dependency org="net.sf.json-lib" name="json-lib" rev="2.4">
        <artifact name="json-lib" url="http://repo1.maven.org/maven2/net/sf/json-lib/json-lib/2.4/json-lib-2.4-jdk15.jar"/>     
    </dependency>
like image 42
danbsd Avatar answered Dec 06 '22 01:12

danbsd