从php javabridge JasperReports传递参数

时间:2016-11-17 12:43:39

标签: java php jasper-reports php-java-bridge

我正在使用javabridge并收到此警告和错误:

        [ec2-user@ip-172-22-2-182 ~]$ sudo realm join -U admin@corp.xxx.com corp.xxx.com --verbose
 * Resolving: _ldap._tcp.corp.xxx.com
 * Resolving: corp.xxx.com
 * Performing LDAP DSE lookup on: 172.22.2.34
 * Successfully discovered: corp.xxx.com
Password for admin@corp.xxx.com: 
 * Required files: /usr/sbin/oddjobd, /usr/libexec/oddjob/mkhomedir, /usr/sbin/sssd, /usr/sbin/adcli
 * LANG=C /usr/sbin/adcli join --verbose --domain xxx.com --domain-realm CORP.xxx.COM --domain-controller 172.22.2.34 --login-type user --login-user admin@xxx.com --stdin-password
 * Using domain name: corp.xxx.com
 * Calculated computer account name from fqdn: IP-172-22-2-182
 * Using domain realm: xxx.com
 * Sending netlogon pings to domain controller: cldap://172.22.2.34
 * Received NetLogon info from: WIN-QUUMO7C7PU3.xxx.com
 * Wrote out krb5.conf snippet to /var/cache/realmd/adcli-krb5-g1oscN/krb5.d/adcli-krb5-conf-RlQBkY
 ! Couldn't get kerberos ticket for: admin@xxx.com: Cannot find KDC for realm "xxx.com"
adcli: couldn't connect to xxx.com domain: Couldn't get kerberos ticket for: admin@xxx.com: Cannot find KDC for realm "xxx.com"
 ! Failed to join the domain
realm: Couldn't join realm: Failed to join the domain
[ec2-user@ip-172-22-2-182 ~]$ 

在我的php文件中,启动此错误的代码是当我尝试将日期参数传递给JasperReports的报告时创建java.util.date类的实例:

 ( ! ) Warning: Unchecked exception detected: [[o:Response$UndeclaredThrowableErrorMarker]:"FATAL: Undeclared java.lang.RuntimeException detected. java.lang.Exception: CreateInstance failed: new java.util.Date((o:String)[o:String]). Cause: java.lang.IllegalArgumentException VM: 1.7.0_79@http://java.oracle.com/" at: #-11 java.util.Date.parse(Unknown Source) #-10 java.util.Date.<init>(Unknown Source) #-9 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) #-8 sun.reflect.NativeConstructorAccessorImpl[...]java/Java.inc(361): java_Arg->getResult(false) #2 http://localhost:8080/JavaBridgeTemplate/java/Java.inc(364): java_Client->getWrappedResult(false) #3 http://localhost:8080/JavaBridgeTemplate/java/Java.inc(536): java_Client->getInternalResult() #4 http://localhost:8080/JavaBridgeTemplate/java/Java.inc(1930): java_Client->createObject('java.util.Date', Array) #5 C:\wamp\www\advanced\backend\javabridge\generate.php(48): Java->Java('java.util.Date', '2016-07-01') #6 {main}] in http://localhost:8080/JavaBridgeTemplate/java/Java.inc on line 202
Call Stack
#   Time    Memory  Function    Location
1   0.0040  324624  {main}( )   ..\generate.php:0
2   3.3043  1428168 Java->Java( )   ..\generate.php:48
3   3.3043  1429240 java_Client->createObject( )    ..(null):1930
4   3.3113  1429512 java_Client->getInternalResult( )   ..(null):536
5   3.3113  1429560 java_Client->getWrappedResult( )    ..(null):364
6   3.3113  1429560 java_Arg->getResult( )  ..(null):361
7   3.3113  1441256 java_ThrowExceptionProxyFactory->checkResult( ) ..(null):235
8   3.3163  1444344 trigger_error ( )   ..(null):202

Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: Invoke failed: [[c:JasperFillManager]]->fillReport((o:JasperReport)[o:JasperReport], (i:Map)[o:HashMap], (i:Connection)[o:Connection]). Cause: net.sf.jasperreports.engine.JRException: Incompatible php.java.bridge.Response$UndeclaredThrowableErrorMarker value assigned to parameter FInicio in the Reubicados dataset. VM: 1.7.0_79@http://java.oracle.com/" at: #-17 net.sf.jasperreports.engine.fill.JRFillDataset.setParameter(JRFillDataset.java:903) #-16 net.sf.jasperreports.engine.fill.JRFillDataset.setFillParameterValues(JRFillDataset.java:642) #-15 net.sf.jasperreports.engine.fill.JRFillDataset.setParameterValues(JRFillDataset.java:585) #-14 net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1280) #-13 net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:901) #-12 net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:845) #-11 net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58) #-10 net.sf.ja in http://localhost:8080/JavaBridgeTemplate/java/Java.inc on line 195

这是 jrxml

require_once("http://localhost:8080/JavaBridgeTemplate/java/Java.inc");

try {
    $Param1 = date('Y-m-d', strtotime($_POST['FInicio']));
    $Param2 = date('Y-m-d', strtotime($_POST['FFin']));
    $fecha1=date_create("2016-01-15");
    $fecha2=date_create("2016-08-15");
    $date1 = date_format( $fecha1, 'Y-m-d');             
    $date2 = date_format( $fecha2, 'Y-m-d');             

    $jasperxml = new java("net.sf.jasperreports.engine.xml.JRXmlLoader");
    $jasperDesign = $jasperxml->load(realpath("Reubicados.jrxml"));
    $query = new java("net.sf.jasperreports.engine.design.JRDesignQuery");

    $jasperDesign->setQuery($query);
    $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");
    //aqui se pasan los parametros (Fecha Inicio y Fecha Fin)
    $params = new Java("java.util.HashMap");

$params->put("FInicio",new Java('java.util.date', $Param1));
$params->put("FFin",new Java('java.util.date', $Param2)); 

0 个答案:

没有答案