Virtualizer and JavaScript

1

Good day,

We have enabled virtualization when generating reports:

  JRSwapFile swapFile = new JRSwapFile(configurationService.getReportResourcePath(), VIRT_BLOCK_SIZE, VIRT_PAGE_COUNT);
  JRSwapFileVirtualizer virtualizer = new JRSwapFileVirtualizer(VIRT_PAGE_COUNT, swapFile);
  virtualizer.setReadOnly(false);

  param.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
  jasperPrint = JasperFillManager.fillReport(jasperReport, param);

However, when we try to generate a report longer than VIRT_PAGE_COUNT, we get the following error:

net.sf.jasperreports.engine.util.SwapFileVirtualizerStore store
SEVERE: Error virtualizing object 145329976_33558975_1_-1314094481 to JRSwapFile /reportResources/resources/swap_194903130_1598288065087
java.io.NotSerializableException: net.sf.jasperreports.compilers.JavaScriptFunctionsObject
  at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
  {...}
  at net.sf.jasperreports.engine.virtualization.VirtualizationOutput.writeJRObject(VirtualizationOutput.java:88)
  {...}
  at net.sf.jasperreports.engine.util.SwapFileVirtualizerStore.store(SwapFileVirtualizerStore.java:97)
{...}
net.sf.jasperreports.engine.JRRuntimeException: Error virtualizing object.
  at net.sf.jasperreports.engine.util.SwapFileVirtualizerStore.store(SwapFileVirtualizerStore.java:113)
  {...}
  at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:966)
  {...}
Caused by: java.io.NotSerializableException: net.sf.jasperreports.compilers.JavaScriptFunctionsObject
  at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
  {...}
  at net.sf.jasperreports.engine.virtualization.VirtualizationOutput.writeJRObject(VirtualizationOutput.java:88)
  {...}

I've omitted a number of lines from the stack trace above for brevity, but I can make the whole thing available if necessary.

This is due to the report using JavaScript functions in variables like this:

  <variable name="ct_devices_obj" class="java.lang.Object" resetType="Group" resetGroup="Target">
    <variableExpression><![CDATA[true? function () {
      var acc = $V{ct_devices_obj};
      if (acc == null) {
        acc = {
          array:[]
        };
      }
      return acc;
    }():null]]></variableExpression>
  </variable>

Is this incompatibility a known issue? Is there a way to make JavaScript work with virtualization, or do we need to switch the report's language back to Java, and figure out how to rewrite our variable expressions in that language?

Thanks!

allan.meek's picture
Joined: May 30 2017 - 7:27am
Last seen: 59 sec ago

0 Answers:

No answers yet
Feedback
randomness