Announcement Announcement Module
Collapse
No announcement yet.
Groovy:unable to resolve class although same package (again) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Groovy:unable to resolve class although same package (again)

    After updating to STS 2.3.3.M1 and grails 1.3.1, I first thought that my problem described in thread http://forum.springsource.org/showthread.php?t=89927 was gone, but it re-appeared. Unfortunately I cannot reproduce it in a smaller vanilla project, it's only in my bigger project with several domain, controller and service classes. The workaround described below still works, but it's really tedious to do it all the time and to see the code with lots of errors after a while again.

    Here is the problem description and the workaround again (I haven't had the breakpoint issue described in the previous thread anymore, only the unable to resolve issue):

    STS sometimes does not resolve domain classes. I get the typical red cross saying "Groovy:unable to resolve class ...", e.g. when working in a controller, although the domain classes and the controller are in the same package.

    The strange thing is that these errors disappear when I do the following: In the Project Properties, I add an arbitrary exclusion to the domain class source folder, e.g. "xyz". After leaving the dialog, the project refreshes and the errors are gone; then I can also remove the dummy filter again.

    Only when I start working in (i.e. editing) classes again (not only controllers but also test cases etc. which all share the same package), STS starts adding the cannot resolve errors within the classes I work on. I can also remove the errors by using the full package and class name, but I think that's not a clean solution for classes within one package.

  • #2
    Re: Groovy:unable to resolve class although same package (again)

    One additional note: The problem occurs where I explicitly assign a class instead of using def, e.g.

    MyService myService (instead of def myService)
    or
    MyDomainClass myDomainClassInstance (instead of def myDomainClassInstance)

    But this doesn't seem to be a problem in a vanilla project.

    Comment


    • #3
      Hi,

      I would like to get to the bottom of this problem, but it is going to be tough if I can't recreate it. Can you privately share the project with me that has the issue? If I can recreate then it would be cleared up within 24hours... I do believe it will be a groovy eclipse thing.

      Andy
      ---
      Andy Clement
      SpringSource

      Comment


      • #4
        Re: Groovy:unable to resolve class although same package (again)

        Thank you for your support! I'll try to extract a part where the problem still appears, may take a little time though.

        Comment


        • #5
          Hi,

          I don't particularly mind if you have to send me the whole thing - the problem should be straightforward to investigate once I have some piece of code that fails. But I understand if you don't want to share the whole application with me.

          cheers,
          Andy

          Comment


          • #6
            Hi, has there been any update on this issue. I am having a similar problem after running a Grails upgrade today.

            I am now getting multiple "Groovy: unable to resolve class ..." errors for a project I am working on at the moment even though the "missing" classes are clearly present in the package.

            It doesn't appear to affect the Grails app when executed, but it is clearly an issue that needs to be addressed.

            I am new to both Grails and STS and am not in a position to diagnose this issue myself to any great extent. Any help would be greatly appreciated.

            Thanks, Innes (NZ)

            Comment


            • #7
              Hi,

              As I replied to werner5471, if you can share a project with me that exhibits the problem, I should be able to fix it pretty quickly. Without the ability to recreate, I just don't know what it will be. I've seen a recent issue with using types from the default package in some other package, but that doesn't sound like what you are doing. Can you share the code with me?

              thanks,
              Andy
              ---
              Andy Clement
              SpringSource

              Comment


              • #8
                Hi Andrew,

                Thanks ... no problem at all to share my code. What is the best way to send you everything that you need to do the diagnosis?

                Cheers, Innes (NZ)

                Comment


                • #9
                  Hi,

                  Awesome! Just email it to me if you can: andy.clementATspringsource.com

                  cheers
                  Andy
                  ---
                  Andy Clement
                  SpringSource

                  Comment


                  • #10
                    same error: Groovy:unable to resolve class

                    Has there been any resolution on this? I too am getting an error in my controller when I try to instantiate an object. I have a domain and controller both created in a package, com.site.app. When I add something to the controller to use the domain object, it gets flagged with the error.
                    Code:
                    def help = {
                        def loc = new Location()
                    }
                    When I hover over 'new' it shows an error, but when I hover over 'Location' it can identify the class, and if I click and F3 it goes into the class just fine. Code runs just fine too, it's only an error in Eclipse, and also when I generate a war file it always sees the error and prompts if I really want to continue.

                    I tried using the full package, ie com.site.app.Location(), and also importing the class specifically in the controller, and in both cases the error still remained.

                    Using STS Version: 2.3.3.CI-R5547-B44, Build Id: 201008100801, with Grails 1.3.4 and the Groovy-Eclipse extension.

                    Comment


                    • #11
                      Innes shared his code with me and I was able to fix it for his case. Does your error solely appear in the editor or also in the problems view?

                      If you are able to share a failing project with me, I'll investigate your case (send it to the email address I previously posted)

                      Other than that, make sure you are on the latest groovy-eclipse (update site):
                      http://dist.codehaus.org/groovy/dist...snapshot/e3.6/
                      which appears to be 2.0.2.xx-20100908-0900-e36

                      You are on 3.6 aren't you?

                      cheers
                      Andy
                      ---
                      Andy Clement
                      SpringSource

                      Comment


                      • #12
                        I also had this "unable to resolve class" Error-Message problem within an extends statement even when the path to the class was there and no package naming thingy was there.

                        The solution in my case was not the command grails clean in the grails command prompt but just using the normal eclipse menu Project... Clean... and then selecting my project there and let eclipse clean.

                        This made the Error-Message to disappear even after several grails run-app, grails compile and so on.

                        I have no clue why this works... but it helped

                        Comment


                        • #13
                          Thanks! The Eclipse clean option worked for me... That had been annoying me for 3 days.

                          Comment


                          • #14
                            Good!!

                            Thanks guys the Project->Clean... option works for me too!

                            Comment


                            • #15
                              I am also on the latest build and was frustrated to see that this did resolve my problem. I am having serious considerations about buying the tool after having sooooo many of these type of issues.

                              SpringSource Tool Suite

                              Version: 2.6.0.RELEASE
                              Build Id: 201103161000

                              Copyright (c) 2007 - 2011 SpringSource, a division of VMware, Inc.
                              All rights reserved. Visit http://springsource.com/products/sts

                              This product includes software developed by the
                              Apache Software Foundation http://www.apache.org

                              Comment

                              Working...
                              X