Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Data fails with casting exception when returning primitive data types after Spring bump to 3.2 #41134

Closed
michalvavrik opened this issue Jun 11, 2024 · 4 comments · Fixed by quarkusio/quarkus-spring-data-api#14 or #41206
Labels
area/spring Issues relating to the Spring integration kind/bug Something isn't working
Milestone

Comments

@michalvavrik
Copy link
Member

michalvavrik commented Jun 11, 2024

Describe the bug

After #40344 my repository method returns different type than declared:

@RepositoryRestResource(exported = false)
public interface BookRepository extends CrudRepository<Book, Integer> {

    @Query(value = "SELECT b.publicationYear FROM Book b where b.bid = :bid")
    int customFindPublicationYearPrimitive(@Param("bid") Integer bid);
}

Expected behavior

Return integer.

Actual behavior

Exception is thrown:

22:15:39,986 INFO  [app] 22:15:38,456 HTTP Request to /book/paged?size=2&page=1 failed, error id: c89a99f8-505c-4f75-a88b-747e1dead71d-1: java.lang.NoClassDefFoundError: org/springframework/data/domain/Limit
22:15:39,987 INFO  [app] 	at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
22:15:39,988 INFO  [app] 	at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3578)
22:15:39,989 INFO  [app] 	at java.base/java.lang.Class.getDeclaredMethods(Class.java:2676)
22:15:39,989 INFO  [app] 	at com.fasterxml.jackson.databind.util.ClassUtil.getClassMethods(ClassUtil.java:1317)
22:15:39,990 INFO  [app] 	at com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector._addMemberMethods(AnnotatedMethodCollector.java:115)
22:15:39,991 INFO  [app] 	at com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector.collect(AnnotatedMethodCollector.java:54)
22:15:39,991 INFO  [app] 	at com.fasterxml.jackson.databind.introspect.AnnotatedMethodCollector.collectMethods(AnnotatedMethodCollector.java:40)
22:15:39,992 INFO  [app] 	at com.fasterxml.jackson.databind.introspect.AnnotatedClass._methods(AnnotatedClass.java:386)
22:15:39,992 INFO  [app] 	at com.fasterxml.jackson.databind.introspect.AnnotatedClass.memberMethods(AnnotatedClass.java:326)
22:15:39,993 INFO  [app] 	at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector._addMethods(POJOPropertiesCollector.java:794)
22:15:39,993 INFO  [app] 	at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.collectAll(POJOPropertiesCollector.java:480)
22:15:39,994 INFO  [app] 	at com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector.getJsonValueAccessor(POJOPropertiesCollector.java:294)
22:15:39,995 INFO  [app] 	at com.fasterxml.jackson.databind.introspect.BasicBeanDescription.findJsonValueAccessor(BasicBeanDescription.java:258)
22:15:39,995 INFO  [app] 	at com.fasterxml.jackson.databind.ser.BasicSerializerFactory.findSerializerByAnnotations(BasicSerializerFactory.java:393)
22:15:39,996 INFO  [app] 	at com.fasterxml.jackson.databind.ser.BeanSerializerFactory._createSerializer2(BeanSerializerFactory.java:225)
22:15:39,996 INFO  [app] 	at com.fasterxml.jackson.databind.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:174)
22:15:39,997 INFO  [app] 	at com.fasterxml.jackson.databind.SerializerProvider._createUntypedSerializer(SerializerProvider.java:1525)
22:15:39,997 INFO  [app] 	at com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:1473)
22:15:39,998 INFO  [app] 	at com.fasterxml.jackson.databind.SerializerProvider.findPrimaryPropertySerializer(SerializerProvider.java:739)
22:15:39,998 INFO  [app] 	at com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap.findAndAddPrimarySerializer(PropertySerializerMap.java:64)
22:15:39,999 INFO  [app] 	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter._findAndAddDynamic(BeanPropertyWriter.java:901)
22:15:39,999 INFO  [app] 	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:710)
22:15:40,000 INFO  [app] 	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770)
22:15:40,000 INFO  [app] 	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:183)
22:15:40,001 INFO  [app] 	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:502)
22:15:40,001 INFO  [app] 	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:422)
22:15:40,002 INFO  [app] 	at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1570)
22:15:40,003 INFO  [app] 	at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:1061)
22:15:40,003 INFO  [app] 	at org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.writeTo(ResteasyJackson2Provider.java:337)
22:15:40,004 INFO  [app] 	at org.jboss.resteasy.core.messagebody.AsyncBufferedMessageBodyWriter.asyncWriteTo(AsyncBufferedMessageBodyWriter.java:24)
22:15:40,004 INFO  [app] 	at org.jboss.resteasy.core.interception.jaxrs.ServerWriterInterceptorContext.writeTo(ServerWriterInterceptorContext.java:81)
22:15:40,005 INFO  [app] 	at org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.asyncProceed(AbstractWriterInterceptorContext.java:190)
22:15:40,005 INFO  [app] 	at org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInterceptorContext.getStarted(AbstractWriterInterceptorContext.java:158)
22:15:40,006 INFO  [app] 	at org.jboss.resteasy.core.interception.jaxrs.ServerWriterInterceptorContext.lambda$getStarted$0(ServerWriterInterceptorContext.java:68)
22:15:40,006 INFO  [app] 	at org.jboss.resteasy.core.interception.jaxrs.ServerWriterInterceptorContext.aroundWriteTo(ServerWriterInterceptorContext.java:87)
22:15:40,007 INFO  [app] 	at org.jboss.resteasy.core.interception.jaxrs.ServerWriterInterceptorContext.getStarted(ServerWriterInterceptorContext.java:68)
22:15:40,007 INFO  [app] 	at org.jboss.resteasy.core.ServerResponseWriter.lambda$writeNomapResponse$3(ServerResponseWriter.java:166)
22:15:40,008 INFO  [app] 	at org.jboss.resteasy.core.interception.jaxrs.ContainerResponseContextImpl.filter(ContainerResponseContextImpl.java:365)
22:15:40,008 INFO  [app] 	at org.jboss.resteasy.core.ServerResponseWriter.executeFilters(ServerResponseWriter.java:243)
22:15:40,009 INFO  [app] 	at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:100)
22:15:40,010 INFO  [app] 	at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:73)
22:15:40,010 INFO  [app] 	at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:518)
22:15:40,011 INFO  [app] 	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:458)
22:15:40,011 INFO  [app] 	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invokePropagateNotFound$6(SynchronousDispatcher.java:275)
22:15:40,012 INFO  [app] 	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:154)
22:15:40,012 INFO  [app] 	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:321)
22:15:40,012 INFO  [app] 	at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:157)
22:15:40,013 INFO  [app] 	at org.jboss.resteasy.core.SynchronousDispatcher.invokePropagateNotFound(SynchronousDispatcher.java:260)
22:15:40,013 INFO  [app] 	at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:84)
22:15:40,013 INFO  [app] 	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
22:15:40,014 INFO  [app] 	at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:97)
22:15:40,014 INFO  [app] 	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:599)
22:15:40,014 INFO  [app] 	at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
22:15:40,015 INFO  [app] 	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
22:15:40,015 INFO  [app] 	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
22:15:40,015 INFO  [app] 	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
22:15:40,016 INFO  [app] 	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
22:15:40,016 INFO  [app] 	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
22:15:40,016 INFO  [app] 	at java.base/java.lang.Thread.run(Thread.java:1583)
22:15:40,017 INFO  [app] Caused by: java.lang.ClassNotFoundException: org.springframework.data.domain.Limit
22:15:40,017 INFO  [app] 	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
22:15:40,017 INFO  [app] 	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
22:15:40,017 INFO  [app] 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
22:15:40,018 INFO  [app] 	at io.quarkus.bootstrap.runner.RunnerClassLoader.loadClass(RunnerClassLoader.java:113)
22:15:40,018 INFO  [app] 	at io.quarkus.bootstrap.runner.RunnerClassLoader.loadClass(RunnerClassLoader.java:71)
22:15:40,018 INFO  [app] 	... 59 more

How to Reproduce?

Reproducer:

  1. git clone git@github.com:michalvavrik/quarkus-test-suite.git -b feature/fix-spring-data-compilation
  2. cd quarkus-test-suite/spring/spring-data
  3. mvn clean verify -Dit.test=SpringDataCompositeEntityIT#ensureFieldPageableIsSerialized -Dreruns=0

Output of uname -a or ver

Fedora 38

Output of java -version

OpenJDK 21

Quarkus version or git rev

999-SNAPSHOT

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.4

Additional information

No response

@michalvavrik michalvavrik added kind/bug Something isn't working area/spring Issues relating to the Spring integration labels Jun 11, 2024
Copy link

quarkus-bot bot commented Jun 11, 2024

/cc @geoand (spring)

@michalvavrik
Copy link
Member Author

/cc @aureamunoz

@aureamunoz
Copy link
Member

This needs a new release of quarkus-spring-data-api @gsmet. I'll send you an email

@geoand
Copy link
Contributor

geoand commented Jun 17, 2024

Fixed by #41206

@geoand geoand closed this as completed Jun 17, 2024
@geoand geoand added this to the 3.13 - main milestone Jun 17, 2024
@gsmet gsmet modified the milestones: 3.13 - main, 3.12.0 Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/spring Issues relating to the Spring integration kind/bug Something isn't working
Projects
None yet
4 participants