Announcement Announcement Module
Collapse
No announcement yet.
PK member is not of specified type (javax.jdo.identity.LongIdentity) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • PK member is not of specified type (javax.jdo.identity.LongIdentity)

    I'm facing problems with Spring Roo 1.2.0.RELEASE [rev 39eb957] even with the simplest setup. Here is what I do:

    Code:
    project --topLevelPackage com.ciaobit --java 6
    jpa setup --database GOOGLE_APP_ENGINE --provider DATANUCLEUS --applicationId appotest
    
    entity jpa --class ~.domain.App --activeRecord false --testAutomatically 
    field string --fieldName appName --sizeMin 3 --sizeMax 48 --regexp ^[0-9a-zA-Z-]+$ --notNull --unique 
    field string --fieldName email --regexp ^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$ --notNull 
    
    repository jpa --interface ~.repository.AppRepository --entity ~.domain.App 
    service --interface ~.service.AppService --entity ~.domain.App
    
    web mvc setup
    web mvc all --package ~.webproto
    perform eclipse
    exit
    $ mvn gae:run

    [ERROR] Failed to execute goal org.datanucleus:maven-datanucleus-plugin:3.0.1:enhance (default) on project ciaobit: Error executing enhancer: InvocationTargetException: Plugin (Bundle) "org.datanucleus" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/home/stivlo/.m2/repository/org/datanucleus/datanucleus-core/3.0.4/datanucleus-core-3.0.4.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/home/stivlo/.m2/repository/org/datanucleus/datanucleus-core/3.0.7/datanucleus-core-3.0.7.jar." -> [Help 1]

    To get around this problem, I set datanucleus-core dependency with scope runtime:

    Code:
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-core</artifactId>
            <version>3.0.4</version>
            <scope>runtime</scope>
        </dependency>
    mvn gae:run

    All the test fails:

    2012-02-06 12:33:32,004 [main] ERROR org.springframework.test.context.TestContextManage r - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.Dependenc yInjectionTestExecutionListener@14c1615] to prepare test instance [com.ciaobit.domain.AppIntegrationTest@3ded93]
    java.lang.IllegalStateException: Failed to load ApplicationContext
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'appRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: PK member is not of specified type (javax.jdo.identity.LongIdentity). Should be java.lang.Long
    Caused by: java.lang.IllegalArgumentException: PK member is not of specified type (javax.jdo.identity.LongIdentity). Should be java.lang.Long

    Even deleting the tests, running fails with the error "PK member is not of specified type (javax.jdo.identity.LongIdentity). Should be java.lang.Long"

    I've grepped for LongIdentity and is found only in class files, so it's added by datanucleus enhancement.

    How to solve the issue? Thanks in advance.

  • #2
    Obviously caused by Roo-generated code making large assumptions about what the JPA metamodel API returns. Maybe if you up your version of datanucleus jars to the latest you may see different results. But then I'd expect Spring Roo people to comment since its their code that results in this

    Comment


    • #3
      Thanks Andy, once again, for your reply.

      I tried to upgrade as follows:

      datanucleus-core 3.0.4 -> 3.0.5
      datanucleus-api-jpa 3.0.4 -> 3.0.5
      datanucleus-rdbms 3.0.4 -> 3.0.5

      But I've still the same errors. I suppose that in this case it might be a Spring Data problem, rather than a Roo problem, but sure, as you say, people from Spring can enlighten us about it.

      Comment


      • #4
        the *latest* version : datanucleus-core is 3.0.7, datanucleus-api-jpa is 3.0.6 and since you're using GAE then you don't need datanucleus-rdbms.

        Comment


        • #5
          Ah got it, I checked on mvnrepository.com, that is not yet updated.

          However, it seems to work with the latest version, but I've to test it more, I will post an update.

          Comment


          • #6
            The Roo JPA support assumes JPA 2.0 compliance for which Hibernate, EcllipseLink, OpenJPA, and DN3 seems to do well with when used with relational databases. GAE has its issues but we have higher priorities and also our focus is on our own cloud initiatives, such as Cloud Foundry.

            If someone wants to provide a patch so that GAE works correctly for Roo-generated apps, then please do so.
            Thanks

            Alan

            Comment


            • #7
              FYI, for Roo 1.2.1 coming out later this week, I have updated DN to 3.0.7 core and 3.0.6 for jpa as well as the datanucleus-appengine-2.0.0-final plugin. I had to host the latter jar in our own repository as I can''t find it anywhere in any other public repo.

              Comment


              • #8
                To follow up, here is an updated script, without tests (since they fail), without the unique constraint (since is not supported), and I've written a couple of Groovy scripts to change a version of an artifact in the pom (pomVersions) and to remove an artifact from the pom (pomRm). In this way I can express the whole thing in a script that can be copied and pasted in the console:

                Code:
                mkdir test-gae
                cd test-gae
                roo
                project --topLevelPackage com.ciaobit --java 6
                jpa setup --database GOOGLE_APP_ENGINE --provider DATANUCLEUS --applicationId appotest
                entity jpa --class ~.domain.App --activeRecord false  
                field string --fieldName appName --sizeMin 3 --sizeMax 48 --regexp ^[0-9a-zA-Z-]+$ --notNull
                field string --fieldName email --regexp ^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$ --notNull
                repository jpa --interface ~.repository.AppRepository --entity ~.domain.App
                service --interface ~.service.AppService --entity ~.domain.App
                web mvc setup
                web mvc all --package ~.webproto
                perform eclipse
                exit
                pomVersions datanucleus-core 3.0.7
                pomVersions datanucleus-api-jpa 3.0.6
                pomRm datanucleus-rdbms rm
                mvn gae:run
                It's improved, now I can create a new item, modify it. The modification works in the datastore, but the interface shows the old value, even after multiple refreshes. If instead I go to List All, it dies with an exception:

                Code:
                java.util.ArrayList$Itr.next(ArrayList.java:794)
                org.datanucleus.api.jpa.criteria.CriteriaQueryImpl.toString(CriteriaQueryImpl.java:758)
                org.datanucleus.api.jpa.JPAEntityManager.createQuery(JPAEntityManager.java:771)
                sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                java.lang.reflect.Method.invoke(Method.java:601)
                com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
                org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
                $Proxy29.createQuery(Unknown Source)
                sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                java.lang.reflect.Method.invoke(Method.java:601)
                com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
                org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
                $Proxy29.createQuery(Unknown Source)
                org.springframework.data.jpa.repository.support.SimpleJpaRepository.getQuery(SimpleJpaRepository.java:420)
                org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:277)
                org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:239)
                So, I've to give up with roo and spring-data.

                Regards,
                stivlo

                Comment

                Working...
                X