Announcement Announcement Module
Collapse
No announcement yet.
Error creating bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error creating bean

    Hello,

    Maybe someone can help me...
    I have the following error, when I run my webapplication on Jboss.
    Everything works fine when I run unit tests in eclipse. But when I run the application via my webbrowser i am getting those errors ???



    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'userDao' defined in class path resource [daoApplicationContext.xml]: Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.HibernateException: could not configure from URL: file:/C:/Program%20Files/jboss-4.0.2/server/default/tmp/deploy/tmp20341multilibrarian-exp.war/WEB-INF/classes/hibernate.cfg.xml

    org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:180)
    org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:105)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1013)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:824)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:345)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:226)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
    org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:275)
    org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:320)
    org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:87)
    org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:72)
    org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:63)
    net.sf.click.extras.spring.SpringClickServlet.init (SpringClickServlet.java:143)
    javax.servlet.GenericServlet.init(GenericServlet.j ava:211)
    org.jboss.web.tomcat.security.CustomPrincipalValve .invoke(CustomPrincipalValve.java:39)
    org.jboss.web.tomcat.security.SecurityAssociationV alve.invoke(SecurityAssociationValve.java:153)
    org.jboss.web.tomcat.security.JaccContextValve.inv oke(JaccContextValve.java:59)
    org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
    org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
    org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:856)
    org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.processConnection(Http11Protocol.jav a:744)
    org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
    org.apache.tomcat.util.net.MasterSlaveWorkerThread .run(MasterSlaveWorkerThread.java:112)
    java.lang.Thread.run(Thread.java:595)

    This is the contents of my applicationContext.xml :

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>
    <import resource="daoApplicationContext.xml" />
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="locations">
    <list>
    <value>classpath:/jdbc.properties</value>
    <value>classpath:/hibernate.properties</value>
    </list>
    </property>
    </bean>

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName">
    <value>${jdbc.driverClassName}</value>
    </property>
    <property name="url">
    <value>${jdbc.url}</value>
    </property>
    <property name="username">
    <value>${jdbc.username}</value>
    </property>
    <property name="password">
    <value>${jdbc.password}</value>
    </property>
    <!--<property name="autoReconnect">
    <value>true</value>
    </property>-->
    <property name="initialSize">
    <!--
    The initial number of connections that are created when the pool is started.
    NOTE: if you omit this parameter, no connections (zero) are created initially !
    -->
    <value>10</value>
    </property>
    <property name="testOnBorrow">
    <!--
    The indication of whether objects will be validated before being borrowed from the pool.
    If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.
    -->
    <value>true</value>
    </property>
    <property name="testOnReturn">
    <!--
    The indication of whether objects will be validated before being returned to the pool.
    -->
    <value>false</value>
    </property>

    <property name="testWhileIdle">
    <!--
    The indication of whether objects will be validated by the idle object evictor (if any).
    If an object fails to validate, it will be dropped from the pool.
    -->
    <value>false</value>
    </property>
    <property name="removeAbandoned">
    <!--
    Flag to remove abandoned connections if they exceed the removeAbandonedTimout.
    If set to true a connection is considered abandoned and eligible for removal if it has been idle longer than the
    removeAbandonedTimeout. Setting this to true can recover db connections from poorly written applications which
    fail to close a connection.
    -->
    <value>true</value>
    </property>
    <property name="removeAbandonedTimeout">
    <!--
    Timeout in seconds before an abandoned connection can be removed.
    -->
    <value>3600</value>
    </property>
    <property name="logAbandoned">
    <!--
    Flag to log stack traces for application code which abandoned a Statement or Connection.
    Logging of abandoned Statements and Connections adds overhead for every Connection open or new Statement because
    a stack trace has to be generated.
    -->
    <value>true</value>
    </property>

    </bean>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="dataSource">
    <ref bean="dataSource" />
    </property>
    <property name="configLocation">
    <value>hibernate.cfg.xml</value>
    </property>
    <property name="configurationClass">
    <value>org.hibernate.cfg.AnnotationConfiguration </value>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
    <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
    <prop key="hibernate.hbm2ddl.auto">update</prop>
    <prop key="hibernate.connection.max_fetch_depth">0</prop>
    <prop key="use_outer_join">true</prop>
    <prop key="hibernate.cglib.use_reflection_optimizer">${h ibernate.cglib.use_reflection_optimizer}</prop>
    <prop key="hibernate.connection.autoReconnect">true</prop>
    <prop key="hibernate.connection.autoReconnectForPools">t rue</prop>
    </props>
    </property>
    </bean>

    </beans>


    This is the contents of my hibernate XML file :

    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

    <!-- Generated by MyEclipse Hibernate Tools. -->
    <hibernate-configuration>

    <session-factory>
    <mapping class="be.foundation.multilib.model.User" />
    <mapping class="be.foundation.multilib.model.Address" />
    <mapping class="be.foundation.multilib.model.Community" />
    <mapping class="be.foundation.multilib.model.Collection" />
    <mapping class="be.foundation.multilib.model.MultimediaType " />
    <mapping class="be.foundation.multilib.model.Loan" />
    <mapping class="be.foundation.multilib.model.Activity" />
    <mapping class="be.foundation.multilib.model.Reservation" />
    <mapping class="be.foundation.multilib.model.MultimediaItem " />

    </session-factory>



    </hibernate-configuration>

    If someone please can help me...
    I am using this application as a school project. My tutor is of skiing till 11 Apr, so I'm really stuck now...
    Many thanks

  • #2
    hibernate-file(s)

    Hi,

    Just a quick one... Are you sure you have the hibernate.cfg.xml-file in the war file (e.g. in the WEB-INF\classes-directory)? You propably have since this is the only bean that cannot been initialized, right?

    Comment


    • #3
      Error creating bean

      Yes,

      The hibernate config file is in the right directory.

      Tommie.

      Comment

      Working...
      X