Saurabh
Saurabh

Reputation: 181

java.lang.ClassNotFoundException: javax.jms.JMSContext on tomcat 7

I have a spring web application which I am trying to deploy on tomcat 7. I got following error on tomcat 7 start-up:

Caused by:

java.lang.ClassNotFoundException: javax.jms.JMSContext

This is because tomcat could not find javaee-api-7.0.jar which is present in my application's WEB-INF/lib folder. However, if I copy this to tomcat/lib, error is fixed and tomcat can load the class.

But I don't want to copy any additional jars to tomcat/lib. Can someone help here so that tomcat can find above jar in application's lib. Am I missing any classpath handler entries? I have not added any explicitly.

Upvotes: 18

Views: 44346

Answers (2)

blacktiago
blacktiago

Reputation: 393

I had the same problem in an Apache karaf 4.2.7 environment over JDK 11.0.2, in my case the exception prints

Caused by: java.lang.ClassNotFoundException: javax.jms.JMSContext not found by org.apache.geronimo.specs.geronimo-jms_1.1_spec

It works by installing: bundle:install mvn:javax.jms/javax.jms-api/2.0.1

Upvotes: 0

sapan prajapati
sapan prajapati

Reputation: 1732

I was also facing the same issue when I moved from spring-3.0 to spring-5.0 while using Tomcat-7 to deploy my application. I added below maven dependency in pom.xml file and it got resolved.

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

The root cause I found is, UserCredentialsConnectionFactoryAdapter class provided by spring-jms-5.0.2.RELEASE.jar was using JMSContext class internally. This class was not available in jms-1.1.jar which I was using with spring-jms-3.2.4.jar.

So I replaced jms-1.1.jar with javax.jms-api-2.0.1.jar

I would suggest you to add/upgrade your jms jar as mentioned above according to you spring version. Hope this works!

Upvotes: 48

Related Questions