2

I am trying to run a sample Hibernate program which will insert a values into database, But I am getting below error, where I already included slf4j JAR in my build path please help me fixing this issue.

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2246)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:2158)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:2137)
    at org.test1.HibernateTest.main(HibernateTest.java:18)
Caused by: org.dom4j.DocumentException: Error on line 2 of document  : The document type declaration for root element type "hibernate-configuration" must end with '>'. Nested exception: The document type declaration for root element type "hibernate-configuration" must end with '>'.
    at org.dom4j.io.SAXReader.read(SAXReader.java:482)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2238)
    ... 3 more
0

3 Answers 3

3

The error is pretty explicit, at some point in the file hibernate.cfg.xml, you made a mistake closing one XML tag, possibly a > character is missing (perhaps in the element hibernate-configuration?). Check the file with a good text editor, it'll help you find where the problem is.

Sign up to request clarification or add additional context in comments.

Comments

1

I think you forgot to close the '>' properly it's just a compilation error

Comments

0

You may have not mentioned the doctype in the hibernate.cfg.xml

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration>

Use the above syntax, it should work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.