58

I need to import javax.jms.* classes. What is the right dependency to include into a Maven project? I'm trying javax.jms:jms:1.1, but no luck (it's pom, not jar).

ps. The only workaround I've found so far is: javax:javaee-api:6.0 (from Maven Central).

3
  • Are you using Spring by any chance? Commented Jun 13, 2011 at 18:38
  • No, I'm not using Spring Commented Jun 13, 2011 at 19:05
  • depends. usually those classes are provided by JEE container, if you're using one - then javaee-api is the right answer. if you don't, then you need to use the one provided by jms provider you use. Commented Dec 13, 2012 at 14:11

9 Answers 9

50

In ActiveMQ as well as some other projects like Qpid JMS we pull in the JMS spec classes from Apache Geronimo JARs, the 1.1 APIs are available in this dependency:

 <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-jms_1.1_spec</artifactId> <version>1.1.1</version> </dependency> 

For JMS 2 APIs you'd need to use a different dependency, for instance

 <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-jms_2.0_spec</artifactId> <version>1.0-alpha-2</version> </dependency> 

These are both Apache 2.0 licensed dependencies.

Now that things have moved on to the Jakarta API versions of the JMS Specifications the options for JMS API jars have shifted.

The basic Jakarta JMS 2.0 API that is API compatible with legacy JMS 2.0 APIs can be found here.

<dependency> <groupId>jakarta.jms</groupId> <artifactId>jakarta.jms-api</artifactId> <version>2.0.3</version> </dependency> 

New Jakarta Messaging APIs in the 3.x series can be pulled in from here, ActiveMQ 6.0+ brokers have migrated to Jakarta:

<dependency> <groupId>jakarta.jms</groupId> <artifactId>jakarta.jms-api</artifactId> <version>3.1.0</version> </dependency> 

Another option which is not Apache licensed is here as others have pointed out.

<dependency> <groupId>javax.jms</groupId> <artifactId>javax.jms-api</artifactId> <version>2.0.1</version> </dependency> 
Sign up to request clarification or add additional context in comments.

3 Comments

what's the difference between geronimo and javax ?
geronimo is 100% open source and Apache licensed.
The question is about javax.jms implying the use of the JMS API not a vendor specific implementation like ActiveMQ
16

The Sun license doesn't allow maven repositories to host this (and other) artifacts.

Here is the documentation explaining this and what you should do instead...

Maven - Guide to coping with Sun JARs

What it says is you need to download the JAR manually and then install it into your own local repository or nexus server.

The pom.xml files hosted at maven central for these artifacts contain information on where you can download the JARs from.

2 Comments

This should be the accepted answer, it explains the correct Maven approach for all Sun JARs.
This is the right answer, although the link points to a page that is out of date (it gives misleading info about a Maven 2 repository).
16
 <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> 

2 Comments

javax.jms/jms does not exist anymore from download.java.net/maven/2 but the javax/javaee-api does. I added this to my pom and my JMS dependency issue disappeared and I am able to build my app successfully. The article posted above by Jesse Webb's URL link on "Maven - Guide to coping with Sun JARs" seems outdated.
I like this answer the best, apparently, this should be the "orthodox" dependency to use.
7

I have successfully used this one:

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

2 Comments

I've seen your example in your blog. You're getting this artifact from jboss repository, which is no longer available there
I just added it, and it is in the main repo
3

Go to Maven Search site and search for javax. Open the latest version for groupId javax and artifactId javaee-api

The current version is 7.0 [Maven dependency information]

Comments

3

If you just want the JMS libs, without the rest of javaee, use the following:

https://mvnrepository.com/artifact/javax.jms/javax.jms-api/2.0.1

<dependency> <groupId>javax.jms</groupId> <artifactId>javax.jms-api</artifactId> <version>2.0.1</version> </dependency> 

Comments

1

According to mvnrepository, the dependency to add in the pom of your project is the following:

<dependency> <groupId>jms</groupId> <artifactId>jms</artifactId> <version>1.1</version> </dependency> 

1 Comment

There is now, @yegor256
1

Check out the dependencies listed on grepcode.com.
I only discovered this site recently, and it rocks!

http://grepcode.com/search/?query=javax.jms.*

It looks like the Geronimo jars on maven central should sort your issues out.

Comments

0

This worked for myself

 <dependency> <groupId>javax.jms</groupId> <artifactId>javax.jms-api</artifactId> <version>2.0.1</version> </dependency> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.