Announcement Announcement Module
Collapse
No announcement yet.
Bugs: ClassCastException in 1.1.0.M1 & no property found 1.1.0.BUILD-SNAPSHOT Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bugs: ClassCastException in 1.1.0.M1 & no property found 1.1.0.BUILD-SNAPSHOT

    Note: environment is Win7 64-bit, JDK 1.7.0_01 61-bit, Hibernate 3.6.7.Final & Oracle.

    I've hit a bug similar to https://jira.springsource.org/browse/DATAJPA-45 with Spring Data JPA 1.1.0.M1. In DATAJPA-45, the ClassCastException has to do with ParameterizedTypeImpl, whereas the bug I see has to do with TypeVariableImpl.
    Code:
    Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class
            at org.springframework.data.repository.util.ClassUtils.getReturnedDomainClass(ClassUtils.java:60)
            at org.springframework.data.repository.query.QueryMethod.getDomainClass(QueryMethod.java:127)
            at org.springframework.data.repository.query.QueryMethod.getNamedQueryName(QueryMethod.java:120)
            at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:118)
            at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:157)
            at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:71)
            at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:268)
            at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:142)
            at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:114)
            at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:38)
            at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
            ... 43 more
    After seeing that DATAJPA-45 was fixed in Spring Data Commons, I updated Spring Data JPA to version 1.1.0.BUILD-SNAPSHOT and got a different error:
    Code:
    Caused by: java.lang.IllegalArgumentException: No property find found for type class com.ea.nucleus.db.user.UserDB
            at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:73)
            at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:92)
            at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:312)
            at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:326)
            at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:294)
            at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:258)
            at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:239)
            at org.springframework.data.repository.query.parser.Part.<init>(Part.java:69)
            at org.springframework.data.repository.query.parser.PartTree$OrPart.<init>(PartTree.java:180)
            at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:260)
            at org.springframework.data.repository.query.parser.PartTree$Predicate.<init>(PartTree.java:240)
            at org.springframework.data.repository.query.parser.PartTree.<init>(PartTree.java:68)
            at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.<init>(PartTreeJpaQuery.java:56)
            at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:92)
            at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:159)
            at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:71)
            at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:268)
            at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:142)
            at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:114)
            at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:38)
            at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
            ... 43 more
    Any ideas?

    Thanks,
    Matthew

  • #2
    Hi Matthew,

    make sure you pull the SD Commons 1.2.0.BUILD-SNAPSHOT as well (actually the pom.xml of SD JPA 1.1.0.M1 should do but I guess you've defined the dependency explicitly to SD Commons in your pom.xml). The latter error seems to be caused by a method declared not being a query method but rather a redeclaration of a CRUD method of some kind. Is there a chance you can show the repository declaration?

    Comment


    • #3
      Nevermind. I had a slight inconsistency in my custom interface hierarchy. Fixed & now works with SD JPA 1.1.0.M1 & 1.1.0.BUILD-SNAPSHOT.

      -matthew

      Comment


      • #4
        Glad it worked out for you!

        Comment

        Working...
        X