Я скачал базу кода и сервер WildFly 10.1.0.Final
. Я также столкнулся с той же проблемой.
Root Причина проблемы: Использование @ApplicationPath и @Path одновременно в классе создавало проблему.
Этот класс RestService.java
создает проблему.
Измените RestService.java
(удалите @ApplicationPath
из этого класса):
@Path("/MyRestService")
public class RestService {
// http://localhost:8080/RestExample/resources/MyRestService/sayHello
@GET
@Path("/sayHello")
public String getHelloMsg() {
return "Hello World";
}
@GET
@Path("/echo")
public Response getEchoMsg(@QueryParam("message") String msg) {
return Response.ok("Your message was: " + msg).build();
}
@GET
@Path("/object")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public SimpleObject getObject() {
return new SimpleObject(1, "Test");
}
}
Я добавил новый класс RestApp.java
. Код:
@ApplicationPath("/resources")
public class RestApp extends Application {
}
Обновленная структура проекта:
Журнал Wildfly (успешное развертывание):
21:05:09,997 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-7) WFLYDS0013: Started FileSystemDeploymentService for directory C:\Users\Anish\Downloads\wildfly-10.1.0.Final\wildfly-10.1.0.Final\standalone\deployments
21:05:10,157 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0027: Starting deployment of "RestExample.war" (runtime-name: "RestExample.war")
21:05:10,312 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-1) ISPN000128: Infinispan version: Infinispan 'Chakra' 8.2.4.Final
21:05:10,432 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 63) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
21:05:10,434 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 60) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
21:05:10,473 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 60) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
21:05:10,476 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 63) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
21:05:10,431 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 65) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
21:05:10,512 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 65) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated.
21:05:12,754 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080
21:05:13,012 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]
21:05:13,434 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
21:05:13,603 INFO [org.jboss.ws.common.management] (MSC service thread 1-6) JBWS022052: Starting JBossWS 5.1.5.Final (Apache CXF 3.1.6)
21:05:14,003 INFO [org.jboss.weld.deployer] (MSC service thread 1-4) WFLYWELD0003: Processing weld deployment RestExample.war
21:05:14,103 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-4) HV000001: Hibernate Validator 5.2.4.Final
21:05:14,443 INFO [org.jboss.weld.Version] (MSC service thread 1-4) WELD-000900: 2.3.5 (Final)
21:05:15,748 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 59) Initializing Mojarra 2.2.13.SP1 20160303-1204 for context '/RestExample'
21:05:16,915 INFO [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 59) RESTEASY002225: Deploying javax.ws.rs.core.Application: class de.dks.ws.RestApp$Proxy$_$$_WeldClientProxy
21:05:17,050 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 59) WFLYUT0021: Registered web context: /RestExample
21:05:17,144 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "RestExample.war" (runtime-name : "RestExample.war")
21:05:17,304 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
21:05:17,305 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
21:05:17,310 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in 13646ms - Started 435 of 683 services (404 services are lazy, passive or on-demand)
Снимок экрана:
Снимок экрана для RestClient:
Нажав на Позвоните в Webservice и получите выходные данные:
Примечание: Не забудьте добавить эти банки javax.faces.api-2.2.jar
и javax.ws.rs-api-2.0.1.jar
в вашем проекте WebContent/WEB-INF/lib
.
Модифицированная ссылка проекта: https://github.com/anish-fullstack/RestExample