1

I am making hibernate application using ubuntu trying to connect hibernate with mysql but this exception is arising. What should I have to do now to solve this?

Exception in thread "main" org.hibernate.HibernateException: Error accessing stax stream
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:107)
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:65)
at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:57)
at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:163)
at org.hibernate.cfg.Configuration.configure(Configuration.java:259)
at test.Client.main(Client.java:18)
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[8,16]
Message: The processing instruction target matching "[xX][mM][lL]" is not allowed.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:598)
at com.sun.xml.internal.stream.XMLEventReaderImpl.peek(XMLEventReaderImpl.java:275)
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:103)
... 5 more
ngm
  • 7,277
  • 1
  • 53
  • 62
Sagar Bhandari
  • 219
  • 2
  • 8

2 Answers2

3

You have illegal symbols in hibernate.cfg.xml, probably spaces. Refer this for details

Error: The processing instruction target matching “[xX][mM][lL]” is not allowed.

Community
  • 1
  • 1
v.ladynev
  • 19,275
  • 8
  • 46
  • 67
0

Here problem is hibernate could not locate your hibernate configuration file.

Hibernate default locate your Hibernate Configuration file in your resource folder.

If your Hibernate.cfg.xml file in your resource folder then check below line must be exist in your HibernateUtil class(There you configured hibernate SessionFactory).

sessionFactory = new Configuration().configure().buildSessionFactory();

If your Hibernate.cfg.xml file in differnt location the add below line in your HibernateUtil class.

sessionFactory = new Configuration().configure("/Path of your configuration file").buildSessionFactory();