Stack Exchange
"Handler dispatch failed; nested exception is NoClassDefFoundError: org/springframework/transaction/support/TransactionSynchronizationManager",
I am new to spring boot. Trying to implement ehcache, but getting the following error: 
Handler dispatch failed; nested exception is NoClassDefFoundError: org/springframework/transaction/support/TransactionSynchronizationManager

Nothing is getting logged, only a Debug statement
2018-05-30 14:09:47.291 DEBUG 5520 --- [nio-9091-exec-2] .m.m.a.ExceptionHandlerExceptionResolver : Resolving exception from handler [public org.springframework.http.ResponseEntity<?> com.jetblue.api.controller.AirportLocationController.getAirport(com.jetblue.api.domain.Location,org.springframework.validation.BindingResult)]: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/transaction/support/TransactionSynchronizationManager
2018-05-30 14:09:47.293 DEBUG 5520 --- [nio-9091-exec-2] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'customizedResponseEntityExceptionHandler'

Cache Config
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.cache.ehcache.EhCacheManagerFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

@Configuration    
@EnableCaching
public class CacheConfiguration {

    @Bean
    public EhCacheManagerFactoryBean ehCacheManagerFactory() {
        EhCacheManagerFactoryBean cacheManagerFactoryBean = new EhCacheManagerFactoryBean();
        cacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache.xml"));
        cacheManagerFactoryBean.setShared(true);
        return cacheManagerFactoryBean;
    }

    @Bean
        public EhCacheCacheManager ehCacheCacheManager() {
            EhCacheCacheManager cacheManager = new EhCacheCacheManager();
            cacheManager.setCacheManager(ehCacheManagerFactory().getObject());
            cacheManager.setTransactionAware(true);
            return cacheManager;
        }
    }

Service layer:
@Override
    public NearByAirport getAirport(Location location) {
       ............
}

Interface:
public interface IAirportLocatorService {

    /**
     * Gets the airport.
     *
     * @param airport the airport
     * @return the airport
     */
    @Cacheable(value="nearestAirport", key="#location.latAndLong")
    public NearByAirport getAirport(Location location);

}

ehcache.xml


<cache name="nearestAirport" eternal="false"
    maxElementsInMemory="250" overflowToDisk="false" diskPersistent="false"
    timeToIdleSeconds="21600" timeToLiveSeconds="21600"
    memoryStoreEvictionPolicy="LRU" />


I tried putting @Cachable annotation on service layer instead of service, but same out put.
Any pointers will be much appreciated. Thanks.

Dependencies:


org.springframework.boot:spring-boot-starter-web


org.springframework.boot:spring-boot-starter-cache


net.sf.ehcache:ehcache:2.10.4



I think your problem is cacheManager.setTransactionAware(true);. This will cause Spring to link the cache to the transaction (with XA or a fake version of it, I'm not sure about that). So if the transaction rollbacks, the modifications to the cache will be as well.
But you are not currently using a Spring transaction manager since it's not in your classpath. So Spring is unhappy. Doing cacheManager.setTransactionAware(false); should solve the problem.

Dear Henri,
Thanks for your time, but seems like I have already done what you suggested in my config class :(.
Anything else you can figure out?

Arg... I meant setTransactionAware(false)
