I'm unable to parse hibernate.cfg.xml and geting
Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.hibernate.org/xsd/orm/cfg", local:"hibernate-configuration"). Expected elements are <{}hibernate-configuration> It can be something with xml parser, it seams like it uses stax under the hood. We are on hibernate 5.2.3. The header of our hibernate.cfg.xml file is correct I tried both Xsd
<?xml version="1.0" encoding='utf-8'?> <hibernate-configuration xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <session-factory> and DTD
<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> Both have the same error. I must be something with the parser.
UPDATE I have fixed the question code was not properly visible. I'm sure the XML is valid XML.
UPDATE 2 I start to get some clues. It can be caused by running the code as junit powermock test. Specifically com.sun.xml.internal.stream.XMLEventReaderImpl class reading the file, is loaded by MockClassLoader.
UPDATE 3 They solved it here by taming powermock a little b
@PowerMockIgnore({ "javax.xml.*", "org.xml.sax.*" }) Now I have different error hope I'm on the right track.
java.lang.LinkageError: loader constraint violation: when resolving overridden method "com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Lorg/w3c/dom/Node;)Ljava/lang/Object;" the class loader (instance of org/powermock/core/classloader/MockClassLoader) of the current class, com/sun/xml/internal/bind/v2/runtime/unmarshaller/UnmarshallerImpl, and its superclass loader (instance of <bootloader>), have different Class objects for the type org/w3c/dom/Node used in the signature That is resolved here by adding additional classes to the
@PowerMockIgnore({ "javax.xml.*", "org.xml.sax.*", "com.sun.xml.*", "com.sun.org.*"})
<or>symbolhibernate.cfg.xml, at least part.