tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: cannot use ManagedExecutorService resource
Date Mon, 16 Jul 2018 12:10:47 GMT
Hi

yes, this is normal. TomEE defines defaults and you can override them. To
supports all cases the defaults are auto-adjusted to the "prod" (hardcoded)
resources - very handy in tests.
If you don't activate openejb.offline=true then this is the behavior you
have, if you set it then no implicit/default resource are available.

This means that if you define a resource matching the default auto-created
one it will be considered as the default. This works until you define the
name of the resource. In this case you must ensure there is no ambiguity
and the resource is defined with the right name.

For you it means you must redefine the default resource as soon as you
define another one of the same type.

Side note: for prod it is more than highly recommanded to do that since the
default executor service can be synchronous or highly parallel, there is
nothing required in the spec so better to take the control of it.

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le lun. 16 juil. 2018 à 12:31, clemensx <clemens.fehr@sap.com> a écrit :

> Hi,
>
> we have problems using ManagedExecutorService resources in tomee 7.0.4
> Using default ManagedExecutorService works fine, but if we try to define a
> new pool with more threads we cannot access the service
>
> In resource.xml we do this:
> <Resource id="FooManagedExecutorService" type="ManagedExecutorService">
>     Core = 40
>     Max = 50
>     KeepAlive = 5 s
>     Queue = 150
>     ThreadFactory =
> org.apache.openejb.threads.impl.ManagedThreadFactoryImpl
>     Lazy = true
> </Resource>
>
> But then we cannot even get the default service injected in our stateful
> session bean:
>                 @Resource(name="java:comp/DefaultManagedExecutorService")
>                 private ManagedExecutorService execService;
> will yield a null execService.
>
>                 @Resource(name="FooManagedExecutorService")
>                 private ManagedExecutorService execService;
> same with trying to access our own resource.
>
> Getting the reference programmatically via
>                 execService = (ManagedExecutorService)
> sessionContext.lookup(“openejb:Resource/FooManagedExecutorService”);
> also gives null.
>
>
> In the server startup logs we see several mentions of our service:
>
> for all beans:
> [CONTAINER] OpenEJB.startup.config INFO Auto-linking resource-ref
> 'openejb/Resource/ROOT/FooManagedExecutorService' in bean ProductDao to
> Resource(id=FooManagedExecutorService)
>
> 3 times this info (no idea why the container is creating the resource 3
> times):
> [CONTAINER] OpenEJB.startup.service INFO Creating
> Resource(id=ROOT/FooManagedExecutorService,
> aliases=FooManagedExecutorService)
>
> [CONTAINER] OpenEJB.startup.config INFO Configuring
> Service(id=ROOT/FooManagedExecutorService, type=Resource,
> provider-id=Default Executor Service)
>
>
> Thanks for any ideas/workarounds
> clemens
>
>
>
>
> --
> Sent from:
> http://tomee-openejb.979440.n4.nabble.com/TomEE-Users-f979441.html
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message