0

I have a project I use maven and intellij. I write my test function using TestFX, Mocito and PowerMock but when I run test one by one all tests are passed. But when I start to run all test it gives this exception. I searched and I add System.loadLibrary("glass") it didn't work. I try some of solutions but I couldn't solve. Anybody know the what is the problem?

java.lang.RuntimeException: java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: Native Library C:\Program Files (x86)\Java\jdk1.8.0_121\jre\bin\glass.dll already loaded in another classloader
    at org.testfx.util.WaitForAsyncUtils.waitFor(WaitForAsyncUtils.java:284)
    at org.testfx.api.FxToolkit.waitForLaunch(FxToolkit.java:323)
    at org.testfx.api.FxToolkit.registerPrimaryStage(FxToolkit.java:132)
    at org.testfx.framework.junit.ApplicationTest.internalBefore(ApplicationTest.java:55)
    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:498)
    at org.junit.internal.runners.MethodRoadie.runBefores(MethodRoadie.java:133)
    at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:96)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:310)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:131)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.access$100(PowerMockJUnit47RunnerDelegateImpl.java:59)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner$TestExecutorStatement.evaluate(PowerMockJUnit47RunnerDelegateImpl.java:147)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.evaluateStatement(PowerMockJUnit47RunnerDelegateImpl.java:107)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:298)
    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:87)
    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:50)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:218)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:160)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:134)
    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
    at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:136)
    at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:121)
    at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:57)
    at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)
    at org.junit.runners.Suite.runChild(Suite.java:128)
    at org.junit.runners.Suite.runChild(Suite.java:27)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    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:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Although I made the linkte and tried other solutions, I could not resolve the glass.dll not found error. I'm looking for a solution to this issue that is long-lasting.

https://maven.apache.org/surefire/maven-surefire-plugin/examples/class-loading.html

1 Answers1

0

I had same kind of problem in my project. I was using Java(In eclipse) and Jboss server 1.7. I also got this kind of error for jpeg.dll. This error caused because, by-mistakenly I put library (.jar file) in my jboss/deployment/../lib folder, which is already provided by Java. Means, it is loading 1st time by java and 2nd time by my program. So this error.

Solution for this is(this works for me, you check at your end) - There is one folder inside Jboss named "modules", in that check for your package and go to "jdk/main" folder. Search for module.xml. And add dependency. I added in my code as follows.

path name="com/sun/image/codec/jpeg"

And then just restart server and try again.

Just look/search where your dll is. In my case it is present in com.sun.image.codec package.

Thats all from my side. Feel free to ask if you need further help.

  • I add path name ="com/sun/glass/ui" to module.xml and restart the jboss but I get the same error. Is path wrong or there something I forgot to add? – user8945079 Jan 16 '18 at 08:33
  • I think, you interpreted me wrong. I told you to find where glass.dll is instantiated, you have to add that path. In my case jpeg.dll was instantiated through "sun.awt.image.codec.JPEGImageDecoderImpl". So, I gave the path as I specified earlier. Little research you also have to do – Abhijit Khatri Jan 16 '18 at 09:50
  • I found the reason @RunWith(PowerMockRunner.class). when I remove it dll exception is removed but this time no last call on a mock available exception thrown. But I don't found the solution yet – user8945079 Jan 16 '18 at 11:53
  • I edit question and added end of exception. I add com.sun.glass.utils / com.sun.glass.ui / com.sun.glass.ui.win and restart jboss but it is not work. – user8945079 Jan 17 '18 at 11:12