jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap'

Asked by Sudhansu Gewali on 2020-03-03

Following error is displayed while running Sikuli script with Java 11. HAve even tried with latest Sikuli jar.Issue is still there.

Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')

Any solution on this ?

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2020-03-03
Last reply:
2020-03-21
RaiMan (raimund-hocke) said : #1

What system?

How do you run sikulix.jar?

Sudhansu Gewali (sgewali) said : #2

System: CentOs 7

We run Sikuli jar importing in eclipse integrated with Selenium.

Earlier befor Java 11 update it worked smoothly.

RaiMan (raimund-hocke) said : #3

any stacktrace?

Sudhansu Gewali (sgewali) said : #4

java.lang.ExceptionInInitializerError
 at com.ptc.windchill.mpml.sikuli.SikuliInstanceSolvent.SikuliCompareImageInScreen(SikuliInstanceSolvent.java:90)
 at com.ptc.windchill.pdmLink.mpml.mapsb.visualization.upstream.upstreamDisplayOptions.occMode.OccSatusOff.Hidden.Hidden.hidden(Hidden.java:168)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
 at com.ptc.radar.util.TimeMonitorRule$StatementThread.run(TimeMonitorRule.java:128)
Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
 at org.sikuli.script.RunTime.storeClassPath(RunTime.java:2584)
 at org.sikuli.script.RunTime.isOnClasspath(RunTime.java:2634)
 at org.sikuli.script.RunTime.isJarOnClasspath(RunTime.java:2658)
 at org.sikuli.script.RunTime.libsExport(RunTime.java:951)
 at org.sikuli.script.RunTime.init(RunTime.java:738)
 at org.sikuli.script.RunTime.get(RunTime.java:312)
 at org.sikuli.script.RunTime.get(RunTime.java:122)
 at org.sikuli.script.RunTime.get(RunTime.java:337)
 at org.sikuli.script.Region.<clinit>(Region.java:23)

RaiMan (raimund-hocke) said : #5

ok, the stacktrace is not produced with the latest version.

Versions prior to 2.0.x do not work on Java 9+ and are no longer supported.

The reason behind: the hack, that could be used to access the classpath at runtime is no longer posssible with Java 9+.

So please again try with a sikulixapi.jar version 2.0.3 either as Maven dependency or with the fat jar from the downloadpage.

Sudhansu Gewali (sgewali) said : #6

Hi
I used 2.0.3 version now. Still issue is there. Same error i am getting.

Any Solution ?

RaiMan (raimund-hocke) said : #7

I need the 2.0.3 stacktrace

Sudhansu Gewali (sgewali) said : #8

java.lang.ExceptionInInitializerError
 at com.ptc.windchill.mpml.sikuli.SikuliInstanceSolvent.SikuliImageClick(SikuliInstanceSolvent.java:31)
 at com.ptc.windchill.pdmLink.mpml.mapsb.visualization.upstream.autoSelection.VizAutoSelection.VizAutoSelection.vizAutoSelection(VizAutoSelection.java:126)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
 at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
 at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
 at org.junit.rules.RunRules.evaluate(RunRules.java:20)
 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
 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 com.ptc.selenium.SeleniumRunner.run(SeleniumRunner.java:90)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')
 at org.sikuli.script.RunTime.storeClassPath(RunTime.java:2584)
 at org.sikuli.script.RunTime.isOnClasspath(RunTime.java:2634)
 at org.sikuli.script.RunTime.isJarOnClasspath(RunTime.java:2658)
 at org.sikuli.script.RunTime.libsExport(RunTime.java:951)
 at org.sikuli.script.RunTime.init(RunTime.java:738)
 at org.sikuli.script.RunTime.get(RunTime.java:312)
 at org.sikuli.script.RunTime.get(RunTime.java:122)
 at org.sikuli.script.RunTime.get(RunTime.java:337)
 at org.sikuli.script.Region.<clinit>(Region.java:23)

RaiMan (raimund-hocke) said : #9

again not the trace from a version 2.0.x

org.sikuli.script.RunTime

is now in :

org.sikuli.script.support

so check your environment

Sudhansu Gewali (sgewali) said : #10

/**
     ** Method to click Captured image through Sikuli
     * @throws FindFailed
     **/

    public void SikuliImageClick(URL capturedImage) throws FindFailed {
        Screen S1 = new Screen();
        Pattern img1 = new Pattern(capturedImage);
        S1.wait(img1, 180);
        SeleniumSession.get().pause(20000);
        S1.click(img1);
    }

In above code i have used FindFailed in throws exception which is is org.sikuli.script.FindFailed;
I tried to replace FindFailed with FindFailedDialog which is in org.sikuli.script.support.FindFailedDialog;
But it gives me error:- "No exception of type FindFailedDialog can be thrown; an exception type must be a subclass of Throwable"

Please let me know how to fix this so that it will pick runtime from org.sikuli.script.support.

Sudhansu Gewali (sgewali) said : #11

java.lang.ExceptionInInitializerError
 at org.sikuli.script.Pattern.<init>(Pattern.java:127)
 at com.ptc.windchill.mpml.sikuli.SikuliInstanceSolvent.SikuliCompareImageInScreen(SikuliInstanceSolvent.java:91)
 at com.ptc.windchill.pdmLink.mpml.mapsb.visualization.upstream.autoSelection.VizStructureToViz.VizStructureToViz.vizStructureToViz(VizStructureToViz.java:144)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
 at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
 at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
 at org.junit.rules.RunRules.evaluate(RunRules.java:20)
 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
 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 com.ptc.selenium.SeleniumRunner.run(SeleniumRunner.java:90)
 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: org.sikuli.script.SikuliXception: fatal: problem with native library: opencv_java
 at org.sikuli.script.support.RunTime.terminate(RunTime.java:1317)
 at org.sikuli.script.support.RunTime.libsLoad(RunTime.java:1532)
 at org.sikuli.script.support.RunTime.loadLibrary(RunTime.java:1689)
 at org.sikuli.script.Finder$Finder2.<clinit>(Finder.java:536)
 ... 30 more

I get this error now when using Sikuli latest version.

RaiMan (raimund-hocke) said : #12

Can you help with this problem?

Provide an answer of your own, or ask Sudhansu Gewali for more information if necessary.

To post a message you must log in.