Hi Bernd, thx for the tip. I just found tonight a 1 o'clock clock (hours later) 
a solution. First in used in console not Java 11 (I used 17) as in maven 
release, so this occurs the error. Switching to Java 11 (with "brew install 
openjdk@11“ and "export JAVA_HOME=$(/usr/libexec/java_home -v 11)") solved the 
problem. But also I can reproduce the error (even with Java 11) in Terminal of 
IntelliJ, which i used the whole time while coding in the last days new 
bundles. The switch to a „normal“ terminal solves the problem. So whatever is 
the difference between the terminal in IntelliJ and standard system terminal. 
Executing man clean test with pax logging in IntelliJ Teminal throws the error 
reproducible.

Regards,
Matthias


> Am 06.01.2025 um 04:24 schrieb Bernd <e...@zusammenkunft.net>:
> 
> 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
>  
> 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

Reply via email to