Skip to content
This repository has been archived by the owner on Apr 21, 2021. It is now read-only.

Native Image craches when combined with @Cacheable #14

Open
rodrigo-bruno opened this issue Nov 10, 2020 · 0 comments
Open

Native Image craches when combined with @Cacheable #14

rodrigo-bruno opened this issue Nov 10, 2020 · 0 comments

Comments

@rodrigo-bruno
Copy link

When creating a Micronaut application combining H2 and @Cacheable, the following exception is thrown. Running on HotSpot does not throw an exception and the cache is correctly used:

09:56:20.858 [io-executor-thread-1] ERROR i.m.h.s.netty.RoutingInBoundHandler - Unexpected error occurred: Could not obtain transaction-synchronized Session for current thread                                   
org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for current thread
        at io.micronaut.transaction.hibernate5.MicronautSessionContext.currentSession(MicronautSessionContext.java:100)                                                                                           
        at org.hibernate.internal.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:475)
        at io.micronaut.configuration.hibernate.jpa.TransactionalSessionInterceptor.intercept(TransactionalSessionInterceptor.java:56)                                                                            
        at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:82)
        at io.micronaut.configuration.hibernate.jpa.TransactionalSession$Intercepted.persist(Unknown Source)                                                                                                      
        at example.micronaut.GenreRepositoryImpl.save(GenreRepositoryImpl.java:60)
        at example.micronaut.$GenreRepositoryImplDefinition$Intercepted.$$access1(Unknown Source)
        at example.micronaut.$GenreRepositoryImplDefinition$Intercepted$$proxy1.invokeInternal(Unknown Source)                                                                                                    
        at io.micronaut.context.AbstractExecutableMethod.invoke(AbstractExecutableMethod.java:146)
        at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:73)
        at io.micronaut.cache.interceptor.CacheInterceptor.doProceed(CacheInterceptor.java:475)
        at io.micronaut.cache.interceptor.CacheInterceptor.interceptSync(CacheInterceptor.java:213)
        at io.micronaut.cache.interceptor.CacheInterceptor.intercept(CacheInterceptor.java:131)
        at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:82)
        at io.micronaut.validation.ValidatingInterceptor.intercept(ValidatingInterceptor.java:139)
        at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:82)
        at example.micronaut.$GenreRepositoryImplDefinition$Intercepted.save(Unknown Source)
        at example.micronaut.GenreController.save(GenreController.java:52)
        at example.micronaut.$GenreControllerDefinition$Intercepted.$$access2(Unknown Source)
        at example.micronaut.$GenreControllerDefinition$Intercepted$$proxy2.invokeInternal(Unknown Source)                                                                                                        
        at io.micronaut.context.AbstractExecutableMethod.invoke(AbstractExecutableMethod.java:146)
        at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:73)
        at io.micronaut.validation.ValidatingInterceptor.intercept(ValidatingInterceptor.java:139)
        at io.micronaut.aop.chain.MethodInterceptorChain.proceed(MethodInterceptorChain.java:82)
        at example.micronaut.$GenreControllerDefinition$Intercepted.save(Unknown Source)
        at example.micronaut.$$GenreControllerDefinition$InterceptedDefinition$$exec3.invokeInternal(Unknown Source)                                                                                              
        at io.micronaut.context.AbstractExecutableMethod.invoke(AbstractExecutableMethod.java:146)
        at io.micronaut.context.DefaultBeanContext$4.invoke(DefaultBeanContext.java:474)
        at io.micronaut.web.router.AbstractRouteMatch.execute(AbstractRouteMatch.java:312)
        at io.micronaut.web.router.RouteMatch.execute(RouteMatch.java:118)
        at io.micronaut.http.server.netty.RoutingInBoundHandler.lambda$buildResultEmitter$10(RoutingInBoundHandler.java:1363)                                                                                     
        at io.reactivex.internal.operators.flowable.FlowableDefer.subscribeActual(FlowableDefer.java:35)
        at io.reactivex.Flowable.subscribe(Flowable.java:14918)
        at io.reactivex.Flowable.subscribe(Flowable.java:14865)
        at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)                                                                                    
        at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker$BooleanRunnable.run(ExecutorScheduler.java:288)                                                                                      
        at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker.run(ExecutorScheduler.java:253)                                                                                                      
        at io.micronaut.scheduling.instrument.InvocationInstrumenterWrappedRunnable.run(InvocationInstrumenterWrappedRunnable.java:47)                                                                            
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
        at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:519)
        at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)

Steps to reproduce:

  1. add implementation("io.micronaut.cache:micronaut-cache-caffeine") to build.gradle
  2. add @Cacheable to GenreRepositoryImpl.findById, for example
  3. build NI (gradlew nativeImage) using GraalVM 20.3 (JDK8 build)
  4. launch app (build/native-image/application)
  5. perform request (curl -X "POST" "http://localhost:8080/genres" -H 'Content-Type: application/json; charset=utf-8' -d $'{ "name": "musicX" }')
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant