Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0045729Openbravo ERPY. DBSourceManagerpublic2021-01-13 17:522021-06-11 10:18
shuehner 
shuehner 
normalminorhave not tried
closedfixed 
5
 
PR21Q3PR21Q3 
Core
No
0045729: export.database fails with some views on oracle with: An invalid XML character (Unicode: 0x0) was found in the CDATA section.
Problem was found in one specific environment for 3 specific views.

Running export.database with the module in development containing those views fails with:
     [java] Caused by: org.apache.ddlutils.DdlUtilsException: An invalid XML character (Unicode: 0x0) was found in the CDATA section. : /srv/ci/workspace/mod-simple-ci34.18102/modules/org.openbravo.cashposition/src-db/database/model/views/OBCP_ACTUALS_V.xml
     [java] at org.apache.ddlutils.io.DatabaseIO.readplain(DatabaseIO.java:226)
     [java] at org.openbravo.ddlutils.task.DatabaseUtils.readDatabaseNoChecks(DatabaseUtils.java:300)
     [java] at org.openbravo.ddlutils.task.DatabaseUtils.readDatabaseNoChecks(DatabaseUtils.java:289)
     [java] at org.openbravo.ddlutils.task.DatabaseUtils.readDatabaseNoChecks(DatabaseUtils.java:289)
     [java] at org.openbravo.ddlutils.task.DatabaseUtils.getMergedDatabaseAndInitialize(DatabaseUtils.java:230)
     [java] at org.openbravo.ddlutils.task.DatabaseUtils.readDatabase(DatabaseUtils.java:207)
     [java] at org.openbravo.ddlutils.task.DatabaseUtils.readDatabaseModel(DatabaseUtils.java:450)
     [java] at org.openbravo.ddlutils.task.ExportDatabase.execute(ExportDatabase.java:211)

Technically errors comes from code inside export.database re-reading the just exported xml definition files and failing the the export did write wrong data into them.

Comparing diff of the wrong view to earlier state shows that 1 or 3 0x0 byte '0' are added just after the view definition itself inside the CDATA section.

The attached diff shows the wrong data.

Trigger for when this error is happening + cause of adding 1 or 3 of those bytes is currently unclear.
Problem can be reproduced 100% reliably in one environment.

This code-snapshot file and revision can reproduce the problem:
https://gitlab.com/obcustomers/ob_ob/snapshots/-/blob/a4c6300f70768f2c35e49fe39925f64b2b1d6a4a/Snapshot_Dev_HACK [^]
Clone above code-snapshot
run install.source on oracle
run all modules with type <>'T' into development
run export.database

Probably just exporting this specific module: "org.openbravo.cashposition" is enough to reproduce the problem
No tags attached.
diff oracle-export.database-problem.diff (1,480) 2021-01-13 17:52
https://issues.openbravo.com/file_download.php?file_id=15250&type=bug
xml OBCP_ACTUALS_V.xml (10,722) 2021-01-13 17:53
https://issues.openbravo.com/file_download.php?file_id=15251&type=bug
xml OBCP_CASHPOSDETAIL_INT_V.xml (1,408) 2021-01-13 17:53
https://issues.openbravo.com/file_download.php?file_id=15252&type=bug
xml OBCP_CASHPOSDETAIL_V.xml (1,748) 2021-01-13 17:53
https://issues.openbravo.com/file_download.php?file_id=15253&type=bug
Issue History
2021-01-13 17:52shuehnerNew Issue
2021-01-13 17:52shuehnerAssigned To => platform
2021-01-13 17:52shuehnerFile Added: oracle-export.database-problem.diff
2021-01-13 17:52shuehnerModules => Core
2021-01-13 17:52shuehnerTriggers an Emergency Pack => No
2021-01-13 17:53shuehnerFile Added: OBCP_ACTUALS_V.xml
2021-01-13 17:53shuehnerFile Added: OBCP_CASHPOSDETAIL_INT_V.xml
2021-01-13 17:53shuehnerFile Added: OBCP_CASHPOSDETAIL_V.xml
2021-01-13 17:54shuehnerNote Added: 0125436
2021-06-09 13:54hgbotNote Added: 0129264
2021-06-09 20:02shuehnerTarget Version => PR21Q3
2021-06-09 20:02shuehnerAssigned Toplatform => shuehner
2021-06-10 07:05hgbotNote Added: 0129295
2021-06-10 07:05hgbotNote Added: 0129296
2021-06-11 10:18hgbotResolutionopen => fixed
2021-06-11 10:18hgbotStatusnew => closed
2021-06-11 10:18hgbotFixed in Version => PR21Q3
2021-06-11 10:18hgbotNote Added: 0129394

Notes
(0125436)
shuehner   
2021-01-13 17:54   
The 3 xml files attached are the 3 views triggering the problem (just for easy access. They are contained in the code-snapshot referenced above)
(0129264)
hgbot   
2021-06-09 13:54   
Merge Request created: https://gitlab.com/openbravo/product/dbsm/-/merge_requests/28 [^]
(0129295)
hgbot   
2021-06-10 07:05   
Repository: https://gitlab.com/openbravo/product/dbsm [^]
Changeset: fd92818322bcf48dda05237cfbc28f3ca327ab45
Author: Stefan Huehner <stefan.huehner@openbravo.com>
Date: 2021-06-09T13:44:46+02:00
URL: https://gitlab.com/openbravo/product/dbsm/-/commit/fd92818322bcf48dda05237cfbc28f3ca327ab45 [^]

ISSUE-45729: Workaround reading some views on oracle (extra 0x0 bytes)

Some specific views when having their definition read from the database
fail as they have 1-3 0x0 bytes just after their view body.

That works around strange Oracle behavior (probably caused by
USER_VIEWS.TEXT column we read here having 'LONG' data type and that
datatype has some quirks and is marked 'do not use me' (but used in that
internal ORACLE view).

Apply trim() to the String value read which will strip out any
whitespace (including 0x0) before post-processing it.

We already strip out \n (newlines) from view bodies and even .trim() the
result of the PG translation.

---
M src/org/apache/ddlutils/platform/ModelLoaderBase.java
---
(0129296)
hgbot   
2021-06-10 07:05   
Merge request merged: https://gitlab.com/openbravo/product/dbsm/-/merge_requests/28 [^]
(0129394)
hgbot   
2021-06-11 10:18   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: 5c9721a21dc89e884c13b3bfb31df376e727ffdb
Author: Stefan Huehner <stefan.huehner@openbravo.com>
Date: 2021-06-11T10:17:06+02:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/5c9721a21dc89e884c13b3bfb31df376e727ffdb [^]

fixes ISSUE-47036; fixes ISSUE-45729; fixes ISSUE-47047; fixes ISSUE-28703

dbsm including the fixes for:

ISSUE-47036: Remove lots of obsolete support code for obsolete
    (update.database.mod, ezattributes module, dbmanager.jar references)
ISSUE-45729: export.database fails with some views on oracle with:
    An invalid XML character (Unicode: 0x0) was found in the CDATA section.
ISSUE-47047: Reading tables part of PostgreSQL modelloader could be simplified and speed up
ISSUE-28703: dbmanager.jar & src-db/src removal

---
M src-db/database/lib/dbsourcemanager.jar
---