Jump to content
Changes to the Jaspersoft community edition download ×

Issue Collection is not a Java object,using NULL instead in using php/javabridge


jazebmazher728

Recommended Posts

Hi ,

I am facing this issue when i am sending custom data through JRBeamDataSource Collection data integrate in php but i am facing this error

Warning: argument 'Collection' is not a Java object,using NULL instead in http://localhost:8080/JavaBridgeTemplate721/java/Java.inc on line 511

this is my php code

<?php

require_once("http://localhost:8080/JavaBridgeTemplate721/java/Java.inc");
require "collection.php";

try {

    $jasperxml = new java("net.sf.jasperreports.engine.xml.JRXmlLoader");
    $jasperDesign = $jasperxml->load(realpath("customer.jrxml"));
    $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager");
    $report = $compileManager->compileReport($jasperDesign);
} catch (JavaException $ex) {
    echo $ex;
}

$fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager");
$array1 = [['debit'=> '20.00','credit'=> '50.00'],['debit'=> '10.00','credit'=> '15.00']];
$arrayList = new java( 'java.util.ArrayList');
foreach($array1 as $key => $a){
    $collect1 = new Collection();
    $collect1->setDebit($a['debit']);
    $collect1->setCredit($a['credit']);
    $arrayList->add($collect1);
}
//$arrays = ['20.00','30.00','40.00'];
$params = new Java("java.util.HashMap");
/*
$params->put("debit", "30.00");
$params->put("credit", "3.00");
$params->put("description", "Test123Customer");
$params->put("date", "2019-07-22 06:37:09");
*/

$class = new JavaClass("java.lang.Class");
$beanCollection = new Java("net.sf.jasperreports.engine.data.JRBeanCollectionDataSource" , $arrayList);
$params->put('DataSource', $beanCollection);
$emptyDataSource = new Java("net.sf.jasperreports.engine.JREmptyDataSource");
$jasperPrint = $fillManager->fillReport($report, $params, $emptyDataSource);
$exporter = new java("net.sf.jasperreports.engine.JRExporter");

switch ($_POST['format']) {
    case 'pdf':
        $outputPath = realpath(".")."/"."output.pdf";
        
        $exportManager = new JavaClass("net.sf.jasperreports.engine.JasperExportManager");
        $exportManager->exportReportToPdfFile($jasperPrint, $outputPath);
        break;
}
?>

 

and this is my collection class php

<?php
class Collection {

    private $debit;
    private $credit;

    public function __construct()
    {
        $this->debit = '';
        $this->credit = '';
    }
    // getter-setter
    
    public function getDebit(){
        return $this->debit;
    }
    
    public function setDebit($debit){
        $this->debit = $debit;
    }
    
    public function getCredit(){
        return $this->credit;
    }
    
    public function setCredit($credit){
        $this->credit = $credit;
    }
}

?>

thats why i am seeing reporting value is null plz help me how to resolve this issue in php using php/javabridge not java?

Link to comment
Share on other sites

  • 1 month later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...