-
1. Re: JAX-RS helloworld on Wildfly 10
lcanales Dec 4, 2015 9:50 AM (in response to bertrandp)Hi,
I think @Path("/") should be @Path("/rest") in HelloWorld.java file.
Regards.
Luis.
-
2. Re: JAX-RS helloworld on Wildfly 10
bertrandp Dec 7, 2015 4:50 AM (in response to lcanales)Hi,
Yes indeed I also think the path should be @Path("/rest").
I changed it but I get the same: "Not Found" ...
-
3. Re: JAX-RS helloworld on Wildfly 10
mayerw01 Dec 7, 2015 6:23 AM (in response to bertrandp)I think there is a class missing which extends Application.
It should work if you add another file which looks like
package org.jboss.as.quickstarts.rshelloworld;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("rest")
public class JAXRSConfig extends Application {
public JAXRSConfig() {
}
}
-
4. Re: JAX-RS helloworld on Wildfly 10
bertrandp Dec 7, 2015 11:00 AM (in response to mayerw01)Hi,
So I my class now extends Application:
@ApplicationPath("/rest")
public class HelloWorld extends Application {
@Inject
HelloService helloService;
@GET
@Path("/json")
@Produces({ "application/json" })
public String getHelloWorldJSON() {
return "{\"result\":\"" + helloService.createHelloMessage("World") + "\"}";
}
@GET
@Path("/xml")
@Produces({ "application/xml" })
public String getHelloWorldXML() {
return "<xml><result>" + helloService.createHelloMessage("World") + "</result></xml>";
}
}
When I go to this url: http://localhost:8080/wildfly-helloworld-rs/rest/json I have this error:
16:53:20,919 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (default task-7) RESTEASY002010: Failed to execute: javax.ws.rs.NotFoundException: RESTEASY003210: Could not find resource for full path: http://localhost:8080/wildfly-helloworld-rs/rest/json
at org.jboss.resteasy.core.registry.ClassNode.match(ClassNode.java:75)
at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:445)
at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:254)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:191)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:72)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:198)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:788)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
-
5. Re: JAX-RS helloworld on Wildfly 10
mayerw01 Dec 7, 2015 12:19 PM (in response to bertrandp)I am not absolutely sure what you did here.
But as mentioned before you should not change anything in the source file but add an add'l java class that extends Application
-
6. Re: JAX-RS helloworld on Wildfly 10
bertrandp Dec 9, 2015 8:26 AM (in response to mayerw01)Indeed it works fine ! Thank you very much.
So in wildfly 10 if I want to deploy a JAX-RS webservice I need to add this class ? And this class only extends Application and specify the ApplicationPath right ?
-
7. Re: JAX-RS helloworld on Wildfly 10
mayerw01 Dec 9, 2015 9:34 AM (in response to bertrandp)I don't think this is related to WildFly 10 but documented in the API ApplicationPath (Java EE 6 )
"ApplicationPath Identifies the application path that serves as the base URI for all resource URIs provided by Path. May only be applied to a subclass of Application"
-
8. Re: JAX-RS helloworld on Wildfly 10
dean.w.schulze Dec 31, 2017 6:01 PM (in response to bertrandp)I get the same error with WildFly 11, and I have an subclass of javax.ws.rs.core.Application. Deploying the .war (which only contains my Application .class and resource .class files - no web.xml) gives:
Cannot upload deployment: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.pdfupload.POST_MODULE" => "WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"pdfupload\" Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYRS0006: Could not load JAX-RS Application class Caused by: java.lang.ClassNotFoundException: pdf.upload.server.PdfUploadApplication from [Module \"deployment.pdfupload\" from Service Module Loader]"}}
What do I have to do got get this deployed?