javax.xml.bind.UnmarshalException: unexpected element (uri:"http://www.hibernate.org/xsd/orm/hbm")

Hi,

We are getting unmarshalException after upgarding from hibernate-5.4.4 to 5.4.24 while loading third party jars . During debugging we noticed that none of hbm.xml files included in third party jars are getting loaded and getting unmarshalException.

Here is the snapshot of exception:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘sessionFactory’ defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.boot.InvalidMappingException: Could not parse mapping document: null (INPUT_STREAM)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1794)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$1144/0x00000000d3dc3fe0.getObject(Unknown Source)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:330)
… 209 more
Caused by: org.hibernate.boot.InvalidMappingException: Could not parse mapping document: null (INPUT_STREAM)
at org.hibernate.boot.jaxb.internal.InputStreamXmlSource.doBind(InputStreamXmlSource.java:46)
at org.hibernate.boot.jaxb.internal.InputStreamXmlSource.doBind(InputStreamXmlSource.java:38)
at org.hibernate.boot.spi.XmlMappingBinderAccess.bind(XmlMappingBinderAccess.java:94)
at org.hibernate.boot.MetadataSources.addInputStream(MetadataSources.java:381)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:475)
at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:509)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1853)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1790)
… 217 more
Caused by: org.hibernate.boot.MappingException: Unable to perform unmarshalling at line number -1 and column -1. Message: unexpected element (uri:“Index of /xsd/orm/hbm - Hibernate”, local:“hibernate-mapping”). Expected elements are <{}hibernate-mapping> : origin(null)
at org.hibernate.boot.jaxb.internal.AbstractBinder.jaxb(AbstractBinder.java:177)
at org.hibernate.boot.jaxb.internal.MappingBinder.doBind(MappingBinder.java:61)
at org.hibernate.boot.jaxb.internal.AbstractBinder.doBind(AbstractBinder.java:102)
at org.hibernate.boot.jaxb.internal.AbstractBinder.bind(AbstractBinder.java:57)
at org.hibernate.boot.jaxb.internal.InputStreamXmlSource.doBind(InputStreamXmlSource.java:43)
… 224 more
Caused by: javax.xml.bind.UnmarshalException

  • with linked exception:
    [javax.xml.bind.UnmarshalException: unexpected element (uri:“Index of /xsd/orm/hbm - Hibernate”, local:“hibernate-mapping”). Expected elements are <{}hibernate-mapping>]
    at com.ibm.jtc.jax.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:507)
    at com.ibm.jtc.jax.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:474)
    at com.ibm.jtc.jax.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:443)
    at com.ibm.xml.xlxp2.jaxb.unmarshal.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:295)
    at org.hibernate.boot.jaxb.internal.AbstractBinder.jaxb(AbstractBinder.java:171)
    … 228 more

Please advise.

Thanks,
Bhau

Can you post an excerpt of these hbm.xml files here so we can understand why it fails to parse them?