Groovy/Grails - Unable to Resolve Class
Asked Answered
G

5

8

I am trying to build a Grails project in STS and am getting many error messages of the form: Groovy:unable to resolve class org.codehaus.groovy.grails.commons.ConfigurationHolder as well as others like Groovy:unable to resolve class org.grails.plugins.springsecurity.service.AuthenticateService . I have Grails 1.3.7 selected in the Project Properties, but I don't see an item for 'Grails Depedencies' like I do when I create a sample project. Is this the problem? How can I add it back in?

Galipot answered 29/5, 2011 at 13:20 Comment(2)
Do you see these errors while you're editing classes, or just when you're trying to run the project?Harwill
@Kaleb Brasee - When I try to do a build. Also, I think I just resolved the ConfigurationHolder errors by Refreshing Dependencies, which created the 'Grails Dependencies' in my project. I am still getting the AuthenticateService error, despite the fact that I have the acegi plugin in my project.Galipot
G
20

I don't know why, but here are the steps I took to solve the problem:

  1. Right click on the project and go to Grails Tools -> Enable Dependency Management
  2. Grails Tools -> Refresh Dependencies. This correctly added the 'Grails Dependencies' library.
  3. I still had plugin errors. I for some reason had to uninstall them and then reinstall them for the project to realize they were there.
Galipot answered 29/5, 2011 at 14:9 Comment(1)
I have a similar error "Unable to resolve class" on external libraries such as import com.beust.jcommander.JCommander. I am using Gradle but no Grails. How can I let my Groovy project locate the external libraries?Operand
C
7

For anyone who is using Grails >= 2.4

If you are using Grails 2.4 and above, use grails.util.Holders instead of org.codehaus.groovy.grails.commons.ConfigurationHolder.

Read the doc here section 'Static Holder'

Classes The following deprecated classes have been removed from Grails 2.4.x:

org.codehaus.groovy.grails.commons.ApplicationHolder org.codehaus.groovy.grails.commons.ConfigurationHolder org.codehaus.groovy.grails.plugins.PluginManagerHolder org.codehaus.groovy.grails.web.context.ServletContextHolder org.codehaus.groovy.grails.compiler.support.GrailsResourceLoaderHolder If you or any plugins you have installed are using these classes you will get a compilation error. The problem can be rectified by updating to new plugins and using grails.util.Holders instead.

Chap answered 8/12, 2014 at 14:37 Comment(0)
I
2

If "Refresh Dependencies" has done all it can for you (as you indicate in your comment on the question), try disabling and re-enabling dependencies. You might try refreshing dependencies again afterward if the Acegi plugin still isn't recognized.

Inbound answered 31/5, 2011 at 19:28 Comment(0)
S
0

there is another way solved me this issue when i moved my workspace from Windows OS to Ubuntu , go to

yourWorkSpace -->yourGrailsProject-->setting folder --> org.grails.ide.eclipse.core.prefs, 

then check all the grails paths are correct or not , because in my case all were pointing to windows paths ..

Hope this solve.

Sensibility answered 19/11, 2014 at 12:35 Comment(0)
G
0

I faced a similar issue: "Unable to resolve class GrailsTestCase". I checked Grails Tools of my project and observed Dependency Management was already enabled (IDE - GGTS). I just disabled Dependency Management, refreshed and enabled it again. This solved the issue for me.

Garlen answered 26/2, 2015 at 5:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.