Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0043591Openbravo ERPA. Platformpublic2020-03-20 13:542020-04-02 08:46
guillermogil 
alostale 
highminoralways
closedfixed 
5
 
3.0PR20Q1.13.0PR20Q1.1 
caristu
Core
No
0043591: 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] java.net.MalformedURLException: null
     [java] at java.net.URL.<init>(URL.java:679) ~[?:?]
     [java] at java.net.URL.<init>(URL.java:541) ~[?:?]
     [java] at java.net.URL.<init>(URL.java:488) ~[?:?]
     [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(Translate.java:251) [openbravo-trl.jar:?]
     [java] at org.openbravo.translate.Translate$1.visitFile(Translate.java:219) [openbravo-trl.jar:?]
     [java] at org.openbravo.translate.Translate$1.visitFile(Translate.java:208) [openbravo-trl.jar:?]
     [java] at java.nio.file.Files.walkFileTree(Files.java:2724) [?:?]
     [java] at java.nio.file.Files.walkFileTree(Files.java:2796) [?:?]
     [java] at org.openbravo.translate.Translate.execute(Translate.java:208) [openbravo-trl.jar:?]
     [java] at org.openbravo.translate.Translate.main(Translate.java:166) [openbravo-trl.jar:?]
     [java] Caused by: java.lang.NullPointerException
     [java] at java.net.URL.<init>(URL.java:585) ~[?:?]
     [java] ... 19 more
1. Add to C_Order.jrxml the following:
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> [^]
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.0PR20Q1.1
2020-03-30 10:27hgbotCheckin
2020-03-30 10:27hgbotNote Added: 0118865
2020-03-30 10:27hgbotStatusscheduled => resolved
2020-03-30 10:27hgbotResolutionopen => fixed
2020-03-30 10:27hgbotFixed in SCM revision => http://code.openbravo.com/erp/backports/3.0PR20Q1.1/rev/602682efc345362ded2a3bcd737fd2fa37121bff [^]
2020-04-02 08:46caristuNote Added: 0118909
2020-04-02 08:46caristuStatusresolved => closed
2020-04-02 08:46caristuFixed in Version => 3.0PR20Q1.1

Notes
(0118865)
hgbot   
2020-03-30 10:27   
Repository: erp/backports/3.0PR20Q1.1
Changeset: 602682efc345362ded2a3bcd737fd2fa37121bff
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Mar 26 12:25:43 2020 +0100
URL: http://code.openbravo.com/erp/backports/3.0PR20Q1.1/rev/602682efc345362ded2a3bcd737fd2fa37121bff [^]

fixed BUG-43591: 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] https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Class.html#getResourceAsStream(java.lang.String) [^]

---
M src-trl/src/org/openbravo/translate/LocalEntityResolver.java
---
(0118909)
caristu   
2020-04-02 08:46   
Reviewed