Discussions

General J2EE: Getting Hibernate to run without an App Server

  1. Hello. I'm trying to get Hibernate to work without an app server, but I'm having a lot of problems and I really fail to see how this couldn't work. I really need this to work so I can test my service layer without using the app server (since that's just a pain and I refuse to do that :/)

    Here is the exception I get when I run my test case:

    java.lang.ExceptionInInitializerError
    at cirrus.hibernate.Hibernate.<clinit>(Hibernate.java:35)
    at com.egervari.website.test.services.WebpageServiceTest.setUp(WebpageServiceTest.java:27)
    at junit.framework.TestCase.runBare(TestCase.java:125)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at junit.swingui.TestRunner$16.run(TestRunner.java:623)
    Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JCategoryLog does not implement Log
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:555)
    at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:289)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:409)
    at cirrus.hibernate.type.NullableType.<clinit>(NullableType.java:22)
    ... 12 more
    Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JCategoryLog does not implement Log
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:420)
    at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:548)
    ... 15 more
    Caused by: org.apache.commons.logging.LogConfigurationException: Class org.apache.commons.logging.impl.Log4JCategoryLog does not implement Log
    at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:416)
    ... 16 more

    Here is the code I'm using the initialize hibernate. The configuration is all there and I've been using Hibernate for a long time with Resin, so that just makes this even harder to fix :/

        protected void setUp() {
            try {
                //Hibernate.configure(); (I've tried both)
                Datastore ds = Hibernate.createDatastore();
                ds.storeFile( "d:/java/com.egervari.website/etc/hibernate/All.hbm.xml" );
                SessionFactory factory = ds.buildSessionFactory();

                DriverManager.registerDriver( new com.mysql.jdbc.Driver() );
                Connection connection = DriverManager.getConnection( "jdbc:mysql://localhost:3306/egervari",
                    "root", "password" );

                Session session = factory.openSession( connection );
                HibernateGateway hibernateSession = new HibernateGateway( session );

                service = new WebpageService( hibernateSession );
            } catch( HibernateException e ) {
                e.printStackTrace();
            } catch( SQLException e ) {
                e.printStackTrace();
            } catch( java.lang.ExceptionInInitializerError e ) {
                e.printStackTrace();
            }
        }
  2. Hi there I'm having the same problem. Did you find a solution for this?

    Many thanks,
    Max
  3. I could get rid of this error message when I changed the jars in the build path to their respective latest versions. Hope it would solve your issue too