-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Running on MacOS, I get the following error reported on startup (always). It does not prevent cjmx from working - I assume similar messages show for other providers on other operating systems but haven't confirmed.
In Java 8 the error is reported just as the first line below without stack track. On Java 11 it includes a stack trace.
java.util.ServiceConfigurationError: com.sun.tools.attach.spi.AttachProvider: Provider sun.tools.attach.BsdAttachProvider not found
at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:588)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1211)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1220)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1264)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1299)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1384)
at jdk.attach/com.sun.tools.attach.spi.AttachProvider.providers(AttachProvider.java:258)
at jdk.attach/com.sun.tools.attach.VirtualMachine.list(VirtualMachine.java:144)
at cjmx.util.jmx.Attach$.localVMs(Attach.scala:13)
at cjmx.util.jmx.Attach$.localVMIDs(Attach.scala:16)
at cjmx.cli.REPL$.runR$1(REPL.scala:22)
at cjmx.cli.REPL$.run(REPL.scala:55)
at cjmx.App$.run(App.scala:34)
at cjmx.Main$.main(Main.scala:5)
at cjmx.Main.main(Main.scala)
I spent some time to track down what causes it. When listing the VMs the internal logic iterates the providers. Accessing the providers invokes the ServiceLoader, which looks in each JAR for a text file called META-INF/services/com.sun.tools.attach.spi.AttachProvider. Each line in that file is loaded as a class from within that jar.
The app jar cjmx_2.12-xxx-app.jar appears to include referenced classes from the tools.jar file. The problem is that this includes META-INF/services/com.sun.tools.attach.spi.AttachProvider, but does not include the class that is referenced inside that file (sun.tools.attach.BsdAttachProvider if you're on MacOs).
Removing META-INF/services from the jar file prevents the error (and doesn't appear to have any deleterious effect, but I've only tested on Java 11).
It looks to me like this is probably something that would need to be fixed in the proguard configuration in the build script, but both scala and sbt are foreign to me.