Search code examples
javaspringspring5

Spring Framework upgrade 5.X leads to error class file for org.springframework.context.SmartLifecycle not found


I have been upgrading one of the app to spring framwork 5.X from 3.X, one of the problem I am failing to resolve it error is following - this makes a use of spring-jms

cannot access org.springframework.context.SmartLifecycle [ERROR]
class file for org.springframework.context.SmartLifecycle not found

I can see last version the exact same code works with Spring 4.3.9 (last of 4.X release) and breaks with Spring 5.0.0 (First of 5.X releases)

I don't see my code exposing the class SmartLifecycle but I have suspicion that DefaultMessageListenerContainer instance is at a fault.

public class Factory {
    private DefaultMessageListenerContainer testListnerService;

    public void start() {

        final TestMessageListener testMessageListener = new TestMessageListener();
        testListnerService = new DefaultMessageListenerContainer();    <-- This is where compilation breaks
        testListnerService.setMessageListener(testMessageListener);
        testListnerService.setSessionTransacted(true);
        testListnerService.afterPropertiesSet();
    }

I have created minimal example here https://github.com/milandesai47/com.jms.test/blob/master/pom.xml#L33

Am I missing anything obvious in terms of spring dependencies?


Solution

  • You need to add the following dependency to your pom.xml:

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>5.0.0.RELEASE</version>
    </dependency>