0
votes

This report is include external jar in jasper studio, when i run in jasper running as expected then nothing error produce, but if i compile this on laravel it's generate Error filling reportError loading scriptlet class.

I had see in jaspersoft my external.jar only have path within name like class=external.jar, i reverse engineering .jasper file, there is no clue how to whether jasperstarter or php access this external jar library

Jasper studio : Referenced library

/Users/me/Documents/GitHub/myproject/storage/app/file/jasper/external.jar

Detail on my jrxml:

    <scriptlet name="Scriptlet_1" class="external">
        <scriptletDescription><![CDATA[]]></scriptletDescription>
    </scriptlet>

Detail on my PHP

 $folderstorage = "/app/file/jasper";
        $folderassets = "/User/file/jasper";
        $namef = "invoice";
        $input = storage_path().$folderstorage."/".$namef.".jasper"; 
        $output = storage_path().$folderstorage;
        $options = [
            'format' => [$ext2],
            'locale' => 'en',
            'params' => ['myid'=>$id],
            'db_connection' => [
                'driver' => 'postgres', //mysql, ....
                'username' => env("DB_USERNAME"),
                'password' => env("DB_PASSWORD"),
                'host' => env("DB_HOST"),
                'database' => env("DB_DATABASE"),
                'port' => env("DB_PORT")
            ]
        ];
        if(file_exists(storage_path().$folderstorage."/".$namafile . '.' . $ext)){
            unlink(storage_path().$folderstorage."/".$namafile . '.' . $ext );
        }
        $jasper = new PHPJasper;
        $jasper->compile($input)->process(
            $input,
            $output,
            $options
        )->execute();

When run in browser then look console of my IDE: Using $input = storage_path().$folderstorage."/".$namef.".jrxml";

value = ((external)parameter_Scriptlet_1_SCRIPTLET.getValue()).calcucredit(((java.math.BigDecimal)variable_sumTotalItem.getEstimatedValue()).doubleValue()).toString().toUpperCase(); //$JR_EXPR_ID=26$

Using .jasper

Error filling reportError loading scriptlet class: calcucredit

On this project i run with:

  1. Laravel 6.2
  2. geekcom/phpjasper : 3.3
  3. jasper studio 6.6.0
  4. in external.jar project i had include jasperreports-6.7.0
1

1 Answers

1
votes

Fighting for several days for fix this issue, it's simple way and awkward. Just do this :

Put external.jar on vendor/geekcom/phpjasper/bin/jasperstarter/jdbc/external.jar In jrxml put scriptletclass in jasperReport tag : <jasperReport scriptletClass="external" In jasper soft change referenced libraries to path vendor/geekcom/phpjasper/bin/jasperstarter/jdbc/external.jar Always remember to click preview after made a changed and restart jaspersoft if cache last scriptlet reshown.