我尝试使用PHPJasper创建一些代码,但在同一行出现错误。我认为这是 Java SE 版本的问题。
文件hello_world.jasper已经存在于我的项目中。
源代码:
require __DIR__ . '/vendor/autoload.php';
use PHPJasper\PHPJasper;
$jasper = new PHPJasper;
$input = __DIR__ . '/vendor/geekcom/phpjasper/examples/hello_world.jasper';
$output = __DIR__ . '/vendor/geekcom/phpjasper/examples';
$options = [
'format' => ['pdf', 'rtf']
];
$jasper->process(
$input,
$output,
$options
)->execute();
var_dump($jasper);
控制台中的错误与execute():
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 /home/jack/PhpstormProjects/JasperTest/vendor/geekcom/phpjasper/src/PHPJasper.php:219
Java 版本:
java -version
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu219.04)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu219.04, mixed mode, sharing)
我该如何解决?
catspeake
相关分类