Я следил за руководством по
.
Все шло хорошо, пока последняя часть, где в проекте был представлен index.xhtml.
Я получаю ошибку 404 в браузере, а в журнале консоли wildfly получаю следующее ошибка:
18:24:52,128 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 64) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./RestExample: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./RestExample: org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:85)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)
Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped
at org.jboss.weld.manager.BeanManagerImpl.getContext(BeanManagerImpl.java:689)
at org.jboss.weld.bean.ContextualInstanceStrategy$DefaultContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:90)
at org.jboss.weld.bean.ContextualInstanceStrategy$CachingContextualInstanceStrategy.getIfExists(ContextualInstanceStrategy.java:165)
at org.jboss.weld.bean.ContextualInstance.getIfExists(ContextualInstance.java:63)
at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:83)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.getInstance(ProxyMethodHandler.java:125)
at org.jboss.weld.proxies.RestService$Proxy$_$$_WeldClientProxy.getClasses(Unknown Source)
at org.jboss.resteasy.spi.ResteasyDeployment.processApplication(ResteasyDeployment.java:490)
at org.jboss.resteasy.spi.ResteasyDeployment.registration(ResteasyDeployment.java:336)
at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:250)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:113)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78)
at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:250)
at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:133)
at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:546)
at io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:517)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:559)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:101)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:82)
... 6 more
18:24:52,133 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "RestExample.war")]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./RestExample" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./RestExample: org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped
Caused by: org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active contexts for scope type javax.enterprise.context.RequestScoped"},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.undertow.deployment.default-server.default-host./RestExample"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}
WFLYCTL0184: New missing/unsatisfied dependencies:
service jboss.deployment.unit."RestExample.war".component."com.sun.faces.config.ConfigureListener".START (missing) dependents: [service jboss.deployment.unit."RestExample.war".deploymentCompleteService]
service jboss.deployment.unit."RestExample.war".component."javax.faces.webapp.FacesServlet".START (missing) dependents: [service jboss.deployment.unit."RestExample.war".deploymentCompleteService]
service jboss.deployment.unit."RestExample.war".component."javax.faces.webapp.FacetTag".START (missing) dependents: [service jboss.deployment.unit."RestExample.war".deploymentCompleteService]
service jboss.deployment.unit."RestExample.war".component."managed-bean.RestClient".START (missing) dependents: [service jboss.deployment.unit."RestExample.war".deploymentCompleteService]
service jboss.deployment.unit."RestExample.war".component."org.jboss.weld.servlet.WeldInitialListener".START (missing) dependents: [service jboss.deployment.unit."RestExample.war".deploymentCompleteService]
WFLYCTL0186: Services which failed to start: service jboss.undertow.deployment.default-server.default-host./RestExample
Мой web.xml:
RestExample
index.xhtml
Faces Servlet
javax.faces.webapp.FacesServlet
1
Faces Servlet
*.xhtml
Я создал пустой beans.xml, как в учебнике.
Содержимое моего index.xhtml:
RestClient.java:
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@ApplicationScoped
@ManagedBean
public class RestClient {
public void call() {
Client client = ClientBuilder.newClient();
SimpleObject o = client.target("http://localhost:8080/RestExample/resou ... ice/object").request().get(SimpleObject.class);
System.out.println(o);
}
}
RestService.java:
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/MyRestService")
@ApplicationPath("/resources")
public class RestService extends Application {
// http://localhost:8080/RestExample/resou ... e/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");
}
}
SimpleObject.java:
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class SimpleObject {
private int id;
private String name;
public SimpleObject() {
}
public SimpleObject(int id, String name) {
super();
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Подробнее здесь: https://stackoverflow.com/questions/609 ... on-wildfly