2
votes

I get build errors in the GGTS Groovy error when I import a class from an external jar.

I've added a jar dependency to my Grails project using BuildConfig.groovy that is installed to my local maven repo:

grails.project.dependency.resolution = {
...
  repositories {
    ...
    mavenLocal()
  }
...
}

dependencies {
  runtime(group: 'groupId', name: 'nameId', version: 'versionId')
}

When I import a class from that jar, I get the error in the GGTS Groovy editor Groovy: unable to resolve class... I can run grail compile and grails run-app from either the command line or GGTS. So clearly Grails has no problem finding the jar and referencing it from my code.

Another question suggested that the user run 'Refresh dependencies (or shortcut "Alt+G, R")' but that results in an error dialog.

Refresh dependecies failed
 java.lang.NullPointerException

Opening up the Error Log View shows the stacktrace:

java.lang.NullPointerException
at org.grails.ide.eclipse.core.internal.classpath.PluginDescriptorParser.handleSimpleNode(PluginDescriptorParser.java:216)
at org.grails.ide.eclipse.core.internal.classpath.PluginDescriptorParser.parse(PluginDescriptorParser.java:100)
at org.grails.ide.eclipse.core.internal.classpath.GrailsPluginParser.parse(GrailsPluginParser.java:39)
at org.grails.ide.eclipse.core.internal.plugins.PerProjectPluginCache.parseData(PerProjectPluginCache.java:110)
at org.grails.ide.eclipse.core.internal.plugins.PerProjectPluginCache.initializePluginData(PerProjectPluginCache.java:81)
at org.grails.ide.eclipse.core.internal.plugins.PerProjectPluginCache.refreshDependencyCache(PerProjectPluginCache.java:103)
at org.grails.ide.eclipse.commands.GrailsCommandUtils$1.run(GrailsCommandUtils.java:392)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2345)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2327)
at org.grails.ide.eclipse.commands.GrailsCommandUtils.refreshDependencies(GrailsCommandUtils.java:372)
at org.grails.ide.eclipse.core.internal.classpath.GrailsClasspathContainerUpdateJob.runInWorkspace(GrailsClasspathContainerUpdateJob.java:89)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

I am using:

Grails 1.3.7
GGTS 3.4.0.RELEASE-e4.3.1-linux-gtk-x86_64

How do I fix this error and be able to edit my code in GGTS without errors?

1

1 Answers

0
votes

I faced a similar issue in GGTS where the project was getting compiled fine from command prompt (grails run-app) but GGTS was showing problem as "Unable to resolve class GrailsTestCase". I checked Dependency management (project right click -> Grails Tools) and it was enabled. I just disabled it and enabled it again. This resolved the issue in my case. Could be some problem with IDE.