Skip to content

Conversation

@roberttoyonaga
Copy link
Contributor

This is a fix for: #46506

This change makes the substitution that prevents use of JMX#createProxy conditional. The substitution should only be enabled if the jmxserver feature is not included in the image build.

@roberttoyonaga
Copy link
Contributor Author

roberttoyonaga commented Mar 3, 2025

Currently, the BooleanSupplier JmxServerNotIncluded always seems to evaluate to false regardless of whether --enable-monitoring=jmxserver is used. From what I can tell JmxServerNotIncluded#getAsBoolean is evaluated after RemoteJmxHelper#setJmxServerNotIncluded is called from NativeImageBuildStep.NativeImageInvokerInfo.Builder#build(). However, it doesn't seem like the new value actually takes effect. I do not understand why. Maybe the Target_javax_management_JMX substitution is somehow being evaluated earlier than I think? @zakkak if you have time, can you please have a quick look to see if I've overlooked something?

@zakkak
Copy link
Contributor

zakkak commented Mar 5, 2025

The reason this doesn't work is because you are setting the value at deployment time and then try to read it at native-image build time.

When compiling a Quarkus native application the following two phases/steps take place:

  1. Deployment: at this step Quarkus generates application-specific bytecode to handle/optimize things and packages all necessary bits in a jar.
  2. Native-image compilation: this happens right after the deployment phase is completed. The jar generated in step 1 is passed to GraalVM/Mandrel as the application to be compiled to native code.

Any code in *.deployment.* packages is only available during the deployment phase. The addition you made in NativeImageBuildStep.java will only run during the deployment phase so the value being set in RemoteJmxHelper.java will only be available during the deployment phase, but GraalVM/Mandrel performs the substitutions at native-image compilation time, at which point it will be running in a different JVM process and thus accessing a different RemoteJmxHelper instance.

The best way IMHO would be to see if jmx-server is included in com.oracle.svm.core.VMInspectionOptions#EnableMonitoringFeatures, but unfortunately it's not available in the public API.

The simplest way I can think of is to use a property, e.g. quarkus.native.jmxserver.included which NativeImageBuildStep.java will set accordingly and RemoteJmxHelper will read.

@roberttoyonaga
Copy link
Contributor Author

Thank you @zakkak for the detailed explanation! I hadn't realized there were two separate processes. I'll give your suggestion a try.

@roberttoyonaga roberttoyonaga marked this pull request as ready for review March 6, 2025 18:21
Copy link
Contributor

@zakkak zakkak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please squash the two commits and have a look at my suggestion.

Thanks for the contribution!

@quarkus-bot

This comment has been minimized.

@roberttoyonaga
Copy link
Contributor Author

Thanks @zakkak! I've adopted your suggestion and also squashed the commits.

Copy link
Contributor

@zakkak zakkak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @roberttoyonaga !

@zakkak zakkak added triage/waiting-for-ci Ready to merge when CI successfully finishes area/native-image labels Mar 6, 2025
@quarkus-bot
Copy link

quarkus-bot bot commented Mar 6, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 11b06d9.

Failing Jobs

Status Name Step Failures Logs Raw logs Build scan
MicroProfile TCKs Tests Verify Failures Logs Raw logs 🔍

You can consult the Develocity build scans.

Failures

⚙️ MicroProfile TCKs Tests #

- Failing: tcks/microprofile-opentelemetry 

📦 tcks/microprofile-opentelemetry

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.5.2:test (tracing) on project quarkus-tck-microprofile-opentelemetry: There are test failures.

See /home/runner/_work/quarkus/quarkus/tcks/microprofile-opentelemetry/target/surefire-reports-tracing for the individual test results.
See dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.


Flaky tests - Develocity

⚙️ JVM Tests - JDK 17

📦 extensions/scheduler/deployment

io.quarkus.scheduler.test.PausedSchedulerTest.testSchedulerPauseResume - History

  • expected: <false> but was: <true> - org.opentest4j.AssertionFailedError
org.opentest4j.AssertionFailedError: expected: <false> but was: <true>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertFalse.failNotFalse(AssertFalse.java:63)
	at org.junit.jupiter.api.AssertFalse.assertFalse(AssertFalse.java:36)
	at org.junit.jupiter.api.AssertFalse.assertFalse(AssertFalse.java:31)
	at org.junit.jupiter.api.Assertions.assertFalse(Assertions.java:231)
	at io.quarkus.scheduler.test.PausedSchedulerTest.testSchedulerPauseResume(PausedSchedulerTest.java:47)

⚙️ JVM Tests - JDK 17 Windows

📦 extensions/hibernate-orm/deployment

io.quarkus.hibernate.orm.applicationfieldaccess.PublicFieldAccessInheritanceTest.testFieldAccess - History

  • Expecting actual not to be null - java.lang.AssertionError
java.lang.AssertionError: 

Expecting actual not to be null
	at io.quarkus.hibernate.orm.applicationfieldaccess.PublicFieldAccessInheritanceTest$FieldAccessEnhancedDelegate$1.assertValue(PublicFieldAccessInheritanceTest.java:141)
	at io.quarkus.hibernate.orm.applicationfieldaccess.PublicFieldAccessInheritanceTest.doTestFieldAccess(PublicFieldAccessInheritanceTest.java:100)
	at io.quarkus.hibernate.orm.applicationfieldaccess.PublicFieldAccessInheritanceTest.testFieldAccess(PublicFieldAccessInheritanceTest.java:61)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at io.quarkus.test.QuarkusUnitTest.runExtensionMethod(QuarkusUnitTest.java:521)

📦 extensions/micrometer-opentelemetry/deployment

io.quarkus.micrometer.opentelemetry.deployment.compatibility.MicrometerTimedInterceptorTest.testTimeMethod - History

  • Stream has no elements - java.lang.IllegalArgumentException
java.lang.IllegalArgumentException: Stream has no elements
	at io.quarkus.micrometer.opentelemetry.deployment.common.MetricDataFilter.lambda$lastReading$2(MetricDataFilter.java:213)
	at java.base/java.util.Optional.orElseThrow(Optional.java:403)
	at io.quarkus.micrometer.opentelemetry.deployment.common.MetricDataFilter.lastReading(MetricDataFilter.java:213)
	at io.quarkus.micrometer.opentelemetry.deployment.common.MetricDataFilter.lastReadingDataPoint(MetricDataFilter.java:231)
	at io.quarkus.micrometer.opentelemetry.deployment.compatibility.MicrometerTimedInterceptorTest.testTimeMethod(MicrometerTimedInterceptorTest.java:77)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at io.quarkus.test.QuarkusUnitTest.runExtensionMethod(QuarkusUnitTest.java:521)

@zakkak zakkak merged commit 7c3c452 into quarkusio:main Mar 7, 2025
57 of 58 checks passed
@quarkus-bot quarkus-bot bot removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Mar 7, 2025
@quarkus-bot quarkus-bot bot added this to the 3.21 - main milestone Mar 7, 2025
@jamesnetherton
Copy link
Contributor

@gsmet @zakkak Is it possible to have this change backported for inclusion in the 3.20 LTS release?

@zakkak
Copy link
Contributor

zakkak commented Mar 7, 2025

@gsmet @zakkak Is it possible to have this change backported for inclusion in the 3.20 LTS release?

Yes it seems reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

javax.management.JMX.createProxy is not implemented in native mode

3 participants