Reputation: 4538
I am trying to use Blaze persistence in a native quarkus service. Everything works fine in JVM mode. However, I am getting an exception in native (GraalVM). I am probably missing a configuration or some annotation to register Blaze classes for reflection. Note that the quarkus docs mention "The use in native images requires a dependency on the entity view annotation processor that may be extracted into a separate native profile" ( https://quarkus.io/guides/blaze-persistence), however I am not sure how it is supposed to be configured with gradle.
The following code which works fine in JVM mode fails in native mode:
public List<CountryView> getCountries2(){
CriteriaBuilder<Country> cb = cbf.create(em, Country.class);
// Next line fails:
return evm.applySetting(EntityViewSetting.create(CountryView.class), cb).getResultList();
}
The stacktrace is shown bellow:
at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:107)
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:344)
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:205)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:452)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:240)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:154)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:321)
at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:157)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:229)
at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:82)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:147)
at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:93)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:577)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at [email protected]/java.lang.Thread.run(Thread.java:833)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:807)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:210)
Caused by: java.lang.RuntimeException: Probably we did something wrong, please contact us if you see this message.
at com.blazebit.persistence.view.impl.proxy.ProxyFactory.createProxyClass(ProxyFactory.java:627)
at com.blazebit.persistence.view.impl.proxy.ProxyFactory.getProxy(ProxyFactory.java:263)
at com.blazebit.persistence.view.impl.proxy.ProxyFactory.getProxy(ProxyFactory.java:180)
at com.blazebit.persistence.view.impl.proxy.TupleConstructorReflectionInstantiator.<init>(TupleConstructorReflectionInstantiator.java:40)
at com.blazebit.persistence.view.impl.proxy.AbstractReflectionInstantiator.createInstantiator(AbstractReflectionInstantiator.java:93)
at com.blazebit.persistence.view.impl.objectbuilder.ViewTypeObjectBuilderTemplate.createInstantiator(ViewTypeObjectBuilderTemplate.java:399)
at com.blazebit.persistence.view.impl.objectbuilder.ViewTypeObjectBuilderTemplate.<init>(ViewTypeObjectBuilderTemplate.java:329)
at com.blazebit.persistence.view.impl.objectbuilder.ViewTypeObjectBuilderTemplate.<init>(ViewTypeObjectBuilderTemplate.java:127)
at com.blazebit.persistence.view.impl.objectbuilder.ViewTypeObjectBuilderTemplate$Key.createValue(ViewTypeObjectBuilderTemplate.java:1553)
at com.blazebit.persistence.view.impl.EntityViewManagerImpl.getTemplate(EntityViewManagerImpl.java:1379)
at com.blazebit.persistence.view.impl.EntityViewManagerImpl.createObjectBuilder(EntityViewManagerImpl.java:1363)
at com.blazebit.persistence.view.impl.EntityViewSettingHelper.apply(EntityViewSettingHelper.java:119)
at com.blazebit.persistence.view.impl.EntityViewManagerImpl.applySetting(EntityViewManagerImpl.java:1235)
at io.airlinesuite.scheduling.services.CountryService.getCountries2(CountryService.java:40)
Edit: it seems the CountryView interface was not included in the native executable:
@EntityView(Country.class)
@RegisterForReflection
public interface CountryView {
@IdMapping
UUID getId();
String getCountryName();
String getCountryCode();
}
Caused by: javassist.NotFoundException: io.airlinesuite.scheduling.api.rest.dto.CountryView
at javassist.ClassPool.get(ClassPool.java:430)
at com.blazebit.persistence.view.impl.proxy.ProxyFactory.createProxyClass(ProxyFactory.java:391)
... 45 more
the build.gradle for the project:
dependencies {
implementation 'io.quarkus:quarkus-arc'
implementation 'io.quarkus:quarkus-resteasy'
implementation 'io.quarkus:quarkus-resteasy-jackson'
implementation 'io.quarkus:quarkus-resteasy-multipart'
implementation 'io.quarkus:quarkus-hibernate-orm'
implementation 'io.quarkus:quarkus-hibernate-validator'
implementation 'io.quarkus:quarkus-jdbc-postgresql'
implementation 'io.quarkus:quarkus-flyway'
implementation 'org.mapstruct:mapstruct:1.5.3.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.5.3.Final'
implementation 'io.quarkus:quarkus-smallrye-jwt'
implementation 'io.quarkus:quarkus-smallrye-jwt-build'
implementation enforcedPlatform("${quarkusPlatformGroupId}:quarkus-blaze-persistence-bom:${quarkusPlatformVersion}")
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
implementation 'com.blazebit:blaze-persistence-integration-quarkus-3'
runtimeOnly("com.blazebit:blaze-persistence-integration-hibernate-6.2")
testImplementation 'io.quarkus:quarkus-junit5'
testImplementation 'io.rest-assured:rest-assured'
}
Edit 2: updated my build.gradle as suggested by @Christian Beikov to include de annotationProcessor and now everything works perfectly:
...
annotationProcessor 'com.blazebit:blaze-persistence-entity-view-processor:1.6.9'
...
Upvotes: 0
Views: 264
Reputation: 16400
I think you need annotationProcessor 'com.blazebit:blaze-persistence-entity-view-processor'
to enable the annotation processor.
Upvotes: 1