-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
PanacheRepositoryResource fails on POST when the resource's path includes a @PathParam #35167
Comments
/cc @FroMage (panache), @Sgitario (rest-data-panache), @loicmathieu (panache) |
This error seems to be related to the generation of the links. As a workaround, you can try with disabling hal:
About the issue, can you share your resource class to reproduce and better troubleshoot what the root cause is? Thanks! |
Thank you, but the issue remains. My ugly workaround right now is extending the path of the endpoint with "/add" by using a default method.
Yes! I will add an example. |
Here is a entity I created to test the issue. import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.SequenceGenerator;
@Entity
public class Test {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "test_seq")
@SequenceGenerator(name = "test_seq", sequenceName = "test_sequence")
private Long id;
private String description;
public Test() {}
public Test(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
} The entity's repository is the standard: import io.quarkus.hibernate.orm.panache.PanacheRepository;
import jakarta.enterprise.context.ApplicationScoped;
@ApplicationScoped
public class TestRepository implements PanacheRepository<Test> {
} And the resource: import io.quarkus.hibernate.orm.rest.data.panache.PanacheRepositoryResource;
import io.quarkus.rest.data.panache.ResourceProperties;
@ResourceProperties(hal = false, path = "api/project/{projectId}/test")
public interface TestResource extends PanacheRepositoryResource<TestRepository, Test, Long> {
} I was able to reproduce the issue with this. |
So, you're trying to use it as a sub-resource of a top parent resource. There is an existing feature request to support this use case: #28450 |
This is related to quarkusio#35167. Even though HAL is disabled by default, it's still used to generate unexpected links and to set the location.
This is related to quarkusio#35167. Even though HAL is disabled by default, it's still used to generate unexpected links and to set the location.
About disabling HAL, this was actually a bug that should be fixed in #35181. So, after merging this pull request, your issue will be gone. |
This is related to quarkusio#35167. Even though HAL is disabled by default, it's still used to generate unexpected links and to set the location.
This is related to quarkusio#35167. Even though HAL is disabled by default, it's still used to generate unexpected links and to set the location.
Thank you! |
This is related to quarkusio#35167. Even though HAL is disabled by default, it's still used to generate unexpected links and to set the location. (cherry picked from commit 362f03a)
Describe the bug
I'm using the PanacheRepositoryResource interface to create the Jax Resources.
The only difference from what works is the use of a path parameter, like "/project/{projectId}/".
All my POST requests end up with 500 errors saying "Failed to add an entity" and further down the stacktrace it says
"Discovery failed for method com.envisage.gene.rest.project.dependent.TargetResourceJaxRs_597046d94bad44a89428c15444fc02a72e8750c2.get: RESTEASY012060: Not enough URI parameters: expecting 2 but only found 1".
Bearing in mind that the endpoint I'm trying to hit is something like:
http://localhost:8080/api/project/{projectId}/target
After a lot of tinkering around, I can only assume the error must be something with Panache itself.
Unless I have missed something.
Expected behavior
A POST request is made to the endpoint: http://localhost:8080/api/project/{projectId}/target
The server handles the request and creates the requested entity.
A response with status 201 is returned.
Actual behavior
A POST request is made to the endpoint: http://localhost:8080/api/project/{projectId}/target
The server is unable to hit the endpoint and returns a 500 status error.
How to Reproduce?
No response
Output of
uname -a
orver
Linux 5.15.0-78-generic 20.04.1-Ubuntu
Output of
java -version
openjdk version "11.0.20" 2023-07-18 LTS OpenJDK Runtime Environment Corretto-11.0.20.8.1 (build 11.0.20+8-LTS) OpenJDK 64-Bit Server VM Corretto-11.0.20.8.1 (build 11.0.20+8-LTS, mixed mode)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
3.2.2.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.3 (21122926829f1ead511c958d89bd2f672198ae9f)
Additional information
The stacktrace of the error
The text was updated successfully, but these errors were encountered: