Skip to content

Application fails after reload in development mode if there is a NamedQuery present in the codebase #4957

@belyaev-andrey

Description

@belyaev-andrey

Describe the bug
Development mode. If there is a named query in the application code, the application fails during reload after any code change.

Expected behavior
I should see the updated data after I change the code.

Actual behavior
Error occurs:

Error handling 2956ff09-ba44-4a72-a1df-d6f2bbdb32b8-1, org.jboss.resteasy.spi.UnhandledException: java.lang.IllegalArgumentException: Type specified for TypedQuery [org.acme.model.Person] is incompatible with query return type [class org.acme.model.Person]

org.jboss.resteasy.spi.UnhandledException: java.lang.IllegalArgumentException: Type specified for TypedQuery [org.acme.model.Person] is incompatible with query return type [class org.acme.model.Person]
	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:209)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:252)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:153)
	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
	at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:156)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:238)
	at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:69)
	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:104)
	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatchRequestContext(VertxRequestHandler.java:83)
	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.lambda$handle$0(VertxRequestHandler.java:70)
	at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:316)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Type specified for TypedQuery [org.acme.model.Person] is incompatible with query return type [class org.acme.model.Person]
	at org.hibernate.internal.AbstractSharedSessionContract.resultClassChecking(AbstractSharedSessionContract.java:856)
	at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:903)
	at org.hibernate.internal.AbstractSharedSessionContract.buildQueryFromName(AbstractSharedSessionContract.java:884)
	at org.hibernate.internal.AbstractSharedSessionContract.createNamedQuery(AbstractSharedSessionContract.java:990)
	at org.hibernate.internal.AbstractSessionImpl.createNamedQuery(AbstractSessionImpl.java:23)
	at io.quarkus.hibernate.orm.runtime.entitymanager.TransactionScopedEntityManager.createNamedQuery(TransactionScopedEntityManager.java:366)
	at io.quarkus.hibernate.orm.runtime.entitymanager.ForwardingEntityManager.createNamedQuery(ForwardingEntityManager.java:172)
	at org.acme.service.PersonService.getAllPersons(PersonService.java:20)
	at org.acme.service.PersonService_Subclass.getAllPersons$$superaccessor2(PersonService_Subclass.zig:248)
	at org.acme.service.PersonService_Subclass$$function$$2.apply(PersonService_Subclass$$function$$2.zig:47)
	at io.quarkus.arc.interceptors.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:55)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:119)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:92)
	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:315)
	at io.quarkus.arc.interceptors.InterceptorInvocation.invoke(InterceptorInvocation.java:41)
	at io.quarkus.arc.interceptors.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:42)
	at io.quarkus.arc.interceptors.InvocationContexts.performAroundInvoke(InvocationContexts.java:32)
	at org.acme.service.PersonService_Subclass.getAllPersons(PersonService_Subclass.zig:206)
	at org.acme.service.PersonService_ClientProxy.getAllPersons(PersonService_ClientProxy.zig:157)
	at org.acme.ExampleResource.hello(ExampleResource.java:21)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:151)
	at org.jboss.resteasy.core.MethodInjectorImpl.lambda$invoke$3(MethodInjectorImpl.java:122)
	at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602)
	at java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:614)
	at java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:1983)
	at java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:110)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:122)
	at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:594)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:468)
	at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:421)
	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:423)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:391)
	at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invoke$1(ResourceMethodInvoker.java:365)
	at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:981)
	at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2124)
	at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:110)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:365)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:477)
	... 14 more

To Reproduce
Steps to reproduce:

  1. Create a project with an entity and a NamedQuery. Example: https://github.com/belyaev-andrey/named-query-reload-test
  2. Run the application using mvn compile quarkus:dev
  3. Test that application works by opening URL http://localhost:8080/hello
  4. Change something in the application code, for example in class org.acme.service.PersonService update line 21 to return findAll.getResultList().subList(0, 2);
  5. Reload the application page mvn compile quarkus:dev

Configuration
see https://github.com/belyaev-andrey/named-query-reload-test

Environment (please complete the following information):

  • Output of uname -a or ver: OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
  • Output of java -version: Java HotSpot(TM) 64-Bit GraalVM EE 19.0.2 (build 25.212-b31-jvmci-19-b04, mixed mode)
  • Quarkus version or git rev: 0.26.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions