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

  • MalformedParameterizedTypeException

    Hello, first post here.

    I have followed the very well written blog entry Getting started with Spring Data JPA. When trying to run my unit tests, I am getting a Failed to load ApplicationContext error. The exception eventually boils down to this:
    Error creating bean with name 'basInstrumentRepository': Post-processing failed of bean type [class org.springframework.data.jpa.repository.support.Jp aRepositoryFactoryBean] failed; nested exception is java.lang.reflect.MalformedParameterizedTypeExcept ion
    Can anybody provide any hints? I have made sure to have only the latest versions of everything, and I am not mixing old Spring jars in my classpath.

    Thanks in advance and best regards.

  • #2
    Sounds like a version inconsistency.

    What version of JPA are you using? What version of Hibernate and spring?

    Comment


    • #3
      I'd be interested in some more context of the exception. Is there a stacktrace you can provide?

      Cheers,
      Ollie

      Comment


      • #4
        Originally posted by crobster View Post
        Sounds like a version inconsistency. What version of JPA are you using? What version of Hibernate and spring?
        I am using hibernate-jpa-2.0-api-1.0.0.Final.jar and hibernate3.jar. Both come from the final 3.2.6 Hibernate distribution.

        Originally posted by Oliver Gierke View Post
        I'd be interested in some more context of the exception. Is there a stacktrace you can provide?
        I have uploaded a full stack trace and a full library list here.

        Thanks for any hints.

        Comment


        • #5
          Originally posted by gonzus View Post
          I am using hibernate-jpa-2.0-api-1.0.0.Final.jar and hibernate3.jar. Both come from the final 3.2.6 Hibernate distribution.
          Hibernate 3.2.6 does not support JPA 2. Hibernate introduced the support with version 3.5.

          I have uploaded a full stack trace and a full library list here.
          This looks rather strange as the exception is popping up somewhere deep inside the JDK and seems to appear while scanning the entities inside the core Spring JPA support. Are you using generics inside your entities? If so, what do these entities look like?
          Last edited by Oliver Gierke; Apr 8th, 2011, 07:51 AM.

          Comment


          • #6
            Originally posted by Oliver Gierke View Post
            Hibernate 3.2.6 does not support JPA two. Hibernate introduced the support with version 3.5.
            Sorry, I mistyped. Those two files come from the 3.6.2 Hibernate zip. Are you suggesting I should use a different version of Hibernate? Since v4 is not released yet, I think I would have to stick with 3.6, right?

            Newbie question: do I need any other JARs in order to use JPA with Hibernate?

            Originally posted by Oliver Gierke View Post
            This looks rather strange as the exception is popping up somewhere deep inside the JDK and seems to appear while scanning the entities inside the core Spring JPA support. Are you using generics inside your entities? If so, what do these entities look like?
            Yes, I am using generics, as per the example in the blog I pointed to in my original post. I have added a zip file with the source code at the same URL where the other information is located.

            Thanks for your help.

            Comment


            • #7
              I just wanted to report that I found the cause for this exception: I was missing the spring-data-commons-core JAR in my classpath.

              Thanks for all the help and best regards.

              Comment


              • #8
                I'm getting the same error. Using Spring 3.0.5 and EclipseLink 2.1.3. Spring Data JPa and Commons Core 1.00.M2.

                Here is the stacktrace:

                Code:
                Caused by: java.lang.reflect.MalformedParameterizedTypeException
                	at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:42)
                	at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:35)
                	at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:77)
                	at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:86)
                	at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:122)
                	at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:31)
                	at sun.reflect.generics.repository.ClassRepository.getSuperclass(ClassRepository.java:66)
                	at java.lang.Class.getGenericSuperclass(Class.java:677)
                	at org.springframework.core.GenericTypeResolver.getTypeVariableMap(GenericTypeResolver.java:261)
                	at org.springframework.core.GenericTypeResolver.resolveParameterType(GenericTypeResolver.java:82)
                	at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getWriteMethodParameter(GenericTypeAwarePropertyDescriptor.java:147)
                	at org.springframework.beans.GenericTypeAwarePropertyDescriptor.getPropertyType(GenericTypeAwarePropertyDescriptor.java:129)
                	at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.checkResourceType(InjectionMetadata.java:132)
                	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.<init>(PersistenceAnnotationBeanPostProcessor.java:617)
                	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:394)
                	at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:320)
                	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:798)
                	... 12 more
                Last edited by kshronts; May 31st, 2011, 01:32 PM.

                Comment


                • #9
                  The most common cause for this problem is mixing different versions for the Spring JARs. Other than that, I know that some missing JARs are only detected at run time and can cause this exception.

                  What I did to work this out was to download the Spring Data example and build it with maven; then I carefully compared and copied JARs from the maven repo to my project's library path, until I made it work.

                  I also suggest you correct your post and add proper code tags around the exception. Good luck.

                  Comment


                  • #10
                    I enabled TRACE level logging and was able to get more information about the problem. Here's some relevant output:

                    Code:
                    SEVERE: org/springframework/data/jpa/repository/support/JpaRepositoryFactoryBean
                    java.lang.IllegalStateException: Wrong number of type parameters supplied
                    	at org.aspectj.weaver.ResolvedMemberImpl.parameterizedWith(ResolvedMemberImpl.java:732)
                    
                    
                    ...
                    
                    [AppClassLoader@1188d63] error can't determine implemented interfaces of missing type org.springframework.data.repository.support.EntityInformation
                    when weaving type org.springframework.data.jpa.repository.support.JpaRepositoryFactory
                    when weaving classes 
                    when weaving 
                     [Xlint:cantFindType]
                    I checked the jar for the data commons and it is missing the org.springframework.data.repository.support.Entity Information class. I suspect this is the cause of my problem. Any idea when the next release will be out?

                    Comment


                    • #11
                      Originally posted by kshronts View Post
                      I checked the jar for the data commons and it is missing the org.springframework.data.repository.support.Entity Information class. I suspect this is the cause of my problem. Any idea when the next release will be out?
                      This is exactly why I mentioned getting the example and building it with maven. It will make sure you have a consistent set of JARs that work (and you will be able to test that by running the unit tests in the sample). From there it should become easier to replicate a working environment for your code.

                      Trust me, I wasted one week because I did not want to go with maven, but it helped me solve this in a couple of hours (and I am still not using it on a day to day basis).

                      Comment


                      • #12
                        Any luck with this? I have the same issue with JpaRepository of version 1.0.0.M2. My various artifact versions are listed below

                        <spring.version>3.0.5.RELEASE</spring.version>
                        <spring-data-jpa.version>1.0.0.M2</spring-data-jpa.version>
                        <hibernate.version>3.6.1.Final</hibernate.version>
                        <hibernate.jpa.version>1.0.0.Final</hibernate.jpa.version>

                        It works if I switch to CrudRepository for version <spring-data-jpa.version>1.0.0.BUILDSNAPSHOT</spring-data-jpa.version>

                        Comment


                        • #13
                          Originally posted by nazeer View Post
                          Any luck with this?
                          Please add code tags to your post where appropriate.

                          This thing works for me, as stated in previous posts. If it is of any help to you, here are all the JARs in my classpath:

                          Code:
                          antlr-2.7.6.jar
                          aopalliance.jar
                          aspectj-1.6.11.jar
                          cglib-2.2.jar
                          com.springsource.org.objectweb.asm-3.1.0.jar
                          commons-collections-3.1.jar
                          commons-dbcp-1.4.jar
                          commons-httpclient-3.0.1.jar
                          commons-logging-1.1.1.jar
                          commons-management-1.0.jar
                          commons-pool-1.5.6.jar
                          dom4j-1.6.1.jar
                          hibernate-jpa-2.0-api-1.0.0.Final.jar
                          hibernate3.jar
                          javassist-3.14.0.GA.jar
                          jta-1.1.jar
                          log4j-1.2.14.jar
                          org.springframework.aop-3.0.5.RELEASE.jar
                          org.springframework.asm-3.0.5.RELEASE.jar
                          org.springframework.aspects-3.0.5.RELEASE.jar
                          org.springframework.beans-3.0.5.RELEASE.jar
                          org.springframework.context-3.0.5.RELEASE.jar
                          org.springframework.context.support-3.0.5.RELEASE.jar
                          org.springframework.core-3.0.5.RELEASE.jar
                          org.springframework.expression-3.0.5.RELEASE.jar
                          org.springframework.jdbc-3.0.5.RELEASE.jar
                          org.springframework.orm-3.0.5.RELEASE.jar
                          org.springframework.oxm-3.0.5.RELEASE.jar
                          org.springframework.transaction-3.0.5.RELEASE.jar
                          org.springframework.web-3.0.5.RELEASE.jar
                          org.springframework.web.servlet-3.0.5.RELEASE.jar
                          postgresql-8.4-702.jdbc4.jar
                          slf4j-api-1.6.1.jar
                          slf4j-log4j12-1.6.1.jar
                          spring-data-commons-core-1.0.0.M3.jar
                          spring-data-jpa-1.0.0.M1.jar
                          xstream-1.3.1.jar

                          Comment

                          Working...
                          X