Jump to content

Days function working in Jaspersoft Studio but not with ReportServer


Go to solution Solved by reportdev,

Recommended Posts

Posted

Hello everybody!

I hace few reports which are using the function DAYS(DATE1, DATE2) to calculate number of days between two dates.

My expression is (DAYS(new SimpleDateFormat("dd/MM/yyyy").parse($F{DATE_DEBUT_ABSENCE}),new SimpleDateFormat("dd/MM/yyyy").parse($V{date_fin_sejour}))+1).

It's working well and without error on Jaspersoft studio 6.4.0 but when i try to generate a report with jasperreports 6.2.0 i have an error.

net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: (DAYS(new SimpleDateFormat("dd/MM/yyyy").parse($F{DATE_DEBUT_ABSENCE}),new SimpleDateFormat("dd/MM/yyyy").parse($V{date_fin_sejour}))+1)

How an expression can work on Jaspersoft Studio and not on jasperreports? Thanks in advance for your future answer.

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Posted

Hi there,

just a quick info. Even I got the same error when used on jasperreports api, but it works fine on Jasper Server and Studio.

I believe jasperreports api jar does not have all the Jasper Server/Jasper Studio built in functions such as DAYS / DAYSINMONTH etc. 

Exception in thread "main" net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: DAYS(DATE(1987,02,01),new Date())
    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.JRFillElement.evaluateExpression(JRFillElement.java:1020)
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:568)
    at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:552)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:281)
    at net.sf.jasperreports.engine.fill.JRFillFrame.evaluate(JRFillFrame.java:163)
    at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:281)
    at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:504)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2026)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupHeader(JRVerticalFiller.java:613)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupHeaders(JRVerticalFiller.java:535)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:161)
    at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:558)
    at net.sf.jasperreports.engine.fill.BaseReportFiller.fill(BaseReportFiller.java:396)
    at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:91)
    at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:456)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:863)
    at jasperSpfinalTest.FinalTestIterator.main(FinalTestIterator.java:84)
Caused by: java.lang.NoClassDefFoundError: net.sf.jasperreports.functions.standard.DateTimeFunctions

 

Posted

I think it's related to these libs. I'll try to check if they are already in the build path or not and i come back to give an answer.

Posted

OK, i can't check directly on production server... But i've tried a test. I have made a small simple report with some of DateTime functions which are inside jasperreports-functions libs... And it's pretty weird... NOW(), DAY(), SECOND(), DATEVALUE() are OK and functionnal, but DAYS(), YEARS(), MONTHS() give me the error mentionned here...

And these methods are using another method from joda-time lib, so it seems joda-time is the missing libray on theserver

Posted

I have checked my 6.4 Servers and the joda time jar is already there. The server should be shipped with the joda time jar.

If someone tried to delete the libraries, then this would occur from my understanding.

Just check your servers for any other missing libraries. 

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...