[wildfly-dev] Injecting ManagedExecutorService results in NPE
Ingo Weiss
ingo at redhat.com
Tue Mar 22 09:57:53 EDT 2016
On 22/03/2016 13:28, Stuart Douglas wrote:
> Where are you trying to use these?
>
> Stuart
>
> On Wed, 23 Mar 2016, 00:18 Ingo Weiss <ingo at redhat.com
> <mailto:ingo at redhat.com>> wrote:
>
> Hi,
>
> I was testing injecting the default ManagedExecutorService on WF10 and
> it returns a NullPointerException if I don't do a lookup.
>
> These result in a NPE:
>
> @Resource
> private ManagedExecutorService executorService;
>
> @Resource(lookup = "java:jboss/ee/concurrency/executor/default")
> private ManagedExecutorService executorService;
>
> But this works:
>
> private ManagedExecutorService executorService =
> InitialContext.doLookup("java:jboss/ee/concurrency/executor/default");
>
> I didn't change any configurations on WF so far. Ideas?
>
> Cheers
> --
> Ingo Weiss
>
> _______________________________________________
> wildfly-dev mailing list
> wildfly-dev at lists.jboss.org <mailto:wildfly-dev at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>
Hi Stuart,
On a simple JAX-RS class. Something along these lines:
@Path("resource")
public class Resource {
@Resource
private ManagedExecutorService executorService;
... blah blah...
public String fetchMessage() {
CompletableFuture.supplyAsync(this::message, executorService).
thenApply(this::process).
exceptionally(this::handle).
thenAccept(this::consume);
return "* fetchMessage() *";
}
String message() {
return "Super message @ " + System.currentTimeMillis();
}
... blah blah ...
}
--
Ingo Weiss
--
Ingo Weiss
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/wildfly-dev/attachments/20160322/fc055078/attachment-0001.bin
More information about the wildfly-dev
mailing list