Currently, my project is using xdoclet (2.0.1) and hibernate (4.3.10) to generate *.hbm.xml, and export SQL. I have tried to upgrade these libraries to the latest version, especially for hibernate to version 5.4. I can generate hbm files with the new version of hibernate, but then it is failed to export schema using SchemaExportTask with the following error. I assume that I need to upgrade other libraries to make it work, but I have not figured it out yet. Any suggestions for this issue, I really appreciate.
Error performing export: Could not parse mapping document: D:…\model\AclTemplate.hbm.xml (FILE)
Actually, I did add -verbose or -debug option when executing ant target, but I only got the error as I mentioned above. That is the reason I have no clue to investigate further, everything works properly if using hibernate-core-4.x. I have read some migration documents, and there are some constructors of SchemaExport class that have been deprecated, so I assume it might be the issue, is that correct? Could we still use SchemaExportTask together with hibernate 5.x, right ? Thanks for your response.
I don’t know how to help you if you can’t properly determine a stack trace with the way you invoke Hibernate. You can surely use SchemaExportTask with 5.x, but the error clearly says that there was an error during parsing of the hbm.xml, so you will have to look into that.
Why don’t you debug into SchemaExportTask and try to find out what the error is about?
Below is the stack trace for generating hbm and schema export. There are two ant targets, including java2hbm and build.db.schema. The hbm files are generated successfully and placed in the mapping directory, then the next ant target build.db.schema will export to ddl. But I got the issue above, I’m debugging the SchemaExportTask as @beikov 's suggestion, but for now, I have not found the root cause yet. I would appreciate your suggestions. Thanks
java2hbm:
[echo] +++ Generate *.hbm.xml sybase mapping files for model classes +++
[delete] Deleting directory D:\src\com\example\mapping\sybase
[mkdir] Created dir: D:\src\com\example\mapping\sybase
[mkdir] Created dir: D:\src\com\example\hbm_temp
[copy] Copying 1 file to D:\src\com\example\build\conf
[copy] Copying 1 file to D:\src\com\example\build\conf
[copy] Copying 1 file to D:\src\com\example\build\conf
[echo] Generating *.hbm.xml files
[hibernatedoclet] Running org.xdoclet.plugin.hibernate.HibernateMappingPlugin
[hibernatedoclet] * Generate mapping for 'AclTemplate' entity
[hibernatedoclet] * Generate mapping for 'AclTemplateElement' entity
[hibernatedoclet] * Generate mapping for 'AddressBlock' entity
[hibernatedoclet] * Generate mapping for 'AddressRange' entity
[hibernatedoclet] * Generate mapping for 'AddressTemplate' entity
[hibernatedoclet] ...
[copy] Copying 264 files to D:\src\com\example\mapping\sybase
[copy] Copying 264 files to D:\src\com\example\build\WEB-INF\classes
[delete] Deleting directory D:\src\com\example\hbm_temp
[echo] --- *.hbm.xml mapping generation complete for sybase---
build.db.schema:
[echo] Calling build.schema with params:
[echo] dbtype="sybase"
[echo] userName="admin"
[echo] password="admin"
[echo] serverName="SYBASE"
[echo] table.sql="table.sql"
[echo] const.sql="drop_constraint.sql"
[echo] sqldir="D:\src\com\example/sql/sybase"
[echo] propFile="D:\src\com\example/conf/hibernate.properties"
[echo]
[echo] Building DB Schema for sybase
[echo] Generating Hibernate Schema for sybase to D:\src\com\example/sql/sybase/table.sql using D:\src\com\example/conf/hibernate.properties
[schemaexport] ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
BUILD FAILED
D:\src\com\example\build.xml:3296: The following error occurred while executing this line:
D:\src\com\example\build.xml:830: The following error occurred while executing this line:
D:\src\com\example\build.xml:608: Error performing export : Could not parse mapping document: D:\src\com\example\mapping\sybase\model\AclTemplate.hbm.xml (FILE)
@tqdkhoa : i checked the error details and it looks like the error has initiated from [schemaexport] ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console…
and lower down it says error parsing xml.Just in case you want to fetch the actual cause for error, You can write a code in java where-in you can pass the hbmxml file to get the detailed stacktrace if its failing while parsing the file or somewhere else.
Alternatively Hibernate also provide the test-case template which you can fork and supply the same hbmxl file and run the test-case to check what SQL Queries are generated.
Reference Test-Case template to check the difference in versions 4 and 5 are located at