quarkusBuild / quarkusDev stuck using PanacheRepositoryResource with Quarkus > 1.8.0

Created on 18 Oct 2020  路  13Comments  路  Source: quarkusio/quarkus

Hello,

I麓m trying to use PanacheRepositoryResource with Quarkus 1.8.3 and running the application is getting stuck with the following trace

23:41:27: Executing task 'quarkusDev'...


> Task :quarkusGenerateCode
preparing quarkus application

> Task :compileJava
> Task :processResources UP-TO-DATE
> Task :classes

> Task :quarkusDev
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
Listening for transport dt_socket at address: 5005

I麓ve tried other versions like 1.8.1 with the same problem, but 1.7.3 works fine.

aregradle arepanache kinbug

All 13 comments

/cc @FroMage, @loicmathieu

/cc @gytis

@mklueh any chance that you could provide a reproducer? It seems to be working correctly on an example app that I have.

I looked through your application and there are a few issues that need to be addressed (I'm not sure what has changed since the 1.7.3. maybe other guys could expand on that).

First of all, fix the BaseEntity class to have an ID (this might be an issue in REST Data extension because vanilla Panache Hibernate doesn't seem to complain about this):

  • Extend either BanacheEntityBase or nothing. With a Panache repository, you don't need to extend anything.
  • Define an ID field so that Lombok could generate getters and setters.
  • Annotate the class with @MappedSuperclass

The other steps are not REST Data extension related and are needed with pure Panache Hibernate too.

  1. Add an author field with a @ManyToOne relation. Both sides of the relationship are needed.
  2. Annotate AuthorRepository with an @ApplicationScoped. Otherwise it won't be injectable.
  3. Define a datasource so that an entity manager would be registered and tables created:
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test
quarkus.hibernate-orm.database.generation=drop-and-create

The other steps are not REST Data extension related and are needed with pure Panache Hibernate too.

  1. Add an author field with a @ManyToOne relation. Both sides of the relationship are needed.
  2. Annotate AuthorRepository with an @ApplicationScoped. Otherwise it won't be injectable.
  3. Define a datasource so that an entity manager would be registered and tables created:

@gytis Thanks. You are right, some things are missing in the reproducer. I麓ve fixed that

I looked through your application and there are a few issues that need to be addressed (I'm not sure what has changed since the 1.7.3. maybe other guys could expand on that).

First of all, fix the BaseEntity class to have an ID (this might be an issue in REST Data extension because vanilla Panache Hibernate doesn't seem to complain about this):

  • Extend either BanacheEntityBase or nothing. With a Panache repository, you don't need to extend anything.
  • Define an ID field so that Lombok could generate getters and setters.
  • Annotate the class with @MappedSuperclass

Thank you for the hin. I think MappedSuperclass is what I want here :)

However it doesn麓t affect the original issue, it still exists.

I didn't mean that you only need to add the annotation. You should do all three things.

I'll look separately into why is this needed, because vanilla Hibernate with Panache doesn't seem to need it. It could be that REST Data tries to access ID but it's not where it expects it.

Could you please be more specific what is wrong with using PanachEntity in that case, which provides the ID attribute automatically? I've always used it that way without any issues and in this case it works perfectly.

Sorry, I might not have been clear enough. It is not wrong to use PanacheEntity. What I meant is that I had to remove it to make your reproducer function as expected and that is most likely caused by an issue in the REST Data extension.

A bit more information about the issue. This is not Gradle related, I'm able to reproduce it with Maven too.
Also, this is not exactly caused by a PanacheEntity. Application gets stuck when an entity extends a class which also extends a class (e.g. Person < AbstractPerson < AbstractEntity). I'll keep investigating.

I found a bug that causes this entity hierarchy to fail. Will raise a PR today.

A bit more information about the issue. This is not Gradle related, I'm able to reproduce it with Maven too.
Also, this is not exactly caused by a PanacheEntity. Application gets stuck when an entity extends a class which also extends a class (e.g. Person < AbstractPerson < AbstractEntity). I'll keep investigating.

Interesting. Wasn't sure if the inheritance was the cause but had not tested it without. Thanks for your help

This fix will be backported to 1.9.1.Final that I will release next week.

Was this page helpful?
0 / 5 - 0 ratings