org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.springframework.orm.hibernate4.SpringSessionContext]

Spring JIRA | Maksym Gryevtsov | 4 years ago
  1. 0

    If you try to deploy the application on JBoss 7 using the built-in hibernate, you got this stack trace: 15:32:46,919 ERROR [org.hibernate.internal.SessionFactoryImpl] (MSC service thread 1-1) HHH000302: Unable to construct current session context [org.springframework.orm.hibernate4.SpringSessionContext]: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.springframework.orm.hibernate4.SpringSessionContext] at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141) [hibernate-core-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.internal.SessionFactoryImpl.buildCurrentSessionContext(SessionFactoryImpl.java:1491) [hibernate-core-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:502) [hibernate-core-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1746) [hibernate-core-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1784) [hibernate-core-4.1.6.Final.jar:4.1.6.Final] at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:242) [spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE] at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:372) [spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE] at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:357) [spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE] After digging the code it looks like that the spring initialized hibernate in a way that "hibernate.classLoader.application" property is not used. As result hibernate try to use local classloader for loading class defined in "hibernate.current_session_context_class"

    Spring JIRA | 4 years ago | Maksym Gryevtsov
    org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.springframework.orm.hibernate4.SpringSessionContext]
  2. 0

    If you try to deploy the application on JBoss 7 using the built-in hibernate, you got this stack trace: 15:32:46,919 ERROR [org.hibernate.internal.SessionFactoryImpl] (MSC service thread 1-1) HHH000302: Unable to construct current session context [org.springframework.orm.hibernate4.SpringSessionContext]: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.springframework.orm.hibernate4.SpringSessionContext] at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141) [hibernate-core-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.internal.SessionFactoryImpl.buildCurrentSessionContext(SessionFactoryImpl.java:1491) [hibernate-core-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:502) [hibernate-core-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1746) [hibernate-core-4.1.6.Final.jar:4.1.6.Final] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1784) [hibernate-core-4.1.6.Final.jar:4.1.6.Final] at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:242) [spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE] at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:372) [spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE] at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:357) [spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE] After digging the code it looks like that the spring initialized hibernate in a way that "hibernate.classLoader.application" property is not used. As result hibernate try to use local classloader for loading class defined in "hibernate.current_session_context_class"

    Spring JIRA | 4 years ago | Maksym Gryevtsov
    org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.springframework.orm.hibernate4.SpringSessionContext]
  3. 0

    Error 503 when using mysql

    GitHub | 3 years ago | enmaku
    org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [org.hibernate.dialect.MYSQL5InnoDBDialect]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    hibernate microsoft sql server crud

    Stack Overflow | 4 years ago | user1723988
    org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver com.microsoft.sqlserver.jdbc.SQLServerDriver class not found
  6. 0

    Why JBoss can not find MySQL Driver under Hibernate + JPA

    Stack Overflow | 3 years ago | Gandroid
    org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver com.mysql.jdbc.Driver could not be loaded

  1. regisso 1 times, last 6 months ago
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.hibernate.service.classloading.spi.ClassLoadingException

    Unable to load class [org.springframework.orm.hibernate4.SpringSessionContext]

    at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName()
  2. Hibernate
    Configuration.buildSessionFactory
    1. org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:141)[hibernate-core-4.1.6.Final.jar:4.1.6.Final]
    2. org.hibernate.internal.SessionFactoryImpl.buildCurrentSessionContext(SessionFactoryImpl.java:1491)[hibernate-core-4.1.6.Final.jar:4.1.6.Final]
    3. org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:502)[hibernate-core-4.1.6.Final.jar:4.1.6.Final]
    4. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1746)[hibernate-core-4.1.6.Final.jar:4.1.6.Final]
    5. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1784)[hibernate-core-4.1.6.Final.jar:4.1.6.Final]
    5 frames
  3. Spring ORM
    LocalSessionFactoryBean.afterPropertiesSet
    1. org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:242)[spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    2. org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:372)[spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    3. org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:357)[spring-orm-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    3 frames