On 19/02/2025 15:28, Richard Zowalla wrote:
Can you push the reproducrr into a Git Repo, so we can have a look.
Done
https://github.com/egor-duda/tomee/tree/principal-injection-logging-error
With .level=INFO in logging.properties tests pass without any problems
With .level=FINE tests fail
Am 18. Februar 2025 20:45:00 MEZ schrieb Egor Duda <egor.d...@gmail.com>:
Hello!
I've encountered some strange problem with tests with
@RunWith(ApplicationComposer.class) failing to start with error
java.lang.IllegalStateException: On a thread without an initialized context nor
a classloader mapping a deployed app
I've made a simple reproducer -- take application-composer example project, add
following logging.properties file to command line running MoviesTest:
handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = ALL
.level = FINE
and add
@Inject
private java.security.Principal principal;
to MoviesImpl.java
Then, running MovieTest results in failure to start application with root error:
java.lang.IllegalStateException: On a thread without an initialized context nor
a classloader mapping a deployed app
at
org.apache.openejb.cdi.ThreadSingletonServiceImpl.get(ThreadSingletonServiceImpl.java:367)
at
org.apache.openejb.cdi.ThreadSingletonServiceImpl.getContext(ThreadSingletonServiceImpl.java:343)
at
org.apache.openejb.cdi.ThreadSingletonServiceImpl.get(ThreadSingletonServiceImpl.java:378)
at
org.apache.openejb.cdi.ThreadSingletonServiceImpl.get(ThreadSingletonServiceImpl.java:72)
at
org.apache.webbeans.config.WebBeansFinder.getSingletonInstance(WebBeansFinder.java:57)
at
org.apache.webbeans.config.WebBeansContext.getInstance(WebBeansContext.java:197)
at
org.apache.webbeans.config.WebBeansContext.currentInstance(WebBeansContext.java:215)
at
org.apache.openejb.assembler.classic.EntityManagerFactoryCallable$BmHandler.findBm(EntityManagerFactoryCallable.java:180)
at
org.apache.openejb.assembler.classic.EntityManagerFactoryCallable$BmHandler.invoke(EntityManagerFactoryCallable.java:168)
at jdk.proxy2/jdk.proxy2.$Proxy26.toString(Unknown Source)
at java.base/java.lang.String.valueOf(String.java:4220)
at java.base/java.lang.StringBuilder.append(StringBuilder.java:173)
at java.base/java.util.AbstractMap.toString(AbstractMap.java:555)
at java.base/java.text.MessageFormat.subformat(MessageFormat.java:1311)
at java.base/java.text.MessageFormat.format(MessageFormat.java:887)
at java.base/java.text.Format.format(Format.java:159)
at java.base/java.text.MessageFormat.format(MessageFormat.java:862)
at
org.apache.openjpa.lib.util.Localizer$Message.getMessage(Localizer.java:281)
at
org.apache.openjpa.lib.util.Localizer$Message.toString(Localizer.java:309)
at
org.apache.openejb.openjpa.JULOpenJPALog.record(JULOpenJPALog.java:130)
at org.apache.openejb.openjpa.JULOpenJPALog.trace(JULOpenJPALog.java:72)
at
org.apache.openjpa.persistence.PersistenceProductDerivation$ConfigurationProviderImpl.setInto(PersistenceProductDerivation.java:766)
at
org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newInstance(JDBCBrokerFactory.java:69)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:569)
at org.apache.openjpa.kernel.Bootstrap.invokeFactory(Bootstrap.java:131)
at
org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:66)
Both changing logging level from FINE to INFO, and removing injected Principal,
make this error disappear and test works fine.
Is it a bug, or some missing configuration from my part?