-
-
Notifications
You must be signed in to change notification settings - Fork 776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot install agent in AWS environment #612
Comments
As I said, I use the exact same setup locally and in Jenkins and they use Open JDK 11.0.1. I also tried setting |
I assume that it might not be possible to start a process on AWS? It is unfortunately required to attach the agent on JVMs post 8: https://github.com/raphw/byte-buddy/blob/master/byte-buddy-agent/src/main/java/net/bytebuddy/agent/ByteBuddyAgent.java#L476 You can set |
My root problem is that I can't run my tests that are written using mockk library. So whenever a mock is created they call this |
@raphw thanks, I will try this right now! |
@raphw now prints another error:
What do you mean by creating a process? |
Byte Buddy needs to start a helper process as the JVM forbids to attach to your own JVM unless this property is set. However, it seems like it is generally not possible to attach in your enviornment, maybe the JDK being used does not include the attachment API? If its a linux machone, you can include this as a test dependency where Byte Buddy attempts emulation: https://github.com/raphw/byte-buddy/blob/master/byte-buddy-agent/pom.xml#L32 |
@raphw it is Amazon Linux 2. I tried including this dependency but it didn't change anything. |
I assume that it is caused by some environmental restriction enforced by Amazon to using the attach API. You could also try to find out if java.home is set to a strange property on AWS as it is required to resolve a location. |
Also figured that using |
That is interesting. Could you set some breakpoints throughout ByteBuddyAgent and check which attachment provider is used? |
@raphw |
@raphw JAVA_HOME is surely valid since I have the jdk installed inside docker |
@raphw I have removed byte buddy from the project and placed processId is the current PID? I figured there is a one-liner since java 9 |
Did you include the jdk.attach module in the build? |
@raphw perhaps not, how do I do it? |
It's only part of a JDK. The module is named jdk.attach. The parameter name is add-module, it is documented as a JVM option. |
Hey I found a work through for this, for some reason mvn clean install -Djdk.attach.allowAttachSelf=true fails locally and on docker. Putting this argument in pom.xml of the module using byte buddy solves this issue for both local and docker |
Then it seems like you cannot start up a new process in this environment which is how Byte Buddy normally works around this issue. Glad you got it figured out! |
Yes! Putting it in surefire makes the difference because it is responsible for starting the process.
Unfortunately, I just get another error:
|
That is a very particular error issued by HotSpot. The attach API communicates by socket files. Might it be that those files cannot be written to the file system or are deleted by a routine job? |
I have resolved the problem by also adding |
Currently ByteBuddy/Mockito-inline seems to fail on Windows within a docker container when trying to attach to the VM. Let's try the suggestion from raphw/byte-buddy#612 (comment) and https://github.com/raphw/byte-buddy/blob/b69acb3212ab914ca2bb84d0c9f9951ee0678e26/byte-buddy-agent/src/main/java/net/bytebuddy/agent/ByteBuddyAgent.java#L644-L645
Comming from mockk/mockk#254
I have a Maven project called
tmp
with only two files:tmp/pom.xml
tmp/src/test/java/MyTest.java
I run this with
mvn clean test
.We have a Jenkins master running on AWS. It calls a slave node via SSH (also on AWS) to run the build.
Locally and in Jenkins I use the exact same Docker image but it fails only in Jenkins (not sure if it will fail also without Docker I could check that later).
On Jenkins it throws
java.lang.IllegalStateException: Could not self-attach to current VM using external process
Here is full debug log of this command: build.log
Here is the generated streamdump (had to append the extention
.log
for GitHub): 2019-02-14T12-25-31_589-jvmRun1.dumpstream.logThe text was updated successfully, but these errors were encountered: