2012-05-11 97 views
0

我收到以下Jasper報告異常。Jasper報告中的評估異常

JRXML文件的部分是

<textField> 
    <reportElement x="813" y="30" width="25" height="16"/> 
    <textElement> 
     <font size="12"/> 
    </textElement> 
    <textFieldExpression><![CDATA[Pcs]]></textFieldExpression> 
</textField> 
<line> 
    <reportElement x="232" y="2" width="1" height="20"/> 
</line> 

異常的完整堆棧跟蹤如下

net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression: 
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:203) 
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591) 
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559) 
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:876) 
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:421) 
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:406) 
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:257) 
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:473) 
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:434) 
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnHeader(JRVerticalFiller.java:479) 
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:261) 
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128) 
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:836) 
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:746) 
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58) 
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417) 
at Utilities.ReportDriver.runReport(ReportDriver.java:85) 
at jewelleryerpapplication.GUI.MainReports.jbtnViewReportActionPerformed(MainReports.java:864) 
at jewelleryerpapplication.GUI.MainReports.access$700(MainReports.java:19) 
at jewelleryerpapplication.GUI.MainReports$8.actionPerformed(MainReports.java:504) 
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) 
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341) 
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402) 
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259) 
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252) 
at java.awt.Component.processMouseEvent(Component.java:6505) 
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321) 
at java.awt.Component.processEvent(Component.java:6270) 
at java.awt.Container.processEvent(Container.java:2229) 
at java.awt.Component.dispatchEventImpl(Component.java:4861) 
at java.awt.Container.dispatchEventImpl(Container.java:2287) 
at java.awt.Component.dispatchEvent(Component.java:4687) 
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832) 
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492) 
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422) 
at java.awt.Container.dispatchEventImpl(Container.java:2273) 
at java.awt.Window.dispatchEventImpl(Window.java:2713) 
at java.awt.Component.dispatchEvent(Component.java:4687) 
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707) 
at java.awt.EventQueue.access$000(EventQueue.java:101) 
at java.awt.EventQueue$3.run(EventQueue.java:666) 
at java.awt.EventQueue$3.run(EventQueue.java:664) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) 
at java.awt.EventQueue$4.run(EventQueue.java:680) 
at java.awt.EventQueue$4.run(EventQueue.java:678) 
at java.security.AccessController.doPrivileged(Native Method) 
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) 
at java.awt.EventQueue.dispatchEvent(EventQueue.java:677) 
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211) 
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128) 
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117) 
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113) 
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105) 
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) 
DetaiListlCustReport__1336728676796_795705 
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:49) 
at org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:86) 
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:239) 
at DetaiListlCustReport__1336728676796_795705.evaluate(calculator_DetaiListlCustReport__1336728676796_795705:227) 
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:190) 

回答

2

你失去了雙引號爲文本框元素表達,或者你應該使用${}構造變量,f領域或參數。

爲字符串常量「PCS」正確表達式爲:

<textFieldExpression><![CDATA["Pcs"]]></textFieldExpression> 

用於可變PCS正確表達式爲:

<textFieldExpression><![CDATA[$V{Pcs}]]></textFieldExpression> 

這是有效的表達式(沒有雙引號)for staticText element:

<text><![CDATA[Static text]]></text> 
+0

This Working For Me <![CDATA [「Pcs」]]>非常感謝 –

+0

@Prog_Anila歡迎:) –