Giter Site home page Giter Site logo

Comments (5)

jeanbisutti avatar jeanbisutti commented on May 26, 2024

@lmcdasi The Linux user of the JVM may not have access to /proc/7/root/tmp. Could you please check?

It does not work without -Djdk.attach.allowAttachSelf=true?

from applicationinsights-java.

lmcdasi avatar lmcdasi commented on May 26, 2024

The jvm option: -Djdk.attach.allowAttachSelf=true seems to be mandatory. I'm using MSFT openjdk:17 docker image.

Without it, I'm getting:

connector | 14:39:06.600 [main] INFO connector.Application -- ApplicationInsights enabled with file /tmp/app-insights/applicationinsights-dev.json
connector | Jan 29, 2024 2:39:06 PM com.microsoft.applicationinsights.attach.ApplicationInsights attach
connector | WARNING: Fail to runtime attach Application Insights
connector | io.opentelemetry.contrib.attach.core.RuntimeAttachException: A problem has occurred during the runtime attachment of the Java agent.
connector | at io.opentelemetry.contrib.attach.core.CoreRuntimeAttach.handleByteBuddyException(CoreRuntimeAttach.java:106)
connector | at io.opentelemetry.contrib.attach.core.CoreRuntimeAttach.attachJavaagentToCurrentJVM(CoreRuntimeAttach.java:55)
connector | at com.microsoft.applicationinsights.attach.ApplicationInsights.attach(ApplicationInsights.java:63)
connector | at connector.Application.main(Application.java:38)
media-connector | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
connector | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
connector | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
connector | at java.base/java.lang.reflect.Method.invoke(Method.java:568)
connector | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
connector | at org.springframework.boot.loader.Launcher.launch(Launcher.java:95)
connector | at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
connector | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
connector | Caused by: java.lang.IllegalStateException: Could not self-attach to current VM using external process
connector | at net.bytebuddy.agent.ByteBuddyAgent.installExternal(ByteBuddyAgent.java:706)
connector | at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:636)
connector | at net.bytebuddy.agent.ByteBuddyAgent.attach(ByteBuddyAgent.java:303)
connector | at net.bytebuddy.agent.ByteBuddyAgent.attach(ByteBuddyAgent.java:268)
connector | at net.bytebuddy.agent.ByteBuddyAgent.attach(ByteBuddyAgent.java:250)
connector | at io.opentelemetry.contrib.attach.core.CoreRuntimeAttach.attachJavaagentToCurrentJVM(CoreRuntimeAttach.java:53)
connector | ... 10 more

from applicationinsights-java.

lmcdasi avatar lmcdasi commented on May 26, 2024

Regarding /tmp - it seems that if I have it as a volume mounted in docker compose it affects the way it sees that java pid file. I have changed the strategy and now with the allowAttachSelf set to true there is no exception any longer.

connector | OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
connector | 2024-01-29 14:46:57.610Z INFO c.m.applicationinsights.agent - Application Insights Java Agent 3.4.19 started successfully (PID 7, JVM running for 4.855 s)
connector | 2024-01-29 14:46:57.615Z INFO c.m.applicationinsights.agent - Java version: 17.0.10, vendor: Microsoft, home: /usr/lib/jvm/msopenjdk-17-amd64

from applicationinsights-java.

jeanbisutti avatar jeanbisutti commented on May 26, 2024

Regarding /tmp - it seems that if I have it as a volume mounted in docker compose it affects the way it sees that java pid file. I have changed the strategy and now with the allowAttachSelf set to true there is no exception any longer.

Thank you for sharing this. Would you mind if you could share the code of the not working Docker compose configuration?

Does it also work now without the allowAttachSelf property? If it does not work in this case, you can display the root cause error by setting the net.bytebuddy.agent.attacher.dump property to a file path.

from applicationinsights-java.

lmcdasi avatar lmcdasi commented on May 26, 2024

Here is what is causing the issue of the self attach to fail. If in the docker-compose, I have:

  JAVA_OPTIONS: "-DAPPLICATIONINSIGHTS_ENABLED=true -Dapplicationinsights.configuration.file=/mnt/app-insights/applicationinsights-dev.json -Dnet.bytebuddy.agent.attacher.dump=/tmp/bytebuddy.dump"
  JAVA_TOOL_OPTIONS: "-agentlib:jdwp=transport=dt_socket,address=*:5006,server=y,suspend=n"

Then I will get the self attach issue. But, if I move the java_tool_options within the java options as:

  JAVA_OPTIONS: "-agentlib:jdwp=transport=dt_socket,address=*:5006,server=y,suspend=n -XX:+StartAttachListener -XX:-DisableAttachMechanism -DAPPLICATIONINSIGHTS_ENABLED=true -Dapplicationinsights.configuration.file=/mnt/app-insights/applicationinsights-dev.json -Dnet.bytebuddy.agent.attacher.dump=/tmp/bytebuddy.dump"

Then I have no issue, and that because the agent is running the Agent.class as a new java process and inherits the debugger settings ... ByteBuddyAgent.class method installExternal - if (new ProcessBuilder(System.getProperty(JAVA_HOME) ....

Thank you.

from applicationinsights-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.