[ https://issues.apache.org/jira/browse/TOMEE-2071?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Romain Manni-Bucau updated TOMEE-2071: -------------------------------------- Summary: OpenEJBAsyncContext NPE when using AsyncResponse with no web application in 3mbedded mode (was: OpenEJBAsyncContext NPE when using AsyncResponse) > OpenEJBAsyncContext NPE when using AsyncResponse with no web application in > 3mbedded mode > ----------------------------------------------------------------------------------------- > > Key: TOMEE-2071 > URL: https://issues.apache.org/jira/browse/TOMEE-2071 > Project: TomEE > Issue Type: Bug > Components: TomEE Core Server > Affects Versions: 7.0.2, 7.0.3 > Reporter: antoine vianey > > Using the following code works fine with Tomee (mvn tomee:run) and return a > 201 OK response along with the location. > {code:java} > @POST > public void post(@Context UriInfo uriInfo, > @Suspended AsyncResponse asyncResponse, > @NotNull @Valid MyDTO myDTO) throws ParseException { > CompletableFuture<MyBean> cf = supplyAsync(() -> doSomething(myDTO), > executorService); > cf > .thenAccept(myBean -> { > URI location = > uriInfo.getRequestUri().resolve(uriInfo.getPath() + "/" + myBean.getId()); > Response response = Response.created(location).build(); > asyncResponse.resume(response); > }).exceptionally(e -> { > logger.error("An Error occurred.", e); > asyncResponse.resume(Response.serverError().build()); > return null; > }); > } > {code} > But when called in tests with OPENEJB EMBEDDED like this : > {code:java} > Properties p = new Properties(); > p.setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true"); > p.setProperty(EJBContainer.APP_NAME, "/app"); > EJBContainer ejbContainer = EJBContainer.createEJBContainer(p); > {code} > It fails with this.context being null at (with exceptionnaly not bein called > in my method) : > java.lang.NullPointerException > at > org.apache.openejb.server.httpd.OpenEJBAsyncContext.dispatch(OpenEJBAsyncContext.java:230) > at > org.apache.openejb.server.httpd.OpenEJBAsyncContext.dispatch(OpenEJBAsyncContext.java:223) > at > org.apache.openejb.server.httpd.OpenEJBAsyncContext.dispatch(OpenEJBAsyncContext.java:218) > at > org.apache.openejb.server.httpd.EEFilter$AsynContextWrapper.dispatch(EEFilter.java:171) > at > org.apache.cxf.transport.http.Servlet3ContinuationProvider$Servlet3Continuation.redispatch(Servlet3ContinuationProvider.java:125) > at > org.apache.cxf.transport.http.Servlet3ContinuationProvider$Servlet3Continuation.resume(Servlet3ContinuationProvider.java:131) > at > org.apache.cxf.jaxrs.impl.AsyncResponseImpl.doResumeFinal(AsyncResponseImpl.java:96) > at > org.apache.cxf.jaxrs.impl.AsyncResponseImpl.doResume(AsyncResponseImpl.java:89) > at > org.apache.cxf.jaxrs.impl.AsyncResponseImpl.resume(AsyncResponseImpl.java:73) > at > com.engagetech.challenge.service.ExpenseService.lambda$post$1(MyService.java:80) > at > java.util.concurrent.CompletableFuture.uniAccept(CompletableFuture.java:656) > at > java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:632) > at > java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474) > at > java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1595) > 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:748) -- This message was sent by Atlassian JIRA (v6.4.14#64029)