Announcement Announcement Module
Collapse
No announcement yet.
can't determine annotations of missing type javax.persistence.Entity when weaving... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • can't determine annotations of missing type javax.persistence.Entity when weaving...

    Hi all,

    I create a project and add logging support like this:

    Code:
    project --topLevelPackage com.parler.apps.organiser --projectName organiser --java 6
    logging setup --level DEBUG
    and from within STS and at the commandline I get the error: "Can't determine annotations of missing type javax.persistence.Entity...".

    I am not using JPA and do not want to; I want to create just a simple commandline app.

    Can somebody recommend a solution please or explain what's going on? I'll gratefully accept links to other resources which will explain what is happening with respect to the Aspect J weaving stuff if anyone has any.


    Thanks,
    Alistair



    p.s. the exact error is:
    Code:
    roo> logging setup --level DEBUG
    Updated SRC_MAIN_RESOURCES\log4j.properties
    roo> perform eclipse
    [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] Building organiser
    [INFO]    task-segment: [eclipse:clean, eclipse:eclipse]
    [INFO] ------------------------------------------------------------------------
    [INFO] [eclipse:clean {execution: default-cli}]
    [INFO] Deleting file: .project
    [INFO] Deleting file: .classpath
    [INFO] Deleting file: .wtpmodules
    [INFO] Deleting file: .component
    [INFO] Deleting file: org.eclipse.wst.common.component
    [INFO] Deleting file: org.eclipse.wst.common.project.facet.core.xml
    [INFO] Deleting file: org.eclipse.jdt.core.prefs
    [INFO] Deleting file: org.eclipse.ajdt.ui.prefs
    [INFO] Preparing eclipse:eclipse
    [INFO] [aspectj:compile {execution: default}]
    [ERROR] can't determine annotations of missing type javax.persistence.Entity
    when weaving type com.parler.apps.organiser.Whatever
    when weaving classes
    when weaving
    when batch building BuildConfig[null] #Files=1 AopXmls=#0
     [Xlint:cantFindType]
    [WARNING] advice defined in org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect has not been applied [Xlint:adviceDidNotMatch]
    [WARNING] advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
    [WARNING] advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
    [WARNING] advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
    [INFO] ------------------------------------------------------------------------
    [ERROR] BUILD ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] Compiler errors :
    error at (no source information available)
    C:\user\dev\java\organiser\organiser\src\main\java\com\parler\apps\organiser\Whatever.java:0::0 can't determine annotations of missing type javax.persistence.Entity
    when weaving type com.parler.apps.organiser.Whatever
    when weaving classes
    when weaving
    when batch building BuildConfig[null] #Files=1 AopXmls=#0
     [Xlint:cantFindType]
    roo>
    [INFO] ------------------------------------------------------------------------
    [INFO] For more information, run Maven with the -e switch
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 3 seconds
    [INFO] Finished at: Wed Jun 15 13:30:47 BST 2011
    [INFO] Final Memory: 19M/46M
    [INFO] ------------------------------------------------------------------------
    The command 'mvn.bat eclipse:clean eclipse:eclipse' did not complete successfully
    roo>
    I have only done the two lines given above to create the project and add logging, then added (manually) a dummy class like this:

    Code:
    package com.parler.apps.organiser;
    
    public class Whatever {
    
    }
    Within STS, the same error appears as a red cross to the left of the package declaration.

  • #2
    Is Roo the right tool for this?

    If you're not using JPA (the only persistence technology currently supported by Roo), then most Roo features (e.g. web scaffolding) are no use to you. Can I ask how you envisage Roo helping you to write or maintain your application? Which of its features do you see being useful? If you just want to create a skeleton Maven project, you might be better off using a Maven archetype or a Maven IDE plugin.

    Comment


    • #3
      Hi Andrew,

      You have a fair point that for a very simple app, a Maven archetype would be better.

      However, I do want to use Roo to create a full Java EE application over the coming months but wanted to do it in a very bit-by-bit manner. In my opinion, if I have just created an application and added logging and JPA cannot be found by the weaving stuff, then the application which is created by Roo at this stage is effectively broken. True in a "real" usage of Roo it wouldn't be a problem but I hold the opinion that at each stage of executing something with Roo, all functionality introduced must be working and not contain anything unnecessary. Having a dependency on JPA which is not being included is violating both these points.

      So to answer my question then I guess this is a bug?

      For other users I have worked round it by including the dependency manually (which I object to as Roo should have done this for me) to the JPA. Adding this makes the error go away once mvn eclipse:eclipse (or perform eclipse) has been done.

      Code:
              
              <!-- required for Aspect weaving -->
              <dependency>
                  <groupId>org.hibernate.javax.persistence</groupId>
                  <artifactId>hibernate-jpa-2.0-api</artifactId>
                  <version>1.0.0.Final</version>
              </dependency>
      Thanks,
      Alistair

      Comment


      • #4
        I replicated your problem in Roo 1.1.4. Googling the error message turned up a number of hits of which ROO-770 is a good starting point. In short, Roo by default uses the "spring-aspects" aspect library (as listed in the POM), which in turn has this dependency:

        Code:
        <dependency>
              <groupId>javax.persistence</groupId>
              <artifactId>persistence-api</artifactId>
              <version>1.0</version>
              <optional>true</optional>
        </dependency>
        Because this dependency is marked as optional (in Spring 3.0.5 at least), Maven will not pull it in transitively to the classpath as it normally would. You can see in the comments for SPR-6819 that they went back and forth about whether to make this dependency optional or not, but currently it is.

        So if you haven't added JPA to your project via the "persistence setup" command, you'll need to use one of these two workarounds to get your project to compile:
        1. Add the JPA dependency as you have done (although I would suggest setting the scope to provided to ensure the JAR isn't unnecessarily bundled into your application's JAR file), or
        2. Remove the spring-aspects library from your POM if you don't need it for something else. The problem with this approach is that Roo will not add it back in if you execute any commands that cause ITDs to be generated (e.g. the "entity" command).
        If you wish, you can log a JIRA ticket asking for Roo to work around this problem automatically.

        Comment

        Working...
        X