rpozsgai Posted October 18, 2018 Share Posted October 18, 2018 I'm converting a Jasper Report that was originally designed with a data query as the data source. Now, I'm passing in the field values directly with Java. The error I'm getting is from the Print When Expression on one of my Detail Bands. This formula worked fine when the data came from the query, but not now. What is the proper way to test for a blank field value???I tried!$F{group3}.equals(null)!($F{group3}.equals(""))LEN($F{group3})>0Arrays.asList($F{group3}.split(" ")).size()>0None of these work - I get the same error each time.Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: !$F{group3}.isEmpty() at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:291) at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:618) at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:586) at net.sf.jasperreports.engine.fill.JRFillDataset.evaluateExpression(JRFillDataset.java:1832) at net.sf.jasperreports.engine.fill.BaseReportFiller.evaluateExpression(BaseReportFiller.java:666) at net.sf.jasperreports.engine.fill.JRFillBand.evaluatePrintWhenExpression(JRFillBand.java:350) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:748) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:259) at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:119) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:558) at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:414) at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:746) at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:58) at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:216) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1153) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.lang.Thread.run(Thread.java:785)Caused by: java.lang.IllegalStateException: NotesContext not initialized for the thread at com.ibm.domino.xsp.module.nsf.NotesContext.getCurrent(NotesContext.java:123) at com.ibm.domino.xsp.module.nsf.ModuleClassLoader$DynamicClassLoader.loadClass(ModuleClassLoader.java:416) at java.lang.ClassLoader.loadClass(ClassLoader.java:809)The "NotesContext not initialized for the thread" error has been a thorn in my side many times... it seems the report will run right past it, and I've never been able to determine what causes it.[1B14:0010-1274] 10/18/2018 08:37:38 AM HTTP JVM: Error in CreatePDF: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: !$F{group3}.isEmpty(), cause: net.sf.jasperreports.engine.fill.JRExpressionEval evaluating expression for source t[1B14:0010-1274] 10/18/2018 08:37:38 AM HTTP JVM: xt: !$F{group3}.isEmpty()[1B14:0010-1274] 10/18/2018 08:37:38 AM HTTP JVM: Root cause: service com.ibm.domino.xsp.bridge.http.engine.XspCmdManager[1B14:0010-1274] 10/18/2018 08:37:38 AM HTTP JVM: Penultimate cause: method=service class=com.ibm.designer.runtime.domino.adapter.LCDEnvironment line=313 <band height="15" splitType="Prevent"> <printWhenExpression><![CDATA[!$F{qnotes3}.isEmpty()]]></printWhenExpression> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement positionType="Float" stretchType="RelativeToBandHeight" x="42" y="0" width="356" height="15" isRemoveLineWhenBlank="true" isPrintInFirstWholeBand="true" isPrintWhenDetailOverflows="true" uuid="214f58ed-995e-4a86-826c-21700f1bc5ca"/> <textElement> <font size="8"/> </textElement> <textFieldExpression><![CDATA[$F{qnotes3}]]></textFieldExpression> </textField> </band>Can someone point me in the right direction to get this resolved? Link to comment Share on other sites More sharing options...
hozawa Posted October 21, 2018 Share Posted October 21, 2018 Don't know about how you are setting up your datasource but the way to test for null is "== null" and not ".equals(null)" Link to comment Share on other sites More sharing options...
rpozsgai Posted October 22, 2018 Author Share Posted October 22, 2018 hosawa - I get the same result with ==null Link to comment Share on other sites More sharing options...
Solution rpozsgai Posted October 23, 2018 Author Solution Share Posted October 23, 2018 This was strangest error - because, as I mentioned. The original formula of isEmpty() worked when the data came from a query. But, the formula did not work when I switched to using Java passing beans instead. After a week of trial and error, I was finally able to get my report to work and it solved this error, too. The solution for me, was a small tech note I found about using Jasper Reports with nested sub-reports. I had to use the jasperreports-javaflow and commons-javaflow jars. Additionally, the jasperreports jar must removed in this case. I applied these jars, restarted the server and voila - it all works. I can't explain it any more than that, but that's what I did. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now