The default Weld SE configuration will never work with a security Manager manager because the JRE classes create threads were where the setContextClassLoader() method [always throws an exception|http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/util/concurrent/ForkJoinWorkerThread.java#l244]
A workaround is to use:
{{weld.property(EXECUTOR_THREAD_POOL_TYPE.get(), ThreadPoolType.FIXED_TIMEOUT.toString());}}
when initializing the CDI runtime. It would be helpful if the [default Weld SE configuration|https://github.com/weld/core/blob/3.0.5.Final/environments/se/core/src/main/java/org/jboss/weld/environment/se/Weld.java#L778] could detect the security manager is active and choose another thread pool type.
Note: It looks like the JRE Common ForkJoinPool is restricted on a security manager enabled environment probably to avoid data leaks between different security contexts. It use what looks like internal APIs to clear all ThreadLocals, something I think it is not possible with a public API. |
|