Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: using a roo generated entity in a project reference

  1. #1
    Join Date
    Jan 2010
    Posts
    29

    Default using a roo generated entity in a project reference

    I'm using eclipse and have created a project (lets call it ProjectA) with some entities (lets say Person for this example) in Roo

    now have another project "ProjectB" in the workspace which has a project reference to ProejctA.

    when I try to use Person in some code located in ProjectB, I do not get access to the getters & setters created in the AspectJ by roo. Am I missing somethere here or is there a better way to reference ProjectA from within ProjectB?

    many thanks in advance.

    Ben

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    When you say you cannot access the getters/setters, does this mean ProjectB does not compile at all or simply files you open in ProjectB with an Eclipse editor fail to show the introduced getters/setters during code assist?

    Does ProjectB compile successfully if you attempt to compile it outside of Eclipse? If so, this indicates it's more likely an issue in AJDT.

    I'll mention this tread to the AspectJ/AJDT team and see if they can offer any further suggestions.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  3. #3
    Join Date
    Jan 2010
    Posts
    29

    Default

    Hi Ben,

    I have't tried compiling out of the ide, but yes, it does not give me the code completion when inside the ide, which is something i would very much like to have.

    FWIW when I export ProjectA to a jar then import it in ProjectB it works fine, this problem only seems to come up when I am using a project reference...

    thanks
    Ben
    Last edited by benmonro; Jan 14th, 2010 at 05:58 PM.

  4. #4
    Join Date
    Aug 2008
    Location
    Vancouver, BC
    Posts
    768

    Default

    Hi benmonro,

    I'm guessing that your project B is a Java project, not an AJ project. When I try your situation with 2 AJ projects with standard project references, I do not see the problem you describe, but when project B is a plain Java project, I do see the errors in the editor (but not in the problems view).

    This is mostly by design. What is happening here is that both Projects A and B are being compiled correctly, but only the editor is showing problems.

    A way around this is to make Project B an AJ project.

    If you are interested, what is happening is that the magic that we have in AJDT to enable ITDs to appear where they should is only enabled when inside of an AspectJ project. The reason is that there is a bit of a performance hit for this extra functionality that may not be appropriate in pure Java projects.

    Now, that being said, I did find a bit of a bug. When Project A is added to Project B's aspect path, I do see some real compile problems. I'll have to look deeper into this.

    Is it possible for you to add the AJ nature to Project B and if so, does it help?
    Andrew Eisenberg, Ph.D.
    SpringSource, a division of VMware
    SpringSource Tools Team
    More about AJDT, Groovy-Eclipse, and Grails tooling

  5. #5
    Join Date
    Jan 2010
    Posts
    29

    Default

    Hi Andrew,

    I'll give it a whirl, but the project is an android project so I'm not sure if I'll be able to do that without messing up how android sees the project. I'll try it out and post my findings here.

    many thanks for your help

    Cheers
    Ben

  6. #6
    Join Date
    Aug 2008
    Location
    Vancouver, BC
    Posts
    768

    Default

    Well, if the need becomes big enough, we can consider relaxing the requirement that ITD-awareness is disabled in all Java projects. It could be possible to walk the project dependency graph to see if any project upstream is an AJ project and if so we could enable ITD-awareness in the Java project. But, I'm still a little concerned about the performance impacts in the Java projects.
    Andrew Eisenberg, Ph.D.
    SpringSource, a division of VMware
    SpringSource Tools Team
    More about AJDT, Groovy-Eclipse, and Grails tooling

  7. #7
    Join Date
    Jan 2010
    Posts
    29

    Default

    yeah understood.

    i'm wondering if there's a way to have a project reference exported as a jar to ProjectB each time its compiled (this is basically the way .NET does things). When I use the jar reference everybody's happy, its only when I use the direct project ref that things go wrong.

  8. #8
    Join Date
    May 2009
    Location
    Vancouver
    Posts
    274

    Default

    Quote Originally Posted by benmonro View Post
    i'm wondering if there's a way to have a project reference exported as a jar to ProjectB each time its compiled (this is basically the way .NET does things). When I use the jar reference everybody's happy, its only when I use the direct project ref that things go wrong.
    Hi,

    You can achieve something like that if you change from a Project dependency to a class folder dependency. In Project Properties for your Java project, select Java Build Path. Click 'Libraries' on the right and 'Add Class Folder'. Then add the output folder of the AJ project as a class folder dependency for your java project. This is similar to what you described above but avoids the need to use a packaged jar.

    Let me know how that works out for you,

    cheers,
    Andy
    ---
    Andy Clement
    AspectJ Project Lead

  9. #9
    Join Date
    Jan 2010
    Posts
    29

    Default

    Well guys I tried a bunch of differnt ways to do this, but just couldnt get it working. Instead of running this in an android project, I went to a simple Java project. When I run a main method w/ a reference to the jar (i used the export feature of eclipse to export the roo gen'd library), I do the following code:

    Code:
    		Person p = new Person();
    		p.setName("ben");
    		
    		System.out.println(p.getName());
    I then get the following exception:

    Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/beans/factory/aspectj/ConfigurableObject
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    	at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    	at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
    	at com.ProjectB.MainClass.main(MainClass.java:11)
    Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.aspectj.ConfigurableObject
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
    	... 13 more

  10. #10
    Join Date
    Aug 2008
    Location
    Vancouver, BC
    Posts
    768

    Default

    I'm assuming that you are getting this when you are running, but not when compiling.

    Unfortunately, because of all of ROO's dependencies, this is not as easy as it should be. What is happening is that the jar from the roo project has lots of other dependencies that must be included on the classpath of the launch.

    So, to fix this, in your launch configuration tab, you must include all the jars that are on the ROO classpath for the roo project.
    Andrew Eisenberg, Ph.D.
    SpringSource, a division of VMware
    SpringSource Tools Team
    More about AJDT, Groovy-Eclipse, and Grails tooling

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •