81

I am trying to compile a maven project, but I systematically get the following error message:

[ERROR]Failed to execute goal on project ...:
Could not resolve dependencies for project ...:war:1.0.0:
The following artifacts could not be resolved: javax.jms:jms:jar:1.1,
com.sun.jdmk:jmxtools:jar:1.2.1, com.sun.jmx:jmxri:jar:1.2.1:
Failure to find javax.jms:jms:jar:1.1 in http://mirrors.ibiblio.org/maven2/
  was cached in the local repository, resolution will not be reattempted until
  the update interval of maven2-repository.ibiblio.mirror has elapsed or
  updates are forced -> [Help 1]

I know about this maven post about Sun jars, but it does not solve the problem.

Is there a repository I can specify in my pom.xml?

double-beep
  • 5,031
  • 17
  • 33
  • 41
Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453

10 Answers10

86

Thanks for the suggestions. I finally found a solution to this problem after reading this. It turns out that these dependencies were coming from a dependency to ZooKeeper.

I modified my pom.xml as following and it solved the problem:

    <dependency>
        <groupId>org.apache.zookeeper</groupId>
        <artifactId>zookeeper</artifactId>
        <version>3.3.2</version>
        <exclusions>
            <exclusion>
                <groupId>com.sun.jmx</groupId>
                <artifactId>jmxri</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jdmk</groupId>
                <artifactId>jmxtools</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.jms</groupId>
                <artifactId>jms</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
  • 2
    Good workaround. I had the same problem today with a log4j dependency. It looks like https://maven-repository.dev.java.net/nonav/repository has an invalid cert perhaps (Chrome gives me a big warning when I hit that url). That's the server those deps are hosted at I think. – James Cooper May 03 '11 at 01:34
  • I get an SSL cert warning as well, but came to realize that it was because the domain does not exist. It was because of OpenDNS and their default fallback page. – Steve Buzonas Jun 07 '12 at 03:33
  • 5
    It looks like transient dependency `log4j:log4j:1.2.15` is pulling in those odd dependencies. Excluding log4j from the zookeeper dependency, and including a newer version of log4j yourself also seems to solve this problem. – JeroenHoek Dec 05 '13 at 12:31
  • 1
    @JamesCooper Check this(http://unitstep.net/blog/2009/05/18/resolving-log4j-1215-dependency-problems-in-maven-using-exclusions/) out. It explains the log4j issue. – smwikipedia Dec 17 '14 at 03:54
67

If anyone still wants to use jms1.1 then add the public jboss repository and maven will find it...

project->dependencies:

  <dependencies>
    <dependency>
      <groupId>javax.jms</groupId>
      <artifactId>jms</artifactId>
      <version>1.1</version>
    </dependency>

project->repositories:

  <repositories>
    <repository>
      <id>repository.jboss.org-public</id>
      <name>JBoss.org Maven repository</name>
      <url>https://repository.jboss.org/nexus/content/groups/public</url>
    </repository>  

It works -

F:\mvn-repo-stuff>mvn verify
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building mvn-repo-stuff 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.pom
Downloaded: http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.pom (677 B at 0.8 KB/sec)
[WARNING] The artifact xml-apis:xml-apis:jar:2.0.2 has been relocated to xml-apis:xml-apis:jar:1.0.b2
Downloading: http://repo1.maven.org/maven2/javax/jms/jms/1.1/jms-1.1.jar
Downloading: https://repository.jboss.org/nexus/content/groups/public/javax/jms/jms/1.1/jms-1.1.jar
Downloaded: https://repository.jboss.org/nexus/content/groups/public/javax/jms/jms/1.1/jms-1.1.jar (26 KB at 8.5 KB/sec)
matto
  • 671
  • 4
  • 3
  • I found it only in the repository: https://repository.jboss.org/nexus/content/repositories/thirdparty-releases/ – krakover Jul 31 '11 at 09:36
  • Do you put this in section? It didn't help in my case. – haridsv Aug 17 '11 at 22:47
  • I placed the repository in the User Settings settings.xml, but it didn't do the job for me either. – despot Jan 29 '12 at 13:00
  • For me its was giving this error.Could not find artifact org.jboss.com.sun.httpserver:httpserver:jar:1.0.0.Final in java.net...... When i change the repository to jboss its downloaded now .. thanks – Dhrumil Shah Apr 21 '17 at 05:35
24

Log4 version 1.2.17 automatically resolves the issue as it has depency on geronimo-jms. I got the same issue with log4j- 1.2.15 version.


Added with more around the issue


using 1.2.17 resolved the issue during the compile time but the server(Karaf) was using 1.2.15 version thus creating conflict at run time. Thus I had to switch back to 1.2.15.

The JMS and JMX api were available for me at the runtime thus i did not import the J2ee api.

what i did was I used the compile time dependency on 1.2.17 but removed it at the runtime.

            <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
....
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                                                          <Import-Package>!org.apache.log4j.*,*</Import-Package>

.....
R-JANA
  • 1,138
  • 2
  • 14
  • 30
15

Another solution if you don't want to modify your settings:

Download jms-1.1.jar from JBoss repository then:

mvn install:install-file -DgroupId=javax.jms -DartifactId=jms -Dversion=1.1 -Dpackaging=jar -Dfile=jms-1.1.jar

marcelovca90
  • 2,673
  • 3
  • 27
  • 34
Adrián Deccico
  • 4,975
  • 2
  • 22
  • 30
  • it worked all the way to compile project. thanks. One question: if I delete the .m2 folder, I have to again issue this command. am I right? – hephestos Dec 24 '12 at 11:46
  • if I delete the .m2 folder, I have to again issue this command? << Yes you do. mvn install will copy an artifact to your local mvn repo. – Adrián Deccico Dec 26 '12 at 04:16
4

In fact the real solution for this issue is to use the jms-api-1.1-rev-1.jar artifact available on Maven Central : http://search.maven.org/#artifactdetails%7Cjavax.jms%7Cjms-api%7C1.1-rev-1%7Cjar

Sébastien Deleuze
  • 5,950
  • 5
  • 37
  • 38
  • I think this is the best solution in case your projects depends on JMS. This way you delegate to Maven the resolution of JMS too, as one would ideally expect. – danidemi Dec 26 '14 at 19:02
  • Easy, simple solution. No need to add a new repository. – downeyt Dec 26 '17 at 17:31
3

Try forcing updates using the mvn cpu option:

usage: mvn [options] [<goal(s)>] [<phase(s)>]

Options:
 -cpu,--check-plugin-updates            Force upToDate check for any
                                        relevant registered plugins
dogbane
  • 266,786
  • 75
  • 396
  • 414
  • Its not so good to use -cpu. Here is why "Command line option -cpu is deprecated and will be removed in future Maven versions." – despot Jan 29 '12 at 12:44
3

I also faced the same issue when I started using following maven dependency version for log4j (1.2.15) in my project.

<dependency>
  <groupId>log4j</groupId>
  <artifactId>log4j</artifactId>
  <version>1.2.15</version>
</dependency>

Following error was thrown at me.

The following artifacts could not be resolved: javax.jms:jms:jar:1.1, com.sun.jdmk:jmxtools:jar:1.2.1, com.sun.jmx:jmxri:jar:1.2.1: Could not transfer artifact javax.jms:jms:jar:1.1 from/to java.net (https://maven-repository.dev.java.net/nonav/repository): Cannot access https://maven-repository.dev.java.net/nonav/repository with type legacy using the available connector factories: BasicRepositoryConnectorFactory: Cannot access https://maven-repository.dev.java.net/nonav/repository with type legacy using the available layout factories: Maven2RepositoryLayoutFactory: Unsupported repository layout legacy -> [Help 1]

I started using following log4j (1.2.17) version and it helped me solve this issue without any configurations related fixes.

 <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.17</version>
    </dependency>
Du-Lacoste
  • 11,530
  • 2
  • 71
  • 51
2

A check of ibliblio and java.net repositories reveal that jmx related jar is not present in either. I think you should manually download jms and install them locally as discussed here.

Raghuram
  • 51,854
  • 11
  • 110
  • 122
  • I agree. This solves most of the problems. Browse jarvana.com and for Project field type groupId:artifactId of the jar u are looking for. If you can't find the file, than inspect the pom and try to find out where u can download it from (see downloadUrl here: http://jarvana.com/jarvana/inspect-pom/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.pom). Once you download use the following command: mvn install:install-file -DgroupId=groupIdOfJar -DartifactId=artifactIdOfJar -Dversion=versionOfJar -Dpackaging=jar -Dfile="pathToJar.jar" -DgeneratePom=true – despot Jan 29 '12 at 13:13
  • Also check out the different repositories here: http://docs.codehaus.org/display/MAVENUSER/Mirrors+Repositories And Maven's mirrors and repositories guide: http://maven.apache.org/guides/mini/guide-mirror-settings.html – despot Jan 29 '12 at 13:52
0

You import one dependency, and this dependency is dependent on com.sun.jmx:jmxri:jar:1.2.1 and others, but com.sun.jmx:jmxri:jar:1.2.1 cannot be found in central repository,

so you'd better try to import another version.

Here suppose your dependency may be log4j, and you can try to import log4j:log4j:jar:1.2.13.

gnat
  • 6,213
  • 108
  • 53
  • 73
JZ.Hunt
  • 1
  • 2
0

May not be the exactly same problem. but there is a nice article on the same line Here

Nirmal Mangal
  • 812
  • 1
  • 12
  • 26