[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5329) NoClassDefFoundError when using Hibernate 3.5 with J2SE 1.4 because of a wrong catch block

Francesco Poli (JIRA) noreply at atlassian.com
Wed Jun 23 02:39:09 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=37540#action_37540 ] 

Francesco Poli commented on HHH-5329:
-------------------------------------

Emmanuel, I'm working with a J2SE 1.4 included in Bea WebLogic 8.1; the stack trace is the following:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [hibernate-definitions.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: java/util/concurrent/ConcurrentMap
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
	... 62 more
Caused by: java.lang.NoClassDefFoundError: java/util/concurrent/ConcurrentMap
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
	at java.lang.Class.getConstructor0(Class.java:1930)
	at java.lang.Class.getConstructor(Class.java:1027)
	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:204)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1385)
	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
	at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
	... 72 more

So, the error occurrs not on line 204:

Constructor constructor = concurrentStatsClass.getConstructor(new Class[]{SessionFactoryImplementor.class});

It's not a problem of instantiation, it's a linker error.


> NoClassDefFoundError when using Hibernate 3.5 with J2SE 1.4 because of a wrong catch block
> ------------------------------------------------------------------------------------------
>
>                 Key: HHH-5329
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5329
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.5.0-Final
>         Environment: Hibernate 3.5, Java SE 1.4 or J2EE 1.3
>            Reporter: Francesco Poli
>            Assignee: Emmanuel Bernard
>            Priority: Blocker
>             Fix For: 3.5.x
>
>
> In org.hibernate.impl.SessionFactoryImpl is done this check when looking for concurrent classes during the creation of the SessionFactory:
> Statistics concurrentStatistics = null;
> try {
> 	Class concurrentStatsClass = ReflectHelper.classForName("org.hibernate.stat.ConcurrentStatisticsImpl");
> 	Constructor constructor = concurrentStatsClass.getConstructor(new Class[]{SessionFactoryImplementor.class});
> 	concurrentStatistics = (Statistics) constructor.newInstance(new Object[]{this});
> 	log.trace("JDK 1.5 concurrent classes present");
> } catch (Exception noJava5) {
> 	log.trace("JDK 1.5 concurrent classes missing");
> }
> But what is thrown is a NoClassDefFoundError, which is not an Exception.
> As a consequence, the catch block won't work and the error is propagated to the upper levels of the application.
> I suggest to modify the catch arguments to match the correct type of the thrown object.
> Thank you.
> Bye
> Francesco Poli

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list