Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0043592Openbravo ERPA. Platformpublic2020-03-20 13:542020-04-02 08:46
0043592: jrxml translate build step fails if using jasperreport.dtd
When a jrxml file makes use of jasperreport.dtd, translate build step fails executing with JDK 9+:

Compilation fails in case of an external dtd is used on a JRXML file:
     [java] 1770 [main] ERROR org.openbravo.translate.Translate - file: /XX/XX/XX/XX.jrxml
     [java] null
     [java] at<init>( ~[?:?]
     [java] at<init>( ~[?:?]
     [java] at<init>( ~[?:?]
     [java] at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) ~[xercesImpl.jar:?]
     [java] at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source) ~[xercesImpl.jar:?]
     [java] at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown Source) ~[xercesImpl.jar:?]
     [java] at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown Source) ~[xercesImpl.jar:?]
     [java] at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown Source) ~[xercesImpl.jar:?]
     [java] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) ~[xercesImpl.jar:?]
     [java] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) ~[xercesImpl.jar:?]
     [java] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) ~[xercesImpl.jar:?]
     [java] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) ~[xercesImpl.jar:?]
     [java] at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) ~[xercesImpl.jar:?]
     [java] at org.openbravo.translate.Translate.parseFile( [openbravo-trl.jar:?]
     [java] at org.openbravo.translate.Translate$1.visitFile( [openbravo-trl.jar:?]
     [java] at org.openbravo.translate.Translate$1.visitFile( [openbravo-trl.jar:?]
     [java] at java.nio.file.Files.walkFileTree( [?:?]
     [java] at java.nio.file.Files.walkFileTree( [?:?]
     [java] at org.openbravo.translate.Translate.execute( [openbravo-trl.jar:?]
     [java] at org.openbravo.translate.Translate.main( [openbravo-trl.jar:?]
     [java] Caused by: java.lang.NullPointerException
     [java] at<init>( ~[?:?]
     [java] ... 19 more
1. Add to C_Order.jrxml the following:
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" ""> [^]
2. Set core module in development
3. run ant smartbuild (sing JDK 11)
No tags attached.
blocks defect 0043532 closed alostale jrxml translate build step fails if using jasperreport.dtd 
Issue History
2020-03-26 13:18alostaleTypedefect => backport
2020-03-26 13:18alostaleTarget Version => 3.0PR19Q4.4
2020-03-30 10:28hgbotCheckin
2020-03-30 10:28hgbotNote Added: 0118866
2020-03-30 10:28hgbotStatusscheduled => resolved
2020-03-30 10:28hgbotResolutionopen => fixed
2020-03-30 10:28hgbotFixed in SCM revision => [^]
2020-04-02 08:46caristuNote Added: 0118910
2020-04-02 08:46caristuStatusresolved => closed
2020-04-02 08:46caristuFixed in Version => 3.0PR19Q4.4

2020-03-30 10:28   
Repository: erp/backports/3.0PR19Q4.4
Changeset: 084e45e1daf7976ace52d5b96f7577e14fe6f8aa
Author: Asier Lostalé <asier.lostale <at>>
Date: Thu Mar 26 12:25:43 2020 +0100
URL: [^]

fixed BUG-43592: jrxml translate build step fails if using jasperreport.dtd

Translate makes use of a custom EntityResolver to handle jasperreport.dtd
resolving it locally instead of getting it from Internet. This local
resolution is implemented making use of Class.getResourceAsStream
method. The class the method was invoked from was java.lang.System.

Starting from JDK 9, getResourceAsStream invoked in classes within named
Modules looks for the resources only in those modules rather than in the
whole classpath [1]:

  > If this class is in a named Module then this method will attempt to find
  > the resource in the module. This is done by delegating to the module's class
  > loader findResource(String,String) method, invoking it with the module name
  > and the absolute name of the resource. Resources in named modules are subject
  > to the rules for encapsulation specified in the Module getResourceAsStream
  > method and so this method returns null when the resource is a non-".class"
  > resource in a package that is not open to the caller's module.
  > Otherwise, if this class is not in a named module then the rules for searching
  > resources associated with a given class are implemented by the defining class
  > loader of the class. This method delegates to this object's class loader. If
  > this object was loaded by the bootstrap class loader, the method delegates to
  > ClassLoader.getSystemResourceAsStream(java.lang.String).

As java.lang.System is in a named Module, dtd's resource was tried to be found within
it and not found.

Fixed by invoking getResourceAsStream on LocalEntityResolver.class which
is not in a named module.

[1] [^]

M src-trl/src/org/openbravo/translate/
2020-04-02 08:46