Yoav
Yoav

Reputation: 645

HibernateUtil initializig error on the webserver

I hav a webserver and when I try to use the hibernate util I get an excpetion (returned to the client):

SoapFault - faultcode: 'soapenv:Server' faultstring: 'Could not initialize class com.test.data.HibernateUtil' faultactor: 'null' detail: org.kxml2.kdom.Node@4054db90

It worked fine on my local pc. How can I know what is the reason for it?

I have the following code:
public class HibernateUtil {
    private static final SessionFactory sessionFactory;

    static {
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            sessionFactory = new Configuration().configure().buildSessionFactory();
        } catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
//            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }
}

Really really needs help with this... can supply any code needed.

I have updated the HibernateUtil without the try/catch, now I get the exact excpeion:

SoapFault - faultcode: 'soapenv:Server' faultstring: 'org.slf4j.impl.StaticLoggerBinder.getSingleton()Lorg/slf4j/impl/StaticLoggerBinder;' faultactor: 'null' detail: org.kxml2.kdom.Node@4054b2c0

But the jar is deployed....

Upvotes: 0

Views: 1702

Answers (1)

mprabhat
mprabhat

Reputation: 20323

From my experience with static block to initialize sessionFactory your issue lies in this line of code:

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

Looks like it is not able to get the datasource while building the sessionFactory.

Can you log the exception uncomment this line and see whats being printed:

 System.err.println("Initial SessionFactory creation failed." + ex);

Upvotes: 1

Related Questions