Results 1 to 9 of 9

Thread: Spring-ehcache

  1. #1
    Join Date
    Jun 2006
    Posts
    8

    Default Spring-ehcache

    I am getting an error as follows..

    Error creating bean with name 'questionServices' defined in file [C:\Documents and Settings\shobhitha.s\workspace\zapzone\build\sprin gcontext.xml]: Cannot resolve reference to bean 'iqdao' while setting bean property 'iqdao'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'iqdao' defined in file [C:\Documents and Settings\shobhitha.s\workspace\zapzone\build\sprin gcontext.xml]: Cannot resolve reference to bean 'hibernateTemplate' while setting bean property 'hibernateTemplate'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'hibernateTemplate' defined in file [C:\Documents and Settings\shobhitha.s\workspace\zapzone\build\sprin gcontext.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 file [C:\Documents and Settings\shobhitha.s\workspace\zapzone\build\sprin gcontext.xml]: Initialization of bean failed; nested exception is org.hibernate.cache.CacheException: net.sf.ehcache.CacheException: Cannot configure CacheManager: The system cannot find the path specified

    I am using eclipse, hibernate3 junit for unit testing..

    I also reffred the site http://ehcache.sourceforge.net/docum...iguration.html, there it says if ehcache.xml is not found then this error comes. but my classpath refers to ehcache-1.1.jar.

    Where am i wrong?Can any one help me on this issue?

  2. #2
    Join Date
    Aug 2005
    Location
    Austin, TX
    Posts
    425

    Default

    Other than the obvious suggestion of double checking your classpath to ensure that the ehcachel.xml file is availlable and verifying that you've followed the documentation, I don't have much of a suggestion.

    I wuold recommend that you post this question on a forum that is specific to hibernate/ehcache since you will likely find more experts there to help answer your questions.

    Larry.

  3. #3
    Join Date
    Jun 2006
    Posts
    8

    Default

    When i searched in my project there was no ehcache.xml file. I added the file and specified the path in my springcontext.xml/applicationcontext.xml.

    Now i am getting the error as follows

    Error creating bean with name 'questionServices' defined in file [C:\Documents and Settings\shobhitha.s\workspace\zapzone\build\sprin gcontext.xml]: Cannot resolve reference to bean 'iqdao' while setting bean property 'iqdao'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'iqdao' defined in file [C:\Documents and Settings\shobhitha.s\workspace\zapzone\build\sprin gcontext.xml]: Cannot resolve reference to bean 'hibernateTemplate' while setting bean property 'hibernateTemplate'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'hibernateTemplate' defined in file [C:\Documents and Settings\shobhitha.s\workspace\zapzone\build\sprin gcontext.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 file [C:\Documents and Settings\shobhitha.s\workspace\zapzone\build\sprin gcontext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: Could not parse mapping document in input stream


    Is there any specific format of ehcache.xml? Where am i wrong? what does this error mean?

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    The error indicates that a hibernate mapping file can't be read. Start with one of the samples from Spring distribution or Hibernate (which already have the environment setup) and compare them with your current setup.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  5. #5
    Join Date
    Jun 2006
    Posts
    8

    Default

    I could not find any samples with hbm files.

    my applicationContext looks like this

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

    <beans>
    <description></description>

    <bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName">
    <value>com.mysql.jdbc.Driver</value>
    </property>
    <property name="url">
    <value>jdbc:mysql://localhost:3306/zapzone</value>
    </property>
    <property name="username">
    <value></value>
    </property>
    <property name="password">
    <value></value>
    </property>
    </bean>



    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="dataSource">
    <ref bean="dataSource"/>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">
    org.hibernate.dialect.MySQLDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    </props>
    </property>
    <property name="mappingResources">
    <list>
    <value>Question.hbm.xml</value>
    <value>Category.hbm.xml</value>
    <value>FeaturedContent.hbm.xml</value>
    <value>ehcache.xml</value>
    </list>
    </property>
    </bean>

    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheMa nagerFactoryBean">
    <property name="configLocation">
    <value>ehcache.xml</value>
    </property>
    </bean>

    <bean id="methodCache" class="org.springframework.cache.ehcache.EhCacheFa ctoryBean">
    <property name="cacheManager">
    <ref local="cacheManager"/>
    </property>
    <property name="cacheName">
    <value>org.taha.cache.METHOD_CACHE</value>
    </property>
    </bean>


    <bean id="hibernateTemplate"
    class="org.springframework.orm.hibernate3.Hibernat eTemplate">
    <property name="sessionFactory">
    <ref bean="sessionFactory"/>
    </property>
    </bean>



    <bean id="iqdao" class="com.avedya.zapzone2.fun.question.dao.Questi onDAOImpl">
    <property name="hibernateTemplate">
    <ref bean="hibernateTemplate"/>
    </property>
    </bean>

    <bean id="questionServices"
    class="com.avedya.zapzone2.fun.question.service.Qu estionServiceImpl">
    <property name="iqdao">
    <ref bean="iqdao"/>
    </property>
    </bean>



    </beans>


    I am not able to access the hbm files which is highlighted.

    The underlined ones are those which i have added where the control is not going there. Can anybody explain this?.

    Inspite of these i am getting the same error which i have mentioned in the above mail.

    Help is needed.....

  6. #6
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    See petclinic under samples/petclinic. It contains a petclinic.hbm.xml - inside the samples folder there are more examples that use hibernate.
    Also hibernate examples do contain hbm files.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  7. #7
    Join Date
    Jun 2006
    Posts
    8

    Default

    Actually there is no need of specifing ecache.xml in the project, instead if i specify only the jar- ehcache1-1.jar in the build file is enough.

    The example also shows the same thing, either in hbm files or applicationContext.xml does not specify anything on ehcache!.

    in my project ehcache1.1.jar is in classpath.

    Dont know what is wrong in my code :-(

  8. #8
    Join Date
    Jun 2006
    Posts
    8

    Default

    My project works now :-)

    I just removed ehcache.xml file, placed only ehcache-1.1.jar in my classpath.

    There is no need of ehcache.xml file to be reffered in applicationContext.xml file.

    Thank you for all your replies.

  9. #9
    Join Date
    Aug 2007
    Posts
    1

    Default

    ehcache.xml is the default config-file to scan for in classpath.

    If you want to split in several config-files, or want to use a different name, or want to be clear in the config-file to display where the config is read from:

    <property name="configLocation" value="classpath:ehcache.xml"/>

    the thing is this classpath-prefix

    this could also work...
    <property name="configLocation">
    <value>classpath:ehcache.xml</value>
    <property>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •