Exception in thread "main" java.lang.ExceptionInInitializerError 这是啥错误,求教
2017-7-4 20:06:39 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.1.5.Final}
2017-7-4 20:06:39 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
2017-7-4 20:06:39 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
2017-7-4 20:06:39 org.hibernate.boot.jaxb.internal.stax.LocalXmlResourceResolver resolveEntity
WARN: HHH90000012: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/hibernate-configuration. Use namespace http://www.hibernate.org/dtd/hibernate-configuration instead. Support for obsolete DTD/XSD namespaces may be removed at any time.
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.imooc.entity.Test.findStudentsByGrade(Test.java:32)
at com.imooc.entity.Test.main(Test.java:14)
Caused by: 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 org.hibernate.cfg.Configuration.configure(Configuration.java:245)
at com.imooc.util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 2 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[3,2]
Message: The markup in the document preceding the root element must be well-formed.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:588)
at com.sun.xml.internal.stream.XMLEventReaderImpl.peek(XMLEventReaderImpl.java:271)
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:103)
... 8 more
package com.imooc.entity;
import java.util.Set;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.imooc.util.HibernateUtil;
public class Test {
public static void main(String[] args) {
//add();
findStudentsByGrade();
}
public static void add(){
Grade g=new Grade("zl班", "私有");
Student stu1=new Student("zl学生", '女');
Student stu2=new Student("李四", '男');
g.getStudents().add(stu1);
g.getStudents().add(stu2);
Session session=HibernateUtil.getSession();
Transaction tx=session.beginTransaction();
session.save(g);
session.save(stu1);
session.save(stu2);
tx.commit();
HibernateUtil.closeSession(session);
}
public static void findStudentsByGrade(){
Session session=HibernateUtil.getSession();
Grade grade=session.get(Grade.class, 1);
System.out.println(grade.getGname()+","+grade.getGdesc());
Set<Student>students=grade.getStudents();
for(Student stu:students){
System.out.println(stu.getSname()+","+stu.getSex());
}
}
}