quarkiverse / quarkus-jnosql

The Quarkus JNoSql Extension adds support for JNoSQL, an implementation of Jakarta NoSQL.
http://www.jnosql.org/
Apache License 2.0
13 stars 4 forks source link

Query by template returns an error. #25

Closed otaviojava closed 1 year ago

otaviojava commented 1 year ago

When I execute the:

template.select(Fish.class).result();

It returns:

org.jboss.resteasy.spi.UnhandledException: org.eclipse.jnosql.mapping.reflection.ClassInformationNotFoundException: There is not entity found with the name: Fish
        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:576)
        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 java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.eclipse.jnosql.mapping.reflection.ClassInformationNotFoundException: There is not entity found with the name: Fish
        at org.eclipse.jnosql.mapping.reflection.DefaultEntitiesMetadata.lambda$findByName$5(DefaultEntitiesMetadata.java:101)
        at java.base/java.util.Optional.orElseThrow(Optional.java:403)
        at org.eclipse.jnosql.mapping.reflection.DefaultEntitiesMetadata.findByName(DefaultEntitiesMetadata.java:101)
        at org.eclipse.jnosql.mapping.reflection.DefaultEntitiesMetadata_ClientProxy.findByName(Unknown Source)
        at org.eclipse.jnosql.mapping.document.DocumentEntityConverter.toEntity(DocumentEntityConverter.java:122)
        at org.eclipse.jnosql.mapping.document.DefaultDocumentEntityConverter_ClientProxy.toEntity(Unknown Source)
        at org.eclipse.jnosql.mapping.document.AbstractDocumentTemplate.lambda$executeQuery$7(AbstractDocumentTemplate.java:233)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
        at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
        at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
        at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
        at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622)
        at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627)
        at org.eclipse.jnosql.mapping.document.DocumentMapperSelect.result(DocumentMapperSelect.java:168)
        at org.jnosql.demoee.FishService.findAll(FishService.java:26)
        at org.jnosql.demoee.FishService_ClientProxy.findAll(Unknown Source)
        at org.jnosql.demoee.FishResource.findAll(FishResource.java:33)
        at org.jnosql.demoee.FishResource_ClientProxy.findAll(Unknown Source)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:154)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:118)
        at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:560)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:452)
        at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:413)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:321)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:415)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:378)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:356)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:70)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:429)
        ... 15 more
otaviojava commented 1 year ago

At the CDI reflection, we are using this as extension EntityMetadataExtension

otaviojava commented 1 year ago

@amoscatelli
I did it this way: https://github.com/JNOSQL/demo-ee/tree/main/quarkus-mongodb

I created the Application class which starts and load the class.

amoscatelli commented 1 year ago

The problem is that the EntityMetadataExtension afterBeanDiscovery(@Observes BeforeBeanDiscovery event) is never called. Probably Quarkus doesn't support BeforeBeanDiscovery event.

I am gonna dig into this tomorrow.

Probably all we had to do is to provide an Alternative EntityMetadataExtension

otaviojava commented 1 year ago

Yeap, I did it manually:

@Inject
private EntitiesMetadata entities;

void onStart(@Observes StartupEvent ev) {
        LOGGER.info("Starting application loading entities");
        entities.get(Fish.class);
    }
otaviojava commented 1 year ago

Please, let me know what you need, so we can fix it and release a new version fix: 1.0.1.

amoscatelli commented 1 year ago

No worry, there is no need to release a new version of JNoSQL We are going to solve it extension side.

The "clean" solution is to manually trigger the afterBeanDiscovery method. I am studying the best approach for quarkus, give me some more time :)

otaviojava commented 1 year ago

Thank you, @amoscatelli, please, let me know when the new release is ready for more tests.