What to do if ClassNotFoundException occurs when starting Tomcat

--Environment - CentOS Linux release 7.6.1810 (Core) - Eclipse 2019-03 (4.11.0) - Java1.6.0_41 - Apache Maven 3.2.5

Event: I got angry when I started tomcat in Eclipse

[Consol]Tab log


information: Initializing Spring root WebApplicationContext
2020-04-17 10:32:34.216 ERROR                                   Jotm.<init>:144 - Instanciation of TransactionFactory failed
java.rmi.StubNotFoundException: Stub class not found: org.objectweb.jotm.TransactionFactoryImpl_Stub; nested exception is: 
    java.lang.ClassNotFoundException: org.objectweb.jotm.TransactionFactoryImpl_Stub
...abridgement...
    at org.objectweb.jotm.Jotm.<init>(Jotm.java:140) ~[jotm-2.0.10.jar:"2.0.9"]
    at org.springframework.transaction.jta.JotmFactoryBean.<init>(JotmFactoryBean.java:95) ~[spring-dao-2.0.8.jar:2.0.8]
...abridgement...
Caused by: java.lang.ClassNotFoundException: org.objectweb.jotm.TransactionFactoryImpl_Stub
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1698) ~[catalina.jar:6.0.53]
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1544) ~[catalina.jar:6.0.53]
    at java.lang.Class.forName0(Native Method) ~[na:1.6.0_41]
    at java.lang.Class.forName(Class.java:274) ~[na:1.6.0_41]
    at sun.rmi.server.Util.createStub(Util.java:286) ~[na:1.6.0_41]
    ... 85 common frames omitted

Although it is displayed as jotm-2.0.10.jar in the log, I was wondering because it is jotm-2.1.1.pom defined in pom.xml of the project.

Project pom.xml


<dependency>
  <groupId>org.ow2.jotm</groupId>
  <artifactId>jotm</artifactId>
  <version>2.1.1</version>
  <type>pom</type>
  <exclusions>
...abridgement...
</dependency>
...abridgement...
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-dao</artifactId>
    <version>2.0.8</version>
</dependency>
...abridgement...

There is spring-dao-2.0.8.jar under jotm-2.0.10.jar in the log, so when I look at spring-dao-2.0.8.pom, it says" Yes! "

bash:spring-dao-2.0.8.Take a look at pom


$ cat ~/.m2/repository/org/springframework/2.0.8/spring-dao-2.0.8.pom
...abridgement...
<dependency>
  <groupId>jotm</groupId>
  <artifactId>jotm</artifactId>
  <version>2.0.10</version>
  <optional>true</optional>
</dependency>
...abridgement...

Cause: There is no class beyond the jar dependency defined in the project's pom.xml

Used by spring-dao-2.0.8.pom Used by jotm-2.0.10.jar ʻorg.objectweb.jotm.TransactionFactoryImpl_Stub` is missing

Workaround: Define a jar in pom.xml that contains the class at the end of the dependency

  1. Use JAR Search --findJAR.com to find out what jar contains ʻorg.objectweb.jotm.TransactionFactoryImpl_Stub`.
  2. Search Maven Repository: Search / Browse / Explore for jotm-jrmp-stubs found by the search.
  3. Add the definition to the project's pom.xml

Project pom.xml


...abridgement...
<dependency>
    <groupId>jotm</groupId>
    <artifactId>jotm_jrmp_stubs</artifactId>
    <version>2.0.10</version>
</dependency>
...abridgement...

Recommended Posts

What to do if ClassNotFoundException occurs when starting Tomcat
What to do when javax.batch.operations.JobStartException occurs
What to do when a javax.el.PropertyNotWritableException occurs
What to do if the server tomcat dies
What to do when IllegalStateException occurs in PlayFramework
What to do if an error occurs when nokogiri enters when bundle install
What to do if tomcat process remains when tomcat is stopped in eclipse
Notes on what to do when a WebView ClassNotFoundException occurs in JavaFX 12
What to do when a null byte error occurs
What to do if an ActionController :: UnknownFormat error occurs
Error ExecJS :: RuntimeUnavailable: What to do when it occurs
What to do if you get a "Cannot Pull Container Error" when starting ECS ​​Fargate
What to do if a SAX Parser error occurs when using Liferay 7 / DXP on AWS
What to do if you install Ubuntu
What to do when undefined method ʻuser_signed_in?'
What to do if an error occurs when doing npm install axios in React + Typescript project
What to do and how to install when an error occurs in DXRuby 1.4.7
no space left on device What to do if an error occurs
What to do if you get an error when you hit Heroku logs
What to do if you push incorrect information
What to do if mvn archetype: generate fails
What to do when debugging "Source not found"
What do you use when converting to String?
wildflly10 java8 ERROR [org.jboss.jca.core.tx.jbossts.XAResourceRecoveryImpl] (Periodic Recovery) IJ000906 What to do if an error occurs
What to do if ffi installation fails when launching an application in Rails
What to do if the debug gem installation fails
What to do if the Rails server can't start
What to do when JSF tags do not become HTML
What to do if rails server can't be stopped
What to do if TextToSpeech doesn't work on Android 11
What to do if you accidentally create a model
What to do when rails creates a 〇〇 2.rb file
What to do if password authentication fails in Docker/Postgres
ParseException: What to do when Unparseable date is reached
BasicDataSourceFactory is ClassNotFoundException when connecting to DB on Tomcat 8
What to do if you get a NoClassDefFoundError when trying to run eclipse on Java9
What to do if you get a port error when docker-compose up on Mac
What to do if you get an error saying "Could not find a JavaScript runtime." When starting rails server
What to do when it becomes Unable to find CDI BeanManager.
What to do when Method not found in f: ajax
What to do when you launch an application with rails
What to do if audio is not available on discordrb
What to do if FacesMessage is set but not displayed
# What to do if you accidentally do rails db: migrate: drop
What to do when Cannot apply expression operators to method binding
[Opens aml] NoClassDefFoundError occurs when migrating from Tomcat to weblogic
What to do if the adb command cannot be executed
What to do if mysql2 gets a bundle install error
What to do if you can't use the rails command
[Rails 6] What to do when a missing a template error occurs after introducing haml [Super easy]
[Ubuntu 20.04] What to do if the external monitor is not recognized
What to do if you get a gcc error in Docker
What to do if validation doesn't work with the update action
What to do if you go offline due to SSL certificate error when running Jenkins on Mac
[Spring Boot] What to do if an HttpMediaTypeNotAcceptableException occurs on an endpoint for which produces is set
[Rails] What to do if data is not registered in DB
To avoid errors when starting miChecker
What to do when the changes in the Servlet are not reflected
What to do if the Rails page doesn't appear in Rails tutorial 1.3.2
What to do if Cloud9 is full in the Rails tutorial
What to do if the Eclipse Maven dependency Jar is wrong