0

I have a strange behaviour when updating entities (via entity views) in Quarkus native (it works fine on jvm). These are my entities:

    @Entity
    public class Role extends BaseEntity {
        private boolean deleted;
        private String name;
        @OneToMany
        private Set<LocalizedText> localizedDescriptions = new HashSet<>();
        @ManyToMany
        private Set<Permission> permissions = new HashSet<>();
        //SETTERS AND GETTERS
    } 

    @Entity
    public class LocalizedText extends BaseEntity {
        @NotBlank
        private String language;
        @NotBlank
        private String text;
    }

@Entity
public class Permission extends BaseEntity {
    private boolean deleted;
    @NotBlank
    private String name;
    @OneToMany
    @NotEmpty
    private Set<LocalizedText> localizedDescriptions = new HashSet<>();
}

And here's the entity views:

@EntityView(Role.class)
@CreatableEntityView
@UpdatableEntityView
public interface RoleUpdateView {
    @IdMapping
    Long getId();
    String getName();
    void setName(String name);
    @UpdatableMapping
    Set<LocalizedTextUpdateView> getLocalizedDescriptions();
    @UpdatableMapping
    Set<SimplePermissionUpdateView> getPermissions();
}

@EntityView(LocalizedText.class)
@CreatableEntityView
@UpdatableEntityView
public interface LocalizedTextUpdateView {
    @IdMapping
    Long getId();
    String getLanguage();
    void setLanguage(String language);
    String getText();
    void setText(String text);
}

@EntityView(Permission.class)
@CreatableEntityView
@UpdatableEntityView
public interface SimplePermissionUpdateView {
    @IdMapping
    Long getId();
}

As I said it works just fine when using the jvm, but it only works with entity creation in native mode. When updating an entity I get a NPE. Here's the trace:

org.jboss.resteasy.spi.UnhandledException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
    at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
    at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
    at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:218)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:519)
    at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
    at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
    at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
    at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
    at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
    at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:138)
    at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:84)
    at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:41)
    at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:137)
    at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132)
    at io.quarkus.vertx.http.runtime.StaticResourcesRecorder.lambda$start$1(StaticResourcesRecorder.java:65)
    at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:137)
    at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132)
    at io.quarkus.vertx.http.runtime.VertxHttpRecorder$4.handle(VertxHttpRecorder.java:338)
    at io.quarkus.vertx.http.runtime.VertxHttpRecorder$4.handle(VertxHttpRecorder.java:316)
    at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:137)
    at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132)
    at io.quarkus.vertx.http.runtime.security.HttpAuthorizer.doPermissionCheck(HttpAuthorizer.java:116)
    at io.quarkus.vertx.http.runtime.security.HttpAuthorizer.checkPermission(HttpAuthorizer.java:99)
    at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$3.handle(HttpSecurityRecorder.java:218)
    at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$3.handle(HttpSecurityRecorder.java:210)
    at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038)
    at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:137)
    at io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132)
    at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$2$2.onItem(HttpSecurityRecorder.java:143)
    at io.quarkus.vertx.http.runtime.security.HttpSecurityRecorder$2$2.onItem(HttpSecurityRecorder.java:104)
    at io.smallrye.mutiny.operators.uni.UniMemoizeOp.drain(UniMemoizeOp.java:152)
    at io.smallrye.mutiny.operators.uni.UniMemoizeOp.onItem(UniMemoizeOp.java:172)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.onItem(UniOnItemTransformToUni.java:60)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.onItem(UniOnItemTransformToUni.java:60)
    at io.smallrye.mutiny.operators.uni.builders.UniCreateFromKnownItem$KnownItemSubscription.forward(UniCreateFromKnownItem.java:38)
    at io.smallrye.mutiny.operators.uni.builders.UniCreateFromKnownItem$KnownItemSubscription.access$100(UniCreateFromKnownItem.java:26)
    at io.smallrye.mutiny.operators.uni.builders.UniCreateFromKnownItem.subscribe(UniCreateFromKnownItem.java:23)
    at io.smallrye.mutiny.operators.AbstractUni.subscribe(AbstractUni.java:36)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.performInnerSubscription(UniOnItemTransformToUni.java:81)
    at io.smallrye.mutiny.operators.uni.UniOnItemTransformToUni$UniOnItemTransformToUniProcessor.onItem(UniOnItemTransformToUni.java:57)
    at io.smallrye.mutiny.operators.uni.builders.DefaultUniEmitter.complete(DefaultUniEmitter.java:36)
    at io.quarkus.security.runtime.QuarkusIdentityProviderManagerImpl$1$1$1$1.run(QuarkusIdentityProviderManagerImpl.java:58)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2415)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
    at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
    at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
    at java.lang.Thread.run(Thread.java:829)
    at org.jboss.threads.JBossThread.run(JBossThread.java:501)
    at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:553)
    at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
    at com.blazebit.persistence.integration.hibernate.base.HibernateExtendedQuerySupport.getQueryParamEntries(HibernateExtendedQuerySupport.java:824)
    at com.blazebit.persistence.integration.hibernate.base.HibernateExtendedQuerySupport.createQueryParameters(HibernateExtendedQuerySupport.java:719)
    at com.blazebit.persistence.integration.hibernate.base.HibernateExtendedQuerySupport.executeUpdate(HibernateExtendedQuerySupport.java:415)
    at com.blazebit.persistence.impl.plan.CustomModificationQueryPlan.executeUpdate(CustomModificationQueryPlan.java:52)
    at com.blazebit.persistence.impl.query.CustomSQLQuery.executeUpdate(CustomSQLQuery.java:60)
    at com.blazebit.persistence.view.impl.update.flush.CollectionAttributeFlusher.addElements(CollectionAttributeFlusher.java:534)
    at com.blazebit.persistence.view.impl.update.flush.CollectionAttributeFlusher.replaceCollection(CollectionAttributeFlusher.java:1025)
    at com.blazebit.persistence.view.impl.update.flush.CollectionAttributeFlusher.replaceCollection(CollectionAttributeFlusher.java:64)
    at com.blazebit.persistence.view.impl.update.flush.AbstractPluralAttributeFlusher.invokeFlushOperation(AbstractPluralAttributeFlusher.java:286)
    at com.blazebit.persistence.view.impl.update.flush.CollectionAttributeFlusher.flushQuery(CollectionAttributeFlusher.java:287)
    at com.blazebit.persistence.view.impl.update.flush.CollectionAttributeFlusher.flushQuery(CollectionAttributeFlusher.java:64)
    at com.blazebit.persistence.view.impl.update.flush.CompositeAttributeFlusher.flushQuery(CompositeAttributeFlusher.java:450)
    at com.blazebit.persistence.view.impl.update.EntityViewUpdaterImpl.update(EntityViewUpdaterImpl.java:711)
    at com.blazebit.persistence.view.impl.update.EntityViewUpdaterImpl.executeUpdate(EntityViewUpdaterImpl.java:637)
    at com.blazebit.persistence.view.impl.EntityViewManagerImpl.update(EntityViewManagerImpl.java:1182)
    at com.blazebit.persistence.view.impl.EntityViewManagerImpl.update(EntityViewManagerImpl.java:1142)
    at com.blazebit.persistence.view.impl.EntityViewManagerImpl.save(EntityViewManagerImpl.java:1059)
    at cloud.officinaedisanto.heritage.coreservice.services.RolesService.save(RolesService.java:95)
    at cloud.officinaedisanto.heritage.coreservice.services.RolesService_Subclass.save$$superaccessor8(RolesService_Subclass.zig:1366)
    at cloud.officinaedisanto.heritage.coreservice.services.RolesService_Subclass$$function$$8.apply(RolesService_Subclass$$function$$8.zig:33)
    at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
    at io.quarkus.security.runtime.interceptor.SecurityHandler.handle(SecurityHandler.java:24)
    at io.quarkus.security.runtime.interceptor.RolesAllowedInterceptor.intercept(RolesAllowedInterceptor.java:29)
    at io.quarkus.security.runtime.interceptor.RolesAllowedInterceptor_Bean.intercept(RolesAllowedInterceptor_Bean.zig:386)
    at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
    at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:50)
    at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInCallerTx(TransactionalInterceptorBase.java:252)
    at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.doIntercept(TransactionalInterceptorRequired.java:34)
    at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:53)
    at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:26)
    at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired_Bean.intercept(TransactionalInterceptorRequired_Bean.zig:340)
    at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
    at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
    at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
    at cloud.officinaedisanto.heritage.coreservice.services.RolesService_Subclass.save(RolesService_Subclass.zig:1323)
    at cloud.officinaedisanto.heritage.coreservice.services.RolesService.update(RolesService.java:101)
    at cloud.officinaedisanto.heritage.coreservice.services.RolesService_Subclass.update$$superaccessor7(RolesService_Subclass.zig:1253)
    at cloud.officinaedisanto.heritage.coreservice.services.RolesService_Subclass$$function$$7.apply(RolesService_Subclass$$function$$7.zig:33)
    at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
    at io.quarkus.security.runtime.interceptor.SecurityHandler.handle(SecurityHandler.java:24)
    at io.quarkus.security.runtime.interceptor.RolesAllowedInterceptor.intercept(RolesAllowedInterceptor.java:29)
    at io.quarkus.security.runtime.interceptor.RolesAllowedInterceptor_Bean.intercept(RolesAllowedInterceptor_Bean.zig:386)
    at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
    at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:50)
    at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:127)
    at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:100)
    at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.doIntercept(TransactionalInterceptorRequired.java:32)
    at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:53)
    at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:26)
    at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired_Bean.intercept(TransactionalInterceptorRequired_Bean.zig:340)
    at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
    at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
    at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
    at cloud.officinaedisanto.heritage.coreservice.services.RolesService_Subclass.update(RolesService_Subclass.zig:1210)
    at cloud.officinaedisanto.heritage.coreservice.services.RolesService_ClientProxy.update(RolesService_ClientProxy.zig:225)
    at cloud.officinaedisanto.heritage.coreservice.api.backoffice.RolesBOResource.update(RolesBOResource.java:53)
    at cloud.officinaedisanto.heritage.coreservice.api.backoffice.RolesBOResource_Subclass.update$$superaccessor1(RolesBOResource_Subclass.zig:361)
    at cloud.officinaedisanto.heritage.coreservice.api.backoffice.RolesBOResource_Subclass$$function$$1.apply(RolesBOResource_Subclass$$function$$1.zig:33)
    at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
    at io.quarkus.security.runtime.interceptor.SecurityHandler.handle(SecurityHandler.java:24)
    at io.quarkus.security.runtime.interceptor.AuthenticatedInterceptor.intercept(AuthenticatedInterceptor.java:29)
    at io.quarkus.security.runtime.interceptor.AuthenticatedInterceptor_Bean.intercept(AuthenticatedInterceptor_Bean.zig:378)
    at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
    at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:41)
    at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
    at cloud.officinaedisanto.heritage.coreservice.api.backoffice.RolesBOResource_Subclass.update(RolesBOResource_Subclass.zig:318)
    at java.lang.reflect.Method.invoke(Method.java:566)
    at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
    at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
    at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:643)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:507)
    at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:457)
    at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:459)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:419)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:393)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:68)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
    ... 50 more
Caused by: java.lang.RuntimeException: java.lang.NullPointerException
    at com.blazebit.persistence.integration.hibernate.base.HibernateExtendedQuerySupport.getField(HibernateExtendedQuerySupport.java:1296)
    at com.blazebit.persistence.integration.hibernate.base.HibernateExtendedQuerySupport.getQueryParamEntries(HibernateExtendedQuerySupport.java:821)
    ... 127 more
Caused by: java.lang.NullPointerException
    at com.blazebit.persistence.integration.hibernate.base.HibernateExtendedQuerySupport.getField(HibernateExtendedQuerySupport.java:1291)
    ... 128 more

Any ideas on how to fix this error? I'm doing something wrong?

Thanks euks

E. Marotti
  • 89
  • 7
  • Hm that's more like a guess, but have you tried adding [`@RegisterForReflection`](https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection)? – Turing85 May 01 '21 at 07:54
  • No but I will try. But if it was @RegisterForReflection shouldn't I receive the NPE also during the entity creation? – E. Marotti May 01 '21 at 07:58
  • Not necessarily. I am also not quite sure where to add the `@RegisterForReflection`. The dead code elimination in GraalVM can be quite... aggressive. – Turing85 May 01 '21 at 08:10
  • Could you debug to the said location and tell me what kind of `StatementExecutor` types you are seeing there? Looks like we forgot to register some classes for reflection access. – Christian Beikov May 03 '21 at 07:15
  • In HibernateExtendedQuerySupport.getQueryParamEntries I'm seeing a DeleteExecutor and a SimpleUpdateExecutor. – E. Marotti May 03 '21 at 10:56
  • Thanks for confirming. I created https://github.com/Blazebit/blaze-persistence/issues/1305 for this. I'll try to fix this and do a release this weekend. – Christian Beikov May 04 '21 at 11:09
  • Took a bit longer to release, sorry about the delay, but I released version 1.6.1 today which fixes this. – Christian Beikov Jul 08 '21 at 09:04

0 Answers0