Announcement Announcement Module
Collapse
No announcement yet.
[org.hibernate.cfg.AnnotationConfiguration]: Constructor threw exception; Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [org.hibernate.cfg.AnnotationConfiguration]: Constructor threw exception;

    Hi,

    I am building a JBOSS Resteasy webservice. It has integration with spring and hibernate. And the database used is Oracle 11g.

    As soon as I start the server I get the following exception: (the connection to db is failing)

    SEVERE: Exception sending context initialized event to listener instance of class org.jboss.resteasy.plugins.spring.SpringContextLoa derListener
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'someClassDaoCRUD' defined in class path resource [spring/my_project/dao-beans.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [spring/daoContext.xml]: Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.hibernate.cfg.AnnotationConfiguration]: Constructor threw exception; nested exception is java.lang.NoSuchFieldError: INSTANCE
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:328)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:106)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1325)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:1086)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 91)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:288 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplic ationContext.finishBeanFactoryInitialization(Abstr actApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:425)
    at org.springframework.web.context.ContextLoader.crea teWebApplicationContext(ContextLoader.java:276)
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:197)
    at org.springframework.web.context.ContextLoaderListe ner.contextInitialized(ContextLoaderListener.java: 47)
    at org.jboss.resteasy.plugins.spring.SpringContextLoa derListener.contextInitialized(SpringContextLoader Listener.java:44)
    at org.apache.catalina.core.StandardContext.listenerS tart(StandardContext.java:4723)
    at org.apache.catalina.core.StandardContext$1.call(St andardContext.java:5226)
    at org.apache.catalina.core.StandardContext$1.call(St andardContext.java:5221)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unkn own Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [spring/daoContext.xml]: Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.hibernate.cfg.AnnotationConfiguration]: Constructor threw exception; nested exception is java.lang.NoSuchFieldError: INSTANCE
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 91)
    at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
    at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:288 )
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:322)
    ... 24 more
    Caused by: org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.hibernate.cfg.AnnotationConfiguration]: Constructor threw exception; nested exception is java.lang.NoSuchFieldError: INSTANCE
    at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:141)
    at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:104)
    at org.springframework.orm.hibernate3.LocalSessionFac toryBean.newConfiguration(LocalSessionFactoryBean. java:818)
    at org.springframework.orm.hibernate3.LocalSessionFac toryBean.buildSessionFactory(LocalSessionFactoryBe an.java:549)
    at org.springframework.orm.hibernate3.AbstractSession FactoryBean.afterPropertiesSet(AbstractSessionFact oryBean.java:211)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1477)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1417)
    ... 31 more
    Caused by: java.lang.NoSuchFieldError: INSTANCE
    at org.hibernate.type.BasicTypeRegistry.<init>(BasicT ypeRegistry.java:94)
    at org.hibernate.type.TypeResolver.<init>(TypeResolve r.java:59)
    at org.hibernate.cfg.Configuration.<init>(Configurati on.java:250)
    at org.hibernate.cfg.Configuration.<init>(Configurati on.java:302)
    at org.hibernate.cfg.AnnotationConfiguration.<init>(A nnotationConfiguration.java:103)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:126)
    ... 37 more



    The session factory class that is mentioned is:

    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotati on.AnnotationSessionFactoryBean"
    lazy-init="true">
    <property name="dataSource"><ref local="dataSource"/></property>
    <property name="annotatedClasses">
    <list>
    <value>com.SomeClass</value>
    </list>
    </property>

    </bean>

    I am using 'hibernate.dialect=org.hibernate.dialect.Oracle10g Dialect' and following is a list of jars being used:

    asm-3.3.1.jar
    cglib-2.2.2.jar
    commons-collections-3.2.1.jar
    commons-dbcp-1.2.1.jar
    commons-logging-1.1.1.jar
    commons-pool-1.2.jar
    dom4j-1.6.1.jar
    hibernate-annotations-3.3.1.GA.jar
    hibernate-commons-annotations-3.2.0.Final.jar
    hibernate-core-3.6.3.Final.jar
    hibernate-entitymanager-3.4.0.GA.jar
    hibernate-jpa-2.0-api-1.0.0.Final.jar
    javassist-3.12.1.GA.jar
    jaxrs-api-2.2.1.GA.jar
    jta-1.1.jar
    log4j-1.2.16.jar
    ojdbc6.jar
    org.springframework.asm-3.0.5.RELEASE.jar
    org.springframework.beans-3.0.5.RELEASE.jar
    org.springframework.context-3.0.5.RELEASE.jar
    org.springframework.context.support-3.0.5.RELEASE.jar
    org.springframework.core-3.0.5.RELEASE.jar
    org.springframework.expression-3.0.5.RELEASE.jar
    org.springframework.jdbc-3.0.5.RELEASE.jar
    org.springframework.orm-3.0.5.RELEASE.jar
    org.springframework.transaction-3.0.5.RELEASE.jar
    org.springframework.web-3.0.5.RELEASE.jar
    org.springframework.web.servlet-3.0.5.RELEASE.jar
    persistence-api-1.0.2.jar
    resteasy-jaxb-provider-2.2.1.GA.jar
    resteasy-jaxrs-2.2.1.GA.jar
    resteasy-jettison-provider-2.2.1.GA.jar
    resteasy-spring-2.2.1.GA.jar
    scannotation-1.0.3.jar
    slf4j-api-1.6.1.jar
    spring-hibernate3-2.0.5.jar


    Not exactly sure what is going wrong here. Please can somebody help me out.

  • #2
    1st are you sure all those hibernate JARs are compatible with each other. Over the period of time 3.2.x came out and 3.6.x a number of JARs were renamed/repackaged. I would urge you to start with hibernate-core-3.6.3.Final.jar and verify compatibilitiate. Or you could just temporarly remove the 2 JARs hibernate*annotations*jar and see if your application still works.

    What is spring-hibernate3-2.0.5.jar ? If it comes from Spring then why does it not follow the same JAR naming as the others org.springframework.* ?

    Take a look inside persistence-api-1.0.2.jar and hibernate-jpa-2.0-api-1.0.0.Final.jar I think you can delete persistence-api-1.0.2.jar.

    In fact go and revalidate the existance of every JAR.

    Comment


    • #3
      Thank you for that suggestion dlmiles.

      I checked each and every jar and found that there were jar conflicts happening due to versions. Here are the list of jars that works:

      commons-collections-3.2.1.jar
      commons-dbcp-1.4.jar
      commons-logging-1.1.1.jar
      commons-pool-1.5.6.jar
      dom4j-1.6.1.jar
      hibernate-commons-annotations-3.2.0.Final.jar
      hibernate-core-3.6.7.Final.jar
      hibernate-jpa-2.0-api-1.0.1.Final.jar
      javassist-3.12.1.GA.jar
      jaxb-impl-2.1.11.jar
      log4j-1.2.16.jar
      ojdbc6-11.2.0.jar
      resteasy-jaxb-provider-2.2.1.GA.jar
      resteasy-jaxrs-2.2.1.GA.jar
      resteasy-jettison-provider-2.2.1.GA.jar
      resteasy-spring-2.2.1.GA.jar
      scannotation-1.0.3.jar
      slf4j-api-1.6.1.jar
      spring-aop-3.0.6.RELEASE.jar
      spring-asm-3.0.6.RELEASE.jar
      spring-beans-3.0.6.RELEASE.jar
      spring-context-3.0.6.RELEASE.jar
      spring-context-support-3.0.6.RELEASE.jar
      spring-core-3.0.6.RELEASE.jar
      spring-expression-3.0.6.RELEASE.jar
      spring-jdbc-3.0.6.RELEASE.jar
      spring-orm-3.0.6.RELEASE.jar
      spring-oxm-3.0.6.RELEASE.jar
      spring-tx-3.0.6.RELEASE.jar
      spring-web-3.0.6.RELEASE.jar

      Comment


      • #4
        i have the same problem

        Comment


        • #5
          Originally posted by White_King View Post
          i have the same problem
          Hi White_King,

          Were you able to resolve your issue?

          Comment

          Working...
          X