Announcement Announcement Module
Collapse
No announcement yet.
PropertyAccessException Spring Hibernate integration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • PropertyAccessException Spring Hibernate integration

    Hello,
    Im following instructions @ http://www.vaannila.com/spring/sprin...gration-1.html, but ive encountered such problem:
    Code:
    SEVERE: Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [java.lang.Class[]] for property 'annotatedClasses'; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.vaannila.domain.User]. Root cause: java.lang.ClassNotFoundException: com.vaannila.domain.User
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1303)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1042)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
            at java.security.AccessController.doPrivileged(Native Method)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
            at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:407)
            at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
            at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:332)
            at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:266)
            at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:236)
            at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
            at javax.servlet.GenericServlet.init(GenericServlet.java:212)
            at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
            at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:806)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
            at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
            at java.lang.Thread.run(Thread.java:619)
    Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [java.lang.Class[]] for property 'annotatedClasses'; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.vaannila.domain.User]. Root cause: java.lang.ClassNotFoundException: com.vaannila.domain.User
            at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)
            at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1300)
            ... 29 more
    My bean is exact as in example on authors web page:
    Code:
    	<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    		<property name="dataSource" ref="myDataSource" />
    		<property name="annotatedClasses">
    			<list>
    				<value>com.vaannila.domain.User</value>
    			</list>
    		</property>
    Im using Spring web MVC 2.5, Hibernate 3.2.5 and NB 6.7.1.

  • #2
    I've noticed, that after updating dispatcher-servlet, with component-scan tags:
    Code:
        <context:component-scan base-package="java.com.vaannila.domain"/>
    And changing path to User class
    Code:
                    <list>
                        <value>User</value>
                    </list>
    Occurs other kind of error
    Code:
    PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [java.lang.Class[]] for property 'annotatedClasses'; nested exception is java.lang.IllegalArgumentException: Error loading class [User]: problem with class file or dependent class. Root cause: java.lang.NoClassDefFoundError: User (wrong name: com/vaannila/domain/User)

    Comment


    • #3
      The package which you have mentioned in context:component element does not matches with the package of user class.You have mentioned java.com.vaannila.domain whereas it should be com.vaannila.domain
      I would still suggest you to put the full package path for the User class in the value.Don't just put User,give com.vaannila.domain.User.
      The other alternative is that you can remove the annotated classes property and try adding the following :
      Code:
       <property name="packagesToScan" value="com.vaannila.domain"/>
      I would also request you to check if you are having the necessary jars required for this project to run successfully.The zip comes with no library.Can you verify if you are having all the jar files mentioned in the tutorial page ?
      Cheers,
      Sushant

      Comment


      • #4
        thanks for the post...

        Comment


        • #5
          Can you please update the status Mate ? Did it worked out or are you still stuck with it ?

          Comment


          • #6
            I've tryed not only changing packages source path as You mentioned, but also consolidating them, or putting into default package, effect is always same, error changes into for example:
            Code:
            Cannot find class [com.vaannila.domain.User]. Root cause: java.lang.ClassNotFoundException: com.vaannila.domain.User
            Neither, i think, its the fault of libs, couse ive builded my project using auto integration with Spring and Hibernate, now it looks kinda messed up, after i searched for any lack of dependencies:
            http://img109.imageshack.us/img109/8577/packsr.jpg

            Comment


            • #7
              great information thanks a lot

              Comment

              Working...
              X