Announcement Announcement Module
Collapse
No announcement yet.
getting error Invalid property 'packagesToScan' of bean class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • getting error Invalid property 'packagesToScan' of bean class

    Hi to all,
    I am using spring 3.2. Eclipse maven project and Tomcat 7. When i run my project i get the following error that

    Code:
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'emf' defined in class path resource [datasource-tx-jpa.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'packagesToScan' of bean class [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Bean property 'packagesToScan' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    Here is my pom.xml

    Code:
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>pk.training.basitMahmood</groupId>
      <artifactId>ch17_WebApplicationWithSpring</artifactId>
      <packaging>war</packaging>
      <version>0.0.1-SNAPSHOT</version>
      <name>ch17_WebApplicationWithSpring Maven Webapp</name>
      <url>http://maven.apache.org</url>
      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <org.springframework-version>3.2.2.RELEASE</org.springframework-version>
      </properties>
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-core</artifactId>
        	<version>${org.springframework-version}</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-context</artifactId>
        	<version>${org.springframework-version}</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-context-support</artifactId>
        	<version>${org.springframework-version}</version>
        </dependency>
       <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-jdbc</artifactId>
        	<version>${org.springframework-version}</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-tx</artifactId>
        	<version>${org.springframework-version}</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-beans</artifactId>
        	<version>${org.springframework-version}</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-aspects</artifactId>
        	<version>${org.springframework-version}</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-aop</artifactId>
        	<version>${org.springframework-version}</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-orm</artifactId>
        	<version>${org.springframework-version}</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-jpa</artifactId>
        	<version>2.0.8</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework.data</groupId>
        	<artifactId>spring-data-jpa</artifactId>
        	<version>1.3.2.RELEASE</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework.data</groupId>
        	<artifactId>spring-data-commons</artifactId>
        	<version>1.5.1.RELEASE</version>
        </dependency>
        <dependency>
        	<groupId>org.hibernate</groupId>
        	<artifactId>hibernate-entitymanager</artifactId>
        	<version>4.3.0.Beta2</version>
        </dependency>
        <dependency>
        	<groupId>org.hibernate</groupId>
        	<artifactId>hibernate-validator</artifactId>
        	<version>5.0.1.Final</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.171</version>
        </dependency>
        <dependency>
        	<groupId>javax.validation</groupId>
        	<artifactId>validation-api</artifactId>
        	<version>1.1.0.Final</version>
        </dependency>
        <dependency>
        	<groupId>joda-time</groupId>
        	<artifactId>joda-time</artifactId>
        	<version>2.2</version>
        </dependency>
        <dependency>
        	<groupId>joda-time</groupId>
        	<artifactId>joda-time-hibernate</artifactId>
        	<version>1.3</version>
        </dependency>
        <dependency>
        	<groupId>org.slf4j</groupId>
        	<artifactId>slf4j-log4j12</artifactId>
        	<version>1.7.5</version>
        </dependency>
        <dependency>
        	<groupId>com.google.guava</groupId>
        	<artifactId>guava</artifactId>
        	<version>14.0.1</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework</groupId>
        	<artifactId>spring-oxm</artifactId>
        	<version>3.2.3.RELEASE</version>
        </dependency>
        <dependency>
        	<groupId>org.codehaus.jackson</groupId>
        	<artifactId>jackson-mapper-lgpl</artifactId>
        	<version>1.9.12</version>
        </dependency>
        <dependency>
        	<groupId>org.codehaus.castor</groupId>
        	<artifactId>castor-xml</artifactId>
        	<version>1.3.3-rc1</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework.security</groupId>
        	<artifactId>spring-security-core</artifactId>
        	<version>3.1.4.RELEASE</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework.security</groupId>
        	<artifactId>spring-security-web</artifactId>
        	<version>3.1.4.RELEASE</version>
        </dependency>
        <dependency>
        	<groupId>org.springframework.security</groupId>
        	<artifactId>spring-security-config</artifactId>
        	<version>3.1.4.RELEASE</version>
        </dependency>
        <dependency>
        	<groupId>org.apache.httpcomponents</groupId>
        	<artifactId>httpclient</artifactId>
        	<version>4.3-beta1</version>
        </dependency>
        <dependency>
        	<groupId>joda-time</groupId>
        	<artifactId>joda-time-jsptags</artifactId>
        	<version>1.1.1</version>
        </dependency>
      </dependencies>
      
      <build>
        <finalName>WebApplicationWithSpring</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration> 
            </plugin>
        </plugins>
      </build>
    </project>
    Here is my xml file

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:jdbc="http://www.springframework.org/schema/jdbc"
    	xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans 
    	                    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    		                http://www.springframework.org/schema/context 
    		                http://www.springframework.org/schema/context/spring-context-3.2.xsd
    		                http://www.springframework.org/schema/jdbc 
    		                http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
    		                http://www.springframework.org/schema/tx 
    		                http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
    		                http://www.springframework.org/schema/data/jpa 
    		                http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd">
        
        <jdbc:embedded-database id="dataSource" type="H2">
            <jdbc:script location="classpath:schema.sql"/>
            <jdbc:script location="classpath:test-data.sql"/>    
        </jdbc:embedded-database>
    
        <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="entityManagerFactory" ref="emf"/>
        </bean>
        <tx:annotation-driven transaction-manager="transactionManager" />
        <bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
            <property name="dataSource" ref="dataSource" />
            <property name="jpaVendorAdapter">
                <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
            </property> 
            <property name="packagesToScan" value="pk.training.basitMahmood.domain"/>     
            <property name="jpaProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
                    <prop key="hibernate.max_fetch_depth">3</prop>
                    <prop key="hibernate.jdbc.fetch_size">50</prop>
                    <prop key="hibernate.jdbc.batch_size">10</prop>
                    <prop key="hibernate.show_sql">true</prop>              
                </props>        
            </property>
        </bean>    
        <context:annotation-config/>    
        <jpa:repositories base-package="pk.training.basitMahmood.repository"
                          entity-manager-factory-ref="emf"
                          transaction-manager-ref="transactionManager"/>    
    
    </beans>
    Why i am getting this error? I am including all jars of spring 3.2 ... Please help ?

    Thanks

  • #2
    Check this link for my answer http://stackoverflow.com/questions/1...82262#16982262

    Thanks

    Comment

    Working...
    X