为什么在 JasperServer 6.0.1 上出现调度程序无效日期错误?

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

我正在将 jasperserver 从 3.7 迁移到 jasperserver 6.0.1,现在在新的 jasperserver 中我希望日期格式为 dd/mm/yyyy 但默认情况下日期格式为 yyyy-mm-dd。 为此,我在

处更改了 jasperserver_config.properties 文件

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

我改成了

    # 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

它更改了日期格式,但是当我要安排任何报告时,日期字段显示为无效日期(见下文)。有人可以帮助我更改在整个 jasperserver

上正常工作的日期格式吗

JasperReports Server 6.10 版之前存在一个错误,请参阅 bug report。我当时不得不使用解决方案#2。

解决方案#1

如果可能,更新到版本 6.10。

解决方案#2

此解决方案有点冗长,但如果两个步骤(更改源、生成优化的 js 文件)都完成,则可以正常工作:

您必须编辑 js 文件才能正常工作。使用您需要的模式。

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

优化Java脚本

注意: 由于优化了 Java 脚本文件(据我所知这不是编辑过的文件),请记住您可能需要重新创建优化的 js 文件 - 因为优化的文件是 JRS 使用的文件。第 5 版就是这种情况。6.x 至少:

  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

注意:如果在执行所有这些操作后出现问题,请记住清除浏览器缓存。