@Path("/pagamento")
public class PagamentoService {
@Inject
private CompraDao compraDao;
@Context
ServletContext context;
@Inject
private PagamentoGateway pagamentoGateway;
private static ExecutorService executor = Executors.newFixedThreadPool(50);
@POST
public void paga(@Suspended AsyncResponse ar, @QueryParam("uuid") String uuid) {
executor.submit(()->{
try {
Compra compra = compraDao.buscaPorUuid(uuid);
pagamentoGateway.paga(compra.getTotal());
URI uri = UriBuilder.fromPath("http://localhost:8080"+ context.getContextPath() + "/index.xhtml")
.queryParam("msg", "Compra realizada com sucesso")
.build();
Response response = Response.seeOther(uri).build();
ar.resume(response);
}catch(Exception e) {
ar.resume(new WebApplicationException(e));
}
});
}
}
03:04:56,220 ERROR [stderr] (pool-5-thread-1) org.jboss.resteasy.spi.LoggableFailure: RESTEASY003880: Unable to find contextual data of type: javax.servlet.ServletContext
03:04:56,221 ERROR [stderr] (pool-5-thread-1) at org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:62)
03:04:56,221 ERROR [stderr] (pool-5-thread-1) at com.sun.proxy.$Proxy99.getContextPath(Unknown Source)
03:04:56,222 ERROR [stderr] (pool-5-thread-1) at br.com.casadocodigo.loja.services.PagamentoService.lambda$0(PagamentoService.java:43)
03:04:56,222 ERROR [stderr] (pool-5-thread-1) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
03:04:56,222 ERROR [stderr] (pool-5-thread-1) at java.util.concurrent.FutureTask.run(FutureTask.java:266)
03:04:56,223 ERROR [stderr] (pool-5-thread-1) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
03:04:56,223 ERROR [stderr] (pool-5-thread-1) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
03:04:56,223 ERROR [stderr] (pool-5-thread-1) at java.lang.Thread.run(Thread.java:748)
03:05:08,036 ERROR [stderr] (pool-5-thread-1) org.jboss.resteasy.spi.LoggableFailure: RESTEASY003880: Unable to find contextual data of type: javax.servlet.ServletContext
03:05:08,036 ERROR [stderr] (pool-5-thread-1) at org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:62)
03:05:08,037 ERROR [stderr] (pool-5-thread-1) at com.sun.proxy.$Proxy99.getContextPath(Unknown Source)
03:05:08,037 ERROR [stderr] (pool-5-thread-1) at br.com.casadocodigo.loja.services.PagamentoService.lambda$0(PagamentoService.java:43)
03:05:08,037 ERROR [stderr] (pool-5-thread-1) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
03:05:08,038 ERROR [stderr] (pool-5-thread-1) at java.util.concurrent.FutureTask.run(FutureTask.java:266)
03:05:08,038 ERROR [stderr] (pool-5-thread-1) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
03:05:08,038 ERROR [stderr] (pool-5-thread-1) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
03:05:08,039 ERROR [stderr] (pool-5-thread-1) at java.lang.Thread.run(Thread.java:748)
03:05:20,690 ERROR [org.jboss.resteasy.resteasy_jaxrs.i18n] (pool-5-thread-1) RESTEASY002010: Failed to execute: javax.ws.rs.WebApplicationException: HTTP 500 Internal Server Error
at br.com.casadocodigo.loja.services.PagamentoService.lambda$0(PagamentoService.java:49)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.jboss.resteasy.spi.LoggableFailure: RESTEASY003880: Unable to find contextual data of type: javax.servlet.ServletContext
at org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:62)
at com.sun.proxy.$Proxy99.getContextPath(Unknown Source)
at br.com.casadocodigo.loja.services.PagamentoService.lambda$0(PagamentoService.java:43)
... 5 more