huahsin68
huahsin68

Reputation: 6989

Does Hibernate 3 work under Tomcat 7?

I have a HibernateUtil class that initialize a SessionFactory during its initialization. Below is the snapshot of the code that do the initialization.

public class HibernateUtil {

  ...

  static {
    try {
      if (cacheFactory.get("factory") == null) {
        sessionFactory = new Configuration().configure().buildSessionFactory();
        cacheFactory.put("factory", sessionFactory);
      }
      else {
        sessionFactory = (SessionFactory) cacheFactory.get("factory");
      }

    } 
    catch (HibernateException ex) {
       throw new RuntimeException(ex.getMessage(), ex);
    }
  }
}

I tested this code run under JDK6 and WAS8 environment then it is working fine. But when I moved to Tomcat7 with JDK6 then it will failed at buildSessionFactory(). The Hibernate version that I'm using is 3.6.10.Final. I'm just curious whether Hibernate 3 doesn't support in Tomcat 7?

This is the full stack trace for your reference:

javax.servlet.ServletException: Could not initialize class org.huahsin.util.hibernate.HibernateUtil
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:323)
    org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357)
    org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
    org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
    org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
    org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
    org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
    org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
    org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
    org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)
    org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
    org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
    org.springframework.security.ui.webapp.DefaultLoginPageGeneratingFilter.doFilterHttp(DefaultLoginPageGeneratingFilter.java:86)
    org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
    org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
    org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:277)
    org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
    org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
    org.springframework.security.ui.preauth.AbstractPreAuthenticatedProcessingFilter.doFilterHttp(AbstractPreAuthenticatedProcessingFilter.java:69)
    org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
    org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
    org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
    org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
    org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
    org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
    org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
    org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
    org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
    org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
    org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
    org.huahsin.security.Initializer.doFilter(Initializer.java:65)

Upvotes: 0

Views: 487

Answers (1)

Aaron Digulla
Aaron Digulla

Reputation: 328760

Hibernate is supported like any other Java-based framework. Check the log for other errors.

Also the code in question is related to Hibernate but org.huahsin is probably not something from the Hibernate project.

Upvotes: 1

Related Questions