question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

REST Data Panache with ResteasyReactive: field 'id' was not found error

See original GitHub issue

Describe the bug

When using REST Data Panache with ResteasyReactive for entity that has an id field not named “id” application crashes on start with exception:

Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.resteasy.reactive.links.deployment.LinksProcessor#initializeLinksProvider threw an exception: java.lang.RuntimeException: Class 'java.lang.Object' field 'id' was not found
	at io.quarkus.resteasy.reactive.links.deployment.LinksProcessor.getFieldInfo(LinksProcessor.java:146)
	at io.quarkus.resteasy.reactive.links.deployment.LinksProcessor.getFieldInfo(LinksProcessor.java:144)
	at io.quarkus.resteasy.reactive.links.deployment.LinksProcessor.getFieldInfo(LinksProcessor.java:144)
	at io.quarkus.resteasy.reactive.links.deployment.LinksProcessor.implementPathParameterValueGetters(LinksProcessor.java:103)
	at io.quarkus.resteasy.reactive.links.deployment.LinksProcessor.initializeLinksProvider(LinksProcessor.java:65

example entity:

public class ExampleEntity extends PanacheEntityBase {
    @Id
    long companyId;
}

example resource:

@ResourceProperties(path =  "/example")
public interface ExampleResource extends PanacheEntityResource<ExampleEntity, Long> {
}

Data Panache generate resource with path “/example/{id}” so io.quarkus.resteasy.reactive.links.deployment.LinksProcessor#getFieldInfo scans for field “id”, ignoring the fact that entity can have id field with whatever name but with annotation @Id

Expected behavior

REST Data Panache with ResteasyReactive should work with an entity with id field not named “id” but annotated with @Id

Actual behavior

No response

How to Reproduce?

use

        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-hibernate-orm-rest-data-panache</artifactId>
        </dependency>
    <dependency>
      <groupId>io.quarkus</groupId>
      <artifactId>quarkus-resteasy-reactive</artifactId>
    </dependency>

example entity:

public class ExampleEntity extends PanacheEntityBase {
    @Id
    long companyId;
}

example resource:

@ResourceProperties(path =  "/example")
public interface ExampleResource extends PanacheEntityResource<ExampleEntity, Long> {
}

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.9.2.Final

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

No response

Additional information

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
loicmathieucommented, Jun 2, 2022

Can you change the type of your id to Long instead of the primitive type long ?

By the way, this is the default ID field provided by PanacheEntity so you better use PanacheEntity instead of PanacheEntityBase.

0reactions
geoandcommented, Jun 2, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Writing REST Services with RESTEasy Reactive - Quarkus
When the result the userPublic method is serialized, the id field will not be contained in the response as the Public view does...
Read more >
Errors after switching to quarkus-resteasy-reactive
The release notes for 2.8 tell me I should switch to quarkus-resteasy-reactive and it's a 1:1 replacment and no changes are necessary.
Read more >
StackOverflowError when executing Hibernate Panache list ...
Hi Quarkus devs, I've stumbled upon a "RESTEASY008205: JSON Binding serialization error java.lang.StackOverflowError" when executing a REST GET backed by an ...
Read more >
Data Persistence with Quarkus and Hibernate Panache
orm.panache.PanacheEntity : This is the simplest option as you will get an ID field that is auto-generated. Extending io.quarkus.hibernate.
Read more >
Build a REST API from the ground up with Quarkus 2.0
Lombok is a Java library that helps keep the amount of boilerplate code in an application to a minimum; however, its use is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found