1
votes

I am attempting to build a new project with gradle, junit, and jmock. When I run my build, I get this stack trace:

com.heavyweightsoftware.daybook.ws.TypeCodeWsTest STANDARD_ERROR
    java.lang.IllegalStateException: Native library for Attach API not available
 in this JRE
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.ru
nTestClass(JUnitTestClassExecuter.java:80)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.ex
ecute(JUnitTestClassExecuter.java:49)
        at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.p
rocessTestClass(JUnitTestClassProcessor.java:64)
        at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.process
TestClass(SuiteTestClassProcessor.java:50)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionD
ispatch.java:35)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionD
ispatch.java:24)
        at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(Con
textClassLoaderDispatch.java:32)
        at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocat
ionHandler.invoke(ProxyDispatchAdapter.java:93)
        at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestCl
ass(TestWorker.java:106)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionD
ispatch.java:35)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionD
ispatch.java:24)
        at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(Messa
geHub.java:360)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.
onExecute(ExecutorPolicy.java:54)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableE
xecutorImpl.java:40)
    Caused by: java.lang.UnsatisfiedLinkError: no attach in java.library.path
        ... 14 more
Gradle Test Executor 1 finished executing tests.

com.heavyweightsoftware.daybook.ws.TypeCodeWsTest > testGetTypeCodes FAILED
    java.lang.ExceptionInInitializerError
        at com.heavyweightsoftware.daybook.ws.TypeCodeWsTest.testGetTypeCodes(Ty
peCodeWsTest.java:40)

        Caused by:
        java.lang.IllegalStateException: Native library for Attach API not avail
able in this JRE
            at mockit.internal.startup.AgentLoader.getVirtualMachineImplementati
onFromEmbeddedOnes(AgentLoader.java:78)
            at mockit.internal.startup.AgentLoader.loadAgent(AgentLoader.java:46
)
            at mockit.internal.startup.Startup.verifyInitialization(Startup.java
:172)
            at mockit.Invocations.<clinit>(Invocations.java:26)
            ... 1 more

            Caused by:
            java.lang.NoClassDefFoundError: Could not initialize class sun.tools
.attach.WindowsVirtualMachine
                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
 Method)
                at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
 Source)
                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unk
nown Source)
                at java.lang.reflect.Constructor.newInstance(Unknown Source)
                at mockit.internal.startup.AgentLoader.getVirtualMachineImplemen
tationFromEmbeddedOnes(AgentLoader.java:70)
                ... 4 more

So I looked and found these questions: JMockit ERROR - Native library for Attach API not available in this JRE and jmockit: Native library for Attach API not available in this JRE error

And I've made the changes in eclipse, but this error happens even when running outside of eclipse and so it's not the eclipse settings.

Here's the output of java -version from the command prompt:

C:\Users\thom\git\daybook\WebServices>java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

This is part of gradle build --info:

Executing task ':test' (up-to-date check took 0.193 secs) due to:
  Value of input property 'candidateClassFiles' has changed for task ':test'
Starting process 'Gradle Test Executor 1'. Working directory: C:\Users\thom\git\
daybook\WebServices Command: C:\java\bin\java.exe -Djava.security.manager=jarjar
.org.gradle.process.internal.child.BootstrapSecurityManager -Dfile.encoding=wind
ows-1252 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp C:\Users\th
om\.gradle\caches\2.4\workerMain\gradle-worker.jar jarjar.org.gradle.process.int
ernal.launcher.GradleWorkerMain 'Gradle Test Executor 1'
Successfully started process 'Gradle Test Executor 1'
Gradle Test Executor 1 started executing tests.

Which tells me it's running java from c:\java\bin which is the right install. I looked and this directer has javac in it, which I think confirms that it's a JDK and not a JRE.

Any input, oh wise above wise?

1

1 Answers

2
votes

I added c:\java\jre\bin to my path and the build started working again.