I have created a simple endpoint in Helidon:
@GET
@Path("/sampleString")
@Produces(MediaType.APPLICATION_JSON)
public Message getSampleString() {
return "{'Sample':'String'}";
}
The code complies and runs. But when I call:
curl -i http://localhost:8080/sampleString
I receive:
No handler found for path: /sampleString
What am I missing?
Most probably you are missing the META-INF/beans.xml
file.
It should be as simple as that:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
https://jakarta.ee/xml/ns/jakartaee/beans_3_0.xsd"
version="3.0"
bean-discovery-mode="annotated">
</beans>
To check it you may set org.jboss.level=DEBUG
in logging.properties
. When you run your app, you should see something like:
WARNING io.helidon.microprofile.server.ServerCdiExtension Thread[#1,main,5,main]: There are no JAX-RS applications or resources. Maybe you forgot META-INF/beans.xml file?