I have a Java interface which declares all things related to JaxRs like this:
@Path("/notes-service")
public interface NotesApi {
@POST
@Path("/notes")
@Consumes({ "application/json" })
@Produces({ "application/json" })
Response createNote(
@HeaderParam("Accept-Language") @DefaultValue("en") String acceptLanguage,
@Valid CreateNoteDTO createNoteDTO);
}
The interface is shipped as an external dependency as a jar.
And an implementation in my service:
@ApplicationScoped
@Transactional
public class NotesService implements NotesApi {
@Override
public Response createNote(String range, CreateNoteDTO createNoteDTO) {
// ...
}
}
Such a setup like above doesn't work. It returnes 404 for an endpoint /notes-service/notes
However when I copy the @Path part into the implenentation, everything works just fine:
@ApplicationScoped
@Transactional
@Path("/notes-service")
public class NotesService implements NotesApi {
@Override
public Response createNote(String range, CreateNoteDTO createNoteDTO) {
// ...
}
}
Also another workaaround: When I copy-paste the interface into my service then it also works without @Path declaration in an implementation.
This means that @Path annotation on interface level works just fine (I have checked it with a minimal service). But it doesn't work when the interface comes as a dependency.
Is it a bug in Quarkus or an expected behavior?
You need to add an empty beans.xml in your external project in src/main/resources/META-INF, so that Quarkus scans your external jar file.
Quarkus documentation also lists other ways to make beans discoverable:
beans.xml descriptor (content is ignored)META-INF/jandex.idxquarkus.index-dependency in application.propertieshttps://quarkus.io/guides/cdi-reference#bean_discovery
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With