Ah just to add to this, the JEP mentions it explicitely, it throws since JDK23:
- There is a risk that frameworks which rely on the javax.security.auth API still use the deprecated methods in the Subject class, namely doAs and getSubject. We deprecated these methods in Java 17 and 18 because their signatures use deprecated classes of the Security Manager API. We introduced replacements for doAs and getSubject in Java 18. Since getSubject has thrown an UnsupportedOperationException since Java 23, we assume that frameworks have become aware of the deprecation and are working to adopt the replacements, e.g., HADOOP-19212.
Can you please also Check which Version of the Felix EventAdminImpl is used in your case, i cant find prepareEvent() in felix-eventadmin-1.6.4
Gruß
Bernd
--
http://bernd.eckenfels.net
Von: Bernd <e...@zusammenkunft.net>
Gesendet: Montag, Januar 6, 2025 4:25 AM
An: user@karaf.apache.org <user@karaf.apache.org>
Betreff: Re: Security Manager and infinite loop in test with exception Logger: java.lang.reflect.InvocationTargetException
Gesendet: Montag, Januar 6, 2025 4:25 AM
An: user@karaf.apache.org <user@karaf.apache.org>
Betreff: Re: Security Manager and infinite loop in test with exception Logger: java.lang.reflect.InvocationTargetException
Hm, maybe thats related to (incompatible?) OpenJDK changes in JEP 411/486. what JDK Version did you test with, can you try JDK17?
I dont recall that Subject.getSubject was to depend on the Security manager in the first place, but it looks like EventAdminImpl will need to ignore that exception in any case.
Gruß
Bernd
--
http://bernd.eckenfels.net
Von: Matthias Wegner <matthias.weg...@email.de>
Gesendet: Sonntag, Januar 5, 2025 10:55 PM
An: user@karaf.apache.org <user@karaf.apache.org>
Betreff: Security Manager and infinite loop in test with exception Logger: java.lang.reflect.InvocationTargetException
Gesendet: Sonntag, Januar 5, 2025 10:55 PM
An: user@karaf.apache.org <user@karaf.apache.org>
Betreff: Security Manager and infinite loop in test with exception Logger: java.lang.reflect.InvocationTargetException
Hi All,
CONTEXT
The integration test example not works, because an infinite loop "Logger: java.lang.reflect.InvocationTargetException" occurs. It not works in test example of karaf clone or an own written unit-test.
TRIALS
- I tried security.manager with policy
- I tried add-opens
- I tried <useSystemClassLoader>false</useSystemClassLoader>
- I tried different logger settings with log4j. When I change
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-log4j2</artifactId>
<version>${pax-logging.version}</version>
<scope>provided</scope>
</dependency>
to
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-service</artifactId>
<version>1.11.17</version>
</dependency>
it seems that the security issue is occurring „later“, but also raises. Also the infinity loop stays.
DESCRIPTION
I am not able to suppress the security manager on karaf integration test. Hoe to fix that? What is the reason for the Exception which not ends? I configured
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<!-- <useSystemClassLoader>false</useSystemClassLoader> -->
<systemPropertyVariables>
<property>
<!-- Set property to java.system.property, so it could be loaded to build karaf-test-instance -->
<name>karaf.version</name>
<value>${karaf.version}</value>
</property>
<property>
<!-- Set property to java.system.property, so it could be loaded to build karaf-test-instance -->
<name>project.version</name>
<value>${project.version}</value>
</property>
</systemPropertyVariables>
<argLine>
<!---Dtests.security.manager=false-->
<!-- -Djava.security.manager
-Djava.security.policy=${basedir}/src/test/resources/java.policy -->
--add-opens java.base/java.security=ALL-UNNAMED
--add-opens java.base/java.net=ALL-UNNAMED
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.naming/javax.naming.spi=ALL-UNNAMED
--add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
But nothing seems to work. The error which is thrown looks like:
Running org.rogatio.k3.test.ExampleTest
WARNING: package org.apache.karaf.specs.locator not in java.base
Logger: java.lang.reflect.InvocationTargetException
Exception in thread "CM Configuration Updater" java.lang.UnsupportedOperationException: getSubject is supported only if a security manager is allowed
at java.base/javax.security.auth.Subject.getSubject(Subject.java:347)
at org.apache.felix.eventadmin.impl.handler.EventAdminImpl.prepareEvent(EventAdminImpl.java:146)
at org.apache.felix.eventadmin.impl.handler.EventAdminImpl.postEvent(EventAdminImpl.java:180)
at org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator.postEvent(EventAdminSecurityDecorator.java:79)
at org.ops4j.pax.logging.spi.support.EventAdminTracker.deliver(EventAdminTracker.java:103)
at org.ops4j.pax.logging.spi.support.EventAdminTracker.postEvent(EventAdminTracker.java:65)
at org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.handleEvents(PaxLoggingServiceImpl.java:415)
at org.ops4j.pax.logging.log4j2.internal.PaxLoggerImpl.doLog0(PaxLoggerImpl.java:1134)
at org.ops4j.pax.logging.log4j2.internal.PaxLoggerImpl.doLog(PaxLoggerImpl.java:1099)
at org.ops4j.pax.logging.log4j2.internal.PaxLoggerImpl.error(PaxLoggerImpl.java:583)
at org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.logImpl(PaxLoggingServiceImpl.java:368)
at org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl.access$000(PaxLoggingServiceImpl.java:70)
at org.ops4j.pax.logging.log4j2.internal.PaxLoggingServiceImpl$1ManagedPaxLoggingService.log(PaxLoggingServiceImpl.java:675)
at org.apache.felix.cm.impl.Log.log(Log.java:186)
at org.apache.felix.cm.impl.UpdateThread.run(UpdateThread.java:88)
at java.base/java.lang.Thread.run(Thread.java:1575)
Logger: java.lang.reflect.InvocationTargetException
Logger: java.lang.reflect.InvocationTargetException
Logger: java.lang.reflect.InvocationTargetException
Logger: java.lang.reflect.InvocationTargetException
Logger: java.lang.reflect.InvocationTargetException
...
--
http://bernd.eckenfels.net
--
http://bernd.eckenfels.net