Skip to content

Exception in thread "main" 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') #152

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

Closed
wongdh opened this issue Jun 2, 2019 · 12 comments

Comments

@wongdh
Copy link

wongdh commented Jun 2, 2019

Hi all,

Tried the run the example but unsuccessful. PHP reported
"Your report has an error and couldn 't be processed!\ Try to output the command using the function output(); and run it manually in the console."
i output the command
jasperstarter process "C:\wwwroot\phpjasper\vendor\geekcom\phpjasper\examples\hello_world.jasper" -o "C:\wwwroot\phpjasper\vendor\geekcom\phpjasper\examples" -f pdf rtf
and ran in console and got
Exception in thread "main" 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 de.cenote.tools.classpath.ApplicationClasspath.add(ApplicationClasspath.java:75)
at de.cenote.tools.classpath.ApplicationClasspath.add(ApplicationClasspath.java:65)
at de.cenote.tools.classpath.ApplicationClasspath.addJars(ApplicationClasspath.java:134)
at de.cenote.tools.classpath.ApplicationClasspath.addJarsRelative(ApplicationClasspath.java:151)
at de.cenote.jasperstarter.App.processReport(App.java:178)
at de.cenote.jasperstarter.App.main(App.java:109)

my java version as following
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

Please advice. Thank you

@geekcom
Copy link
Member

geekcom commented Jul 15, 2019

Please check the configurations of your server and try it on.

@geekcom geekcom closed this as completed Jul 15, 2019
@deyvisonrocha
Copy link

@wongdh Any solution?

@aazbeltran
Copy link

I also have that problem, has anyone already found a solution?

@eduardoit2000
Copy link

i found this, and worked for me.

String pathSeparator = Syste .getProperty("path.separator");
String[] classPathEntries = System.getProperty("java.class.path") .split(pathSeparator);

from the web site https://blog.codefx.org/java/java-11-migration-guide/#Casting-To-URL-Class-Loader

@harvy76
Copy link

harvy76 commented Oct 9, 2019

Hello,
I have the same problem with jasperstarter, last version, with OPENJDK.
Unfortunately Oracle have new business policy so We need to change the JAVA JDK to OpenJDK . I tried version 8.22, version 9, version 11 and still I take this message, when I tried it to run on commandline:

OException in thread "main" 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 de.cenote.tools.classpath.ApplicationClasspath.add(ApplicationClasspath.java:75)
at de.cenote.tools.classpath.ApplicationClasspath.add(ApplicationClasspath.java:65)
at de.cenote.jasperstarter.App.processReport(App.java:193)
at de.cenote.jasperstarter.App.main(App.java:109)

Please, Where I do the mistake? Why I can't to create the PDF file?
My apache 2.4 and PHP 7.2 running on Windows 10 saerver.

I found that the problem is with options -r
If this option is not set, the generation of the report run OK, but the problem is that subreport is not processed. If I added the option -r without any other parameter, even with path to the subreport, then the error message shows.
Please, where is the problem? Help me with it.

Thank you

@jjen009
Copy link

jjen009 commented Oct 9, 2019

I have the same problem. Even just a plain PHP file gives the following warnings when producing the .jasper file:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/var/www/asa.auckland.ac.nz/pod1/app/phpjasper/bin/jasperstarter/lib/groovy-all-2.4.12.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

It does produce the file, however. But when I run the step to create the .pdf, it crashes with:

Exception in thread "main" 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 de.cenote.tools.classpath.ApplicationClasspath.add(ApplicationClasspath.java:75)
at de.cenote.tools.classpath.ApplicationClasspath.add(ApplicationClasspath.java:65)
at de.cenote.tools.classpath.ApplicationClasspath.addJars(ApplicationClasspath.java:134)
at de.cenote.tools.classpath.ApplicationClasspath.addJarsRelative(ApplicationClasspath.java:151)
at de.cenote.jasperstarter.App.processReport(App.java:178)
at de.cenote.jasperstarter.App.main(App.java:109)
PHP Fatal error: Uncaught PHPJasper\Exception\ErrorCommandExecutable: Your report has an error and couldn 't be processed!\ Try to output the command using the function output(); and run it manually in the console. in /var/www/asa.auckland.ac.nz/pod1/app/phpjasper/src/PHPJasper.php:221
Stack trace:
#0 /var/www/asa.auckland.ac.nz/pod1/app/testJasper.php(10): PHPJasper\PHPJasper->execute()
#1 {main}
thrown in /var/www/asa.auckland.ac.nz/pod1/app/phpjasper/src/PHPJasper.php on line 221

PHP version is PHP 7.2.10
JDK version is:
openjdk 11.0.2 2019-01-15 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.2+7-LTS)

I see above that eduardoit2000 says:

i found this, and worked for me.
String pathSeparator = Syste .getProperty("path.separator");
String[] classPathEntries = System.getProperty("java.class.path") .split(pathSeparator);

But I don't know what to do with these.

jj

@mcjeph
Copy link

mcjeph commented Feb 25, 2020

I have the same problem and I fixed it by installing a different jdk version and switch to it.

@yuzrie
Copy link

yuzrie commented Feb 26, 2020

I have the same problem and I fixed it by installing a different jdk version and switch to it.

What JDK version are you using? can also tell how to specifically install and switch to it?

@coppolaop
Copy link

@mohamadyuzrie, Open JDK 8 fixed my problem.
I downloaded from https://jdk.java.net/java-se-ri/8-MR3 .
To switch, i just configure the build path on my eclipse IDE.

@mcjeph
Copy link

mcjeph commented Mar 11, 2020

@mohamadyuzrie I was using OpedJDK version 11 & 13 when i had the problem. I fixed it using OracleJDK version 8. I don't know if higher versions will make a difference though.

@fabsplayground
Copy link

@mohamadyuzrie, Open JDK 8 fixed my problem.
I downloaded from https://jdk.java.net/java-se-ri/8-MR3 .
To switch, i just configure the build path on my eclipse IDE.

Would love to try this, could you share the steps to downgrade process please? Got the package but can't figure out the command line.

Thanks in advance.
F

@drjoju
Copy link

drjoju commented Apr 19, 2020

Please see my answer to resolve this problem published in the next issue

#211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests