Search code examples
jasper-reportsjasperserver

Why do I get scheduler Invalid Date error on JasperServer 6.0.1?


I am migrating the jasperserver from 3.7 to jasperserver 6.0.1, now in new jasperserver i want the date format to be dd/mm/yyyy but by default the date format is yyyy-mm-dd. For this i changed the jasperserver_config.properties file at

apache-tomcat-7.0.65\webapps\jasperserver\WEB-INF\bundles\jasperserver_config.properties

i changed it to

    # Used for parsing and formatting dates by server
    date.format=dd/MM/yyyy
    datetime.format=dd/MM/yyyy HH:mm:ss
    time.format=HH:mm:ss

    # Used for parsing and formatting dates by calendar component (UI).
    # Pattern for date should match appropriated pattern from server properties.
    # The format for calendar component can be combinations of the following:
    # d  - day of month (no leading zero)
    # dd - day of month (two digit)
    # o  - day of year (no leading zeros)
    # oo - day of year (three digit)
    # D  - day name short
    # DD - day name long
    # m  - month of year (no leading zero)
    # mm - month of year (two digit)
    # M  - month name short
    # MM - month name long
    # y  - year (two digit)
    # yy - year (four digit)
    calendar.date.format=dd/mm/yyyy
    calendar.datetime.format=dd/mm/yyyy HH:mm:ss
    calendar.time.format=HH:mm:ss

It changed the date format but when I am going to schedule any report the date field is showing as invalid date(see below). Can some one help me in changing the date format that work correctly all over jasperserver

enter image description here


Solution

  • There is a bug with this up to version 6.10 of JasperReports Server, see bug report. I've had to use the solution #2 at the time being.

    Solution #1

    If possible, update to version 6.10.

    Solution #2

    This solution is a bit lengthy but works properly if both steps (changing the source, generating the optimized js file) are done:

    You have to edit a js file for this to work properly. Use the pattern you need for your case.

    in file /opt/jasperreports-server-cp-5.5.0a/apache-tomcat/webapps/jasperserver/scripts/scheduler/model/job.js you have to change this:

    row 5

    from:

      var UI_DATE_PATTERN = "YYYY-MM-DD HH:mm";
    

    to:

      var UI_DATE_PATTERN = "DD.MM.YYYY HH:mm";
    

    row 766

    from:

    data.trigger.startDate = moment(data.trigger.startDate).format(SERVICE_DATE_PATTERN);
    

    to:

     data.trigger.startDate = moment(data.trigger.startDate,UI_DATE_PATTERN).format(SERVICE_DATE_PATTERN);
    

    Source

    Optimized Java Script

    NOTE: Because of the optimized Javascript files (which is not the one which is edited as far as I remember), keep in mind you might need to recreate the optimized js file - since the optimized one is the one which is used by JRS. This was the case in v 5.6.x at least:

    1. Create a working directory where you can copy JavaScript files and install and run the required scripts. In this example, the directory is called Working.
    2. Create a subdirectory for a copy of the JavaScript files from JasperReports Server. This directory is called jssources.
    3. Copy the following directories from the JasperReports Server directory, <js-webapp>, to js-sources:

      • Copy <js-webapp>/scripts to js-sources/scripts.

      • Copy <js-webapp>/fusion to js-sources/fusion (optional, Pro version only)

    4. Back up your js-sources directory.
    5. Create a js-optimization-output directory for the output of the optimization process.
    6. Download and install node.js from http://nodejs.org/. Place the nodejs folder directly in your Working folder.
    7. Download r.js, a requirejs optimization file, from http://requirejs.org and place it directly in the Working folder.
    8. Make your changes to the JavaScript files in Working/js-sources.
    9. Open a command line tool and run the commands to optimize the JavaScript. The following example is for Windows, it places the output in the Working/js-optimization-output folder:

      % cd Working

      % nodejs\node r.js -o js-sources\scripts\build.js appDir=js-sources\scripts baseUrl=. optimize=uglify2 dir=js-optimization-output

    10. Copy the optimized scripts from js-optimization-output to <webapp>/optimized-scripts (where webapp is the location of your JRS)
    11. Reload the web app in the app server to see the changes.

    Source

    NOTE: Keep in mind to clear your browser cache if there are problems after doing all this.