Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7948543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:45:06+00:00 2026-06-04T01:45:06+00:00

i am trying to make a 3rd party simple standalone/swing application that uses hibernate

  • 0

i am trying to make a 3rd party simple standalone/swing application that uses hibernate to connect on database for another application, so here’s what i did:

1- Jars used:

hibernate-core-3.5.1-Final
hibernate-entitymanager-3.5.1-Final
hibernate-jpa-2.0-api-1.0.0.Final
hibernate-annotations-3.5.1-Final
hibernate-commons-annotations-3.2.0.Final
dom4j-1.6.1
slf4j-api-1.6.4
slf4j-log4j12-1.6.4
log4j-1.2.16.jar
commons-collections-3.2
jta-1.1
mysql-connector-java-5.1.14 (or compatible connector with your DB)
commons-logging-1.1.1
commons-collections-3.2

2- hibernate.cfg.xml (it’s inside the src folder):

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
   <session-factory>

            <property name="show_sql">true</property>
            <property name="format_sql">true</property>
            <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
            <property name="connection.url">jdbc:mysql://127.0.0.1:3306/myapp</property>
            <property name="connection.username">myuser</property>
            <property name="connection.password">mypass</property>
            <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
            <property name="current_session_context_class">thread</property>

   </session-factory>
</hibernate-configuration>

3- SessionFactoryHelper:

public class SessionFactoryHelper {

    private static final SessionFactory sessionFactory;

    static {
        try {
            /*
             * Build a SessionFactory object from session-factory configuration
             * defined in the hibernate.cfg.xml file. In this file we register
             * the JDBC connection information, connection pool, the hibernate
             * dialect that we used and the mapping to our hbm.xml file for each
             * POJO (Plain Old Java Object).
             */
            sessionFactory = new Configuration().configure()
                    .buildSessionFactory();
        } catch (Throwable e) {
            System.err.println("Error in creating SessionFactory object."
                    + e.getMessage());
            throw new ExceptionInInitializerError(e);
        }
    }

    /*
     * A static method for other application to get SessionFactory object
     * initialized in this helper class.
     */
    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }
}

4- Sample Query:

Session session = SessionFactoryHelper.getSessionFactory()
            .getCurrentSession();
    session.beginTransaction();
    int count = (Integer) session.createSQLQuery(
            "select count(*) from users").uniqueResult();
    session.getTransaction().commit();
    System.out.println("Users Count: " + count);

when running the application, i gets the following exception:

Error in creating SessionFactory object.invalid configuration
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.xeno.xecamp.desktopManagement.SessionFactoryHelper.<clinit>(SessionFactoryHelper.java:24)
    at com.myapp.Main.main(Main.java:9)
Caused by: org.hibernate.MappingException: invalid configuration
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1579)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1520)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1506)
    at com.xeno.xecamp.desktopManagement.SessionFactoryHelper.<clinit>(SessionFactoryHelper.java:19)
    ... 1 more
Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:250)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:626)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3103)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:922)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    at org.dom4j.io.SAXReader.read(SAXReader.java:465)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1576)
    ... 4 more

can anyone please tell me what’s wrong with my configuration ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:45:08+00:00Added an answer on June 4, 2026 at 1:45 am

    The problem is not related to Hibernate at all but to the XML structure.

    The SAX Reader is set by Hibernate to use validation (org.hibernate.util.XMLHelper#createSAXReader(String,List,EntityResolver)

    It goes more less like this:

    SAXParserFactory factory = SAXParserFactory.newInstance();
        factory.setValidating(true);
        factory.setNamespaceAware(true);
    

    Java dosc says

    Method setValidating(boolean) – equests DTD validation and causes a failure if no DTD exists. If you only want schema validation and not DTD validation then use setValidating(false).

    Your error says clear:

    Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.

    In this tutorial you will find all required information about hibernate conf file.

    to fix it you will need to add:

    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a standalone (3rd party) app that I'm trying to launch using a
Here’s the situation: We have a 3rd party application that intermittently displays an error
Trying to make a toggle button that hides/shows the right window/pane. Here is a
I'm trying to make use of a function which comes in a 3rd party
Trying to make a custom :confirm message for a rails form that returns data
Trying to make a simple program to catalogue books. Something like this, for example:
Trying to make a simple program to catalogue books. Something like this, for example:
Trying to make simple minesweeper game in python, but have one problem. I have
I have a 3rd party library that's written in C. It exports all of
I'm trying to access a 3rd party api over http using jquery .ajax (or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.