Skip to content

Java error running a report #162

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
malcolmfowler opened this issue Aug 27, 2019 · 1 comment
Closed

Java error running a report #162

malcolmfowler opened this issue Aug 27, 2019 · 1 comment

Comments

@malcolmfowler
Copy link

I am trying to port my reports from PHPJasperXML to PHPJasper and also move to a LINUX server.

Installed using composer ... All OK
Java is installed

I have successfully compiled a test report under linux using the example code as follows

<?php require __DIR__ . '/vendor/autoload.php'; use PHPJasper\PHPJasper; $input = __DIR__ . '/reports/test1.jrxml'; $jasper = new PHPJasper; $jasper->compile($input)->execute(); ?>

Then set the executable directory...
sudo chmod +x /var/www/html/vendor/geekcom/phpjasper/bin/jasperstarter/bin

The trying to run the report using this code

`<?php
require DIR . '/vendor/autoload.php';
use PHPJasper\PHPJasper;
$input = DIR . '/reports/test1.jasper';
$output = DIR . '/printed_reports';
$options = [
'format' => ['pdf'],
'locale' => 'en',
'params' => [],
'db_connection' => [
'driver' => 'mysql',
'username' => 'myUsername',
'password' => 'myPassword',
'host' => 'localhost',
'database' => 'wms_mfsl',
'port' => '3306'
]
];

$jasper = new PHPJasper;
$jasper->process(
$input,
$output,
$options
)->execute();
?>`

The following error occurs in the browser..

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/html/vendor/geekcom/phpjasper/src/PHPJasper.php:219 Stack trace: #0 /var/www/html/test2.php(34): PHPJasper\PHPJasper->execute() #1 {main} thrown in /var/www/html/vendor/geekcom/phpjasper/src/PHPJasper.php on line 219

and when running PHP command line i see the following error.

php /var/www/html/test2.php
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/html/vendor/geekcom/phpjasper/src/PHPJasper.php:219
Stack trace:
#0 /var/www/html/test2.php(34): PHPJasper\PHPJasper->execute()
#1 {main}
thrown in /var/www/html/vendor/geekcom/phpjasper/src/PHPJasper.php on line 219

Here is the XML report definition from Jaspersoft studio.
`

<title> </title> ` Any guidance on what I am doing wrong?

Thanks
Malcolm

@malcolmfowler
Copy link
Author

FYI - I have just run this on a windows server and all works as expected.

@geekcom geekcom closed this as completed Aug 29, 2019
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

2 participants