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 use Attach API on unknown OS - jMockit via gradle on TeamCity issue #256

Closed
radekkozak opened this Issue Feb 11, 2016 · 2 comments

Comments

2 participants
@radekkozak

radekkozak commented Feb 11, 2016

Trying to build project with jMockit & TestNG via gradle. Locally everything is working great. Exactly the same thing going through TeamCity is somehow messed up. It seems that jMockit cannot execute properly setup method which has @BeforeClass annotation. To be fair it won't work with junit annotation either when setting things up before executing tests. Here's the part of listing that i'm mostly concerned about:

Caused by: java.lang.IllegalStateException: Cannot use Attach API on unknown OS: FreeBSD
at mockit.internal.startup.AgentLoader.findVirtualMachineClassAccordingToOS(AgentLoader.java:103)
at mockit.internal.startup.AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(AgentLoader.java:62)
at mockit.internal.startup.AgentLoader.loadAgent(AgentLoader.java:45)
at mockit.internal.startup.Startup.verifyInitialization(Startup.java:172)
at mockit.MockUp.(MockUp.java:94)

[All tests] pl.greyfox.junit.AddressRetrieverTest.setUp
[18:28:36][pl.greyfox.junit.AddressRetrieverTest.setUp] null
[18:28:36]
[pl.greyfox.junit.AddressRetrieverTest.setUp] java.lang.ExceptionInInitializerError
    at pl.greyfox.junit.AddressRetrieverTest.setUp(AddressRetrieverTest.java:34)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:514)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
    at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:178)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
    at org.testng.TestRunner.privateRun(TestRunner.java:782)
    at org.testng.TestRunner.run(TestRunner.java:632)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
    at org.testng.SuiteRunner.access$000(SuiteRunner.java:39)
    at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:400)
    at org.testng.internal.thread.ThreadUtil$2.call(ThreadUtil.java:64)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Cannot use Attach API on unknown OS: FreeBSD
    at mockit.internal.startup.AgentLoader.findVirtualMachineClassAccordingToOS(AgentLoader.java:103)
    at mockit.internal.startup.AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(AgentLoader.java:62)
    at mockit.internal.startup.AgentLoader.loadAgent(AgentLoader.java:45)
    at mockit.internal.startup.Startup.verifyInitialization(Startup.java:172)
    at mockit.MockUp.<clinit>(MockUp.java:94)
@rliesenfeld

This comment has been minimized.

Show comment
Hide comment
@rliesenfeld

rliesenfeld Feb 11, 2016

Member

Does it work if sun.tools.attach.BsdVirtualMachine is used when "os.name" = "FreeBSD"? I can easily make this change in AgentLoader.java (at line 96), but I won't be able to test it.

Member

rliesenfeld commented Feb 11, 2016

Does it work if sun.tools.attach.BsdVirtualMachine is used when "os.name" = "FreeBSD"? I can easily make this change in AgentLoader.java (at line 96), but I won't be able to test it.

@radekkozak

This comment has been minimized.

Show comment
Hide comment
@radekkozak

radekkozak Feb 11, 2016

Yup, i hotswapped and patched AgentLoader and i can confirm adding simple || osName.startsWith("FreeBSD") at line 96 along Mac OS X option does the trick. It would be great if you could ammend this yourself in your codebase - no need for MR for such trivial change i think. I'll use my monkey patch for the time being. Let me know when it's done.

Appreciate it

radekkozak commented Feb 11, 2016

Yup, i hotswapped and patched AgentLoader and i can confirm adding simple || osName.startsWith("FreeBSD") at line 96 along Mac OS X option does the trick. It would be great if you could ammend this yourself in your codebase - no need for MR for such trivial change i think. I'll use my monkey patch for the time being. Let me know when it's done.

Appreciate it

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