Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0043532
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] A. Platformminoralways2020-03-20 13:542020-04-06 15:49
ReporterguillermogilView Statuspublic 
Assigned Toalostale 
PriorityhighResolutionfixedFixed in Version3.0PR20Q2
StatusclosedFix in branchFixed in SCM revisiondb6cf35ac8a5
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version>=9
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned Tocaristu
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0043532: jrxml translate build step fails if using jasperreport.dtd

DescriptionWhen 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
Steps To Reproduce1. 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)
TagsNo tags attached.
Attached Filesdiff file icon 43532.diff [^] (846 bytes) 2020-03-25 13:11 [Show Content]

- Relationships Relation Graph ] Dependency Graph ]
depends on backport 00435913.0PR20Q1.1 closedalostale jrxml translate build step fails if using jasperreport.dtd 
depends on backport 00435923.0PR19Q4.4 closedalostale jrxml translate build step fails if using jasperreport.dtd 
blocks feature request 0037083 closedalostale support JDK 9 

-  Notes
(0118797)
shuehner (administrator)
2020-03-25 12:52

Hello,
the proposed solution is most likely wrong.
As it just disables functionality without needing it.

There is already code in place since here:
changeset: 673:d344659ef3bb
date: Thu Apr 17 09:49:26 2008 +0000

Which solved that problem (back then) by having a local copy for this specific dtd avoiding the need for the parser to download it.

But apparently that is now not working correctly in some cases.

So probably we should debug and fix that existing mechanism which should fix the issue without loosing the whole feature of validating the xml against its dtd
(0118798)
shuehner (administrator)
2020-03-25 12:59

Further testing shows this error to only happen if Translate java code is running with openjdk11 and it is NOT failing when running with openjdk8
(0118799)
shuehner (administrator)
2020-03-25 13:13

Talking about attached diff:
Move reading the dtd from jasper jar file to use ClassLoader defined for Translate.java itself. That way it sees the classpath we have defined in our builds.xml on invocation (project.class.path) and properly returns the resources.

Without the change running with Java11 the call returns null when using SystemClassLoader which apparently worked before until java8.
Comparing with the various other getResourceAsStream calls we have in pi they all call it on a concrete class which probably explains why the change in behavior from Java was hidden until now.
(0118863)
hgbot (developer)
2020-03-30 10:18

Repository: erp/devel/pi
Changeset: 69adcc2cd00b4c9a04ae16b0d49000a0b8e5a4e7
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Mar 26 12:22:20 2020 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/69adcc2cd00b4c9a04ae16b0d49000a0b8e5a4e7 [^]

related to BUG-43532: apply Java formatting

---
M src-trl/src/org/openbravo/translate/LocalEntityResolver.java
---
(0118864)
hgbot (developer)
2020-03-30 10:18

Repository: erp/devel/pi
Changeset: 0ef412c29220602f3c9286809981bb24d2aa76d9
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Mar 26 12:25:43 2020 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/0ef412c29220602f3c9286809981bb24d2aa76d9 [^]

fixed BUG-43532: 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
---
(0118911)
caristu (developer)
2020-04-02 08:47

MR: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/53 [^]
(0118977)
hgbot (developer)
2020-04-06 11:54

Repository: erp/devel/pi
Changeset: 7bfb4609be0de9d08b4ef82936fb2e56cc34a160
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Mar 26 12:22:20 2020 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/7bfb4609be0de9d08b4ef82936fb2e56cc34a160 [^]

related to BUG-43532: apply Java formatting

---
M src-trl/src/org/openbravo/translate/LocalEntityResolver.java
---
(0118978)
hgbot (developer)
2020-04-06 11:54

Repository: erp/devel/pi
Changeset: db6cf35ac8a53ed2514bdf3cec0cee1687ab4cd4
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Thu Mar 26 12:25:43 2020 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/db6cf35ac8a53ed2514bdf3cec0cee1687ab4cd4 [^]

fixed BUG-43532: 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
---
(0118992)
cberner (developer)
2020-04-06 15:49

closed: wrongly reopened

- Issue History
Date Modified Username Field Change
2020-03-20 13:54 guillermogil New Issue
2020-03-20 13:54 guillermogil Assigned To => platform
2020-03-20 13:54 guillermogil Modules => Core
2020-03-20 13:54 guillermogil Triggers an Emergency Pack => No
2020-03-20 13:55 alostale Severity major => minor
2020-03-20 13:55 alostale Type feature request => defect
2020-03-20 13:55 alostale Status new => acknowledged
2020-03-25 12:52 shuehner Note Added: 0118797
2020-03-25 12:59 shuehner Note Added: 0118798
2020-03-25 13:11 shuehner File Added: 43532.diff
2020-03-25 13:13 shuehner Note Added: 0118799
2020-03-26 12:01 alostale Relationship added blocks 0037083
2020-03-26 12:06 alostale Summary Compilation fails in case of an external dtd is used => jrxml translate build step fails if using jasperreport.dtd
2020-03-26 12:06 alostale Description Updated View Revisions
2020-03-26 12:06 alostale Steps to Reproduce Updated View Revisions
2020-03-26 12:06 alostale Proposed Solution updated
2020-03-26 12:07 alostale Description Updated View Revisions
2020-03-26 12:07 alostale Steps to Reproduce Updated View Revisions
2020-03-26 12:07 alostale Proposed Solution updated
2020-03-26 12:07 alostale Assigned To platform => alostale
2020-03-26 12:48 alostale Review Assigned To => caristu
2020-03-26 13:18 alostale Status acknowledged => scheduled
2020-03-30 10:18 hgbot Checkin
2020-03-30 10:18 hgbot Note Added: 0118863
2020-03-30 10:18 hgbot Checkin
2020-03-30 10:18 hgbot Note Added: 0118864
2020-03-30 10:18 hgbot Status scheduled => resolved
2020-03-30 10:18 hgbot Resolution open => fixed
2020-03-30 10:18 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/0ef412c29220602f3c9286809981bb24d2aa76d9 [^]
2020-04-02 08:47 caristu Note Added: 0118911
2020-04-02 08:47 caristu Status resolved => closed
2020-04-02 08:47 caristu Fixed in Version => 3.0PR20Q2
2020-04-06 11:54 hgbot Checkin
2020-04-06 11:54 hgbot Note Added: 0118977
2020-04-06 11:54 hgbot Checkin
2020-04-06 11:54 hgbot Note Added: 0118978
2020-04-06 11:54 hgbot Status closed => resolved
2020-04-06 11:54 hgbot Fixed in SCM revision http://code.openbravo.com/erp/devel/pi/rev/0ef412c29220602f3c9286809981bb24d2aa76d9 [^] => http://code.openbravo.com/erp/devel/pi/rev/db6cf35ac8a53ed2514bdf3cec0cee1687ab4cd4 [^]
2020-04-06 15:49 cberner Note Added: 0118992
2020-04-06 15:49 cberner Status resolved => closed


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker