reactor / BlockHound

Java agent to detect blocking calls from non-blocking threads.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cloud Foundry Java Buildpack installation throws IllegalStateException: No compatible attachment provider is available.

emreavsar opened this issue · comments

Added the dependency in pom.xml, added the BlockHound.install() in my main

Running locally works everything.

Pushed the application to cloud foundry (java buildpack)

Getting the error:

2020-10-14T13:35:48.471+02:00 [APP/PROC/WEB/0] [ERR] Exception in thread "main" java.lang.reflect.InvocationTargetException
2020-10-14T13:35:48.473+02:00 [APP/PROC/WEB/0] [ERR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2020-10-14T13:35:48.473+02:00 [APP/PROC/WEB/0] [ERR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2020-10-14T13:35:48.473+02:00 [APP/PROC/WEB/0] [ERR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2020-10-14T13:35:48.474+02:00 [APP/PROC/WEB/0] [ERR] at java.base/java.lang.reflect.Method.invoke(Unknown Source)
2020-10-14T13:35:48.474+02:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
2020-10-14T13:35:48.474+02:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
2020-10-14T13:35:48.474+02:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
2020-10-14T13:35:48.475+02:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
2020-10-14T13:35:48.476+02:00 [APP/PROC/WEB/0] [ERR] Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: No compatible attachment provider is available
2020-10-14T13:35:48.476+02:00 [APP/PROC/WEB/0] [ERR] at reactor.blockhound.BlockHound$Builder.install(BlockHound.java:398)
2020-10-14T13:35:48.476+02:00 [APP/PROC/WEB/0] [ERR] at reactor.blockhound.BlockHound.install(BlockHound.java:94)
2020-10-14T13:35:48.477+02:00 [APP/PROC/WEB/0] [ERR] at com.avsar.edu.demo.DemoApplication.main(DemoApplication.java:11)
2020-10-14T13:35:48.477+02:00 [APP/PROC/WEB/0] [ERR] ... 8 more
2020-10-14T13:35:48.477+02:00 [APP/PROC/WEB/0] [ERR] Caused by: java.lang.IllegalStateException: No compatible attachment provider is available
2020-10-14T13:35:48.477+02:00 [APP/PROC/WEB/0] [ERR] at reactor.blockhound.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:602)
2020-10-14T13:35:48.477+02:00 [APP/PROC/WEB/0] [ERR] at reactor.blockhound.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:586)
2020-10-14T13:35:48.477+02:00 [APP/PROC/WEB/0] [ERR] at reactor.blockhound.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:538)
2020-10-14T13:35:48.477+02:00 [APP/PROC/WEB/0] [ERR] at reactor.blockhound.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:515)
2020-10-14T13:35:48.477+02:00 [APP/PROC/WEB/0] [ERR] at reactor.blockhound.BlockHound$Builder.install(BlockHound.java:370)

Manifest looks like this:

---
applications:
  - name: blockhound-demo-app
    path: target/demo-0.0.1-SNAPSHOT.jar
    env:
      JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 11.+ }}'

Read in the internet about --javaagent options etc. Is this expected behaviour is my build pack not matching BlockHound?

Thanks
Emre

Try adding following dependency.

   <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>5.5.0</version>
    </dependency>

Yes, since Liberica's JVM comes with the attachment module removed, you need to add the JNA dependency for ByteBuddy's self attachment implementation.

I have the same issue. I am using io.projectreactor dependency on my project. It runs fine on my local machine but when I push to CF it fails. I tried adding the dependency 'JNA' as provided in the suggestions but it is not helping me.

[ERR] Exception in thread "main" java.lang.reflect.InvocationTargetException
2023-02-27T10:40:58.567-05:00 [APP/PROC/WEB/0] [ERR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-02-27T10:40:58.567-05:00 [APP/PROC/WEB/0] [ERR] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2023-02-27T10:40:58.567-05:00 [APP/PROC/WEB/0] [ERR] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2023-02-27T10:40:58.567-05:00 [APP/PROC/WEB/0] [ERR] at java.base/java.lang.reflect.Method.invoke(Unknown Source)
2023-02-27T10:40:58.567-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
2023-02-27T10:40:58.567-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.loader.Launcher.launch(Launcher.java:108)
2023-02-27T10:40:58.567-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
2023-02-27T10:40:58.567-05:00 [APP/PROC/WEB/0] [ERR] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
2023-02-27T10:40:58.567-05:00 [APP/PROC/WEB/0] [ERR] Caused by: java.lang.IllegalStateException: No compatible attachment provider is available
2023-02-27T10:40:58.567-05:00 [APP/PROC/WEB/0] [ERR] at reactor.tools.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:627)
2023-02-27T10:40:58.568-05:00 [APP/PROC/WEB/0] [ERR] at reactor.tools.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:611)
2023-02-27T10:40:58.568-05:00 [APP/PROC/WEB/0] [ERR] at reactor.tools.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:563)
2023-02-27T10:40:58.568-05:00 [APP/PROC/WEB/0] [ERR] at reactor.tools.shaded.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:540)
2023-02-27T10:40:58.568-05:00 [APP/PROC/WEB/0] [ERR] at reactor.tools.agent.ReactorDebugAgent.init(ReactorDebugAgent.java:56)
2023-02-27T10:40:58.568-05:00 [APP/PROC/WEB/0] [ERR] at com.cah.flu.order.FluOrderApplication.main(FluOrderApplication.java:49)

I'm going to look into this soon, thanks for reporting.

maybe it's the same issue than here:

https://stackoverflow.com/questions/49767683/what-does-no-compatible-attachment-provider-is-available-mean

so, are you using a JRE ? if so, I would suggest to either do one of the following:

  • since BlockHound 1.0.7 version, it is now possible to install blockhound using -javaagent option. So can you try to comment your code where you invoke BlockHound.install, recompile, and then start your jvm using -javaagent:<path to blockhound 1.0.7 jar> -jar ...

  • if you really need to install blockhound programatically, and if you are using a JRE >= 9 version, then can you check if your JRE is configured with the jdk.attach module, and if not then manage to add it

  • ideally, if possible try to use a jdk, not a jre.

hope this helps.