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?
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.
Related
I'm trying to use the grails standalone plugin with a new grails project but I can't get it to work.
I've added it as a plugin dependency in my BuildConfig.groovy file:
plugins {
compile: ":standalone:1.2.3"
}
But I get the following error when I attempt to run grails prod build-standalone:
Script 'BuildStandalone' not found, did you mean:
1) InstallDependency
2) Stats
3) InstallJQuery
4) CreateMultiProjectBuild_
5) TestApp
I tried running grails clean, grails clean-all, grails refresh-dependencies, and grails compile as answered in this question, but nothing seems to help. I would expect refresh-dependencies to either download the necessary artifacts or fail trying.
What am I doing wrong?
Here is my environment:
Mac OS X 10.9.5
JDK 1.8.0_05
Grails v2.4.4 installed with GVM
Always run grails compile after editing dependencies in BuildConfig.groovy; this triggers dependency resolution and installs the plugin, downloads the jars and adds them to the classpath etc. Once that happens the plugins' scripts will resolve.
When creating a basic grails plugin and compiling with Maven, I get this error message:
Error loading plugin manager: Could not create a new instance of class
[org.codehaus.groovy.grails.plugins.web.mapping.UrlMappingsGrailsPlugin]!
(Use --stacktrace to see the full trace)
Grails version 2.4.3
The solution to this issue is to add the tomcat plugin (no idea why):
Add this to BuildConfig.groovy:
build ":tomcat:7.0.55"
Then you may need to regenerate the pom.xml file using grails create-pom.
This appears to be related to this bug.
My application uses grails 1.3.7 with quartz scheduler 1.0-RC1 plugin. It runs fine locally on tomcat when I run it using grails run-app. However, when I create a war file using grails prod war and deploy it in WebLogic, I'm getting the below error:
SLF4J: The requested version 1.5.8 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
log4j:ERROR Error initializing log4j: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.trace(SLF4JLocationAwareLog.java:107)
at org.apache.commons.beanutils.BeanUtilsBean.convert(BeanUtilsBean.java:1073)
I figured this is because grails 1.3.7 uses slf4j 1.5.8, but the quartz plugin uses 1.6.0 and hence there's a conflict. I tried to address it by excluding the slf4j-api jar in BuildConfig.groovy like:
plugins {
compile(":quartz:1.0-RC1") { excludes "slf4j-api" }
}
I was hoping the above config entry would prevent slf4j 1.6.0 from being downloaded and resolve the conflict. But it isn't. When I run grails dependency-report, I still see the conflict and I'm unable to deploy the application in WebLogic.
EDIT: Screenshot of the conflict from grails dependency-report:
Any pointers to resolve this?
You have conflict of jar file. Weblogic comes with sl4j by default and your war file should also contain sl4j jar file inside WEB-INF\lib folder. You can try changing class loading to parent last from admin console.
I resolved this issue by using the code below in BuildConfig.groovy to exclude slf4j-api-1.6.0.jar from the packaged war. The suggestion was posted here
grails.war.resources = { stagingDir ->
delete(file:"${stagingDir}/WEB-INF/lib/slf4j-api-1.6.0.jar")
}
I also had to add slf4j-api-1.5.8.jar to the project's lib folder.
I have created a Grails plugin using Grails 2.3.3 and trying to use the plugin in a Grails application which was also created using Grails 2.3.3. Now, to use the plugin in the application, it needs to be published to a plugin repository first. So I attempted to publish the plugin into the local repository by using the commands:
grails clean
grails compile
grails maven-install
For the grails maven-install command I selected the option 2)InstallPlugin. But then got an error:
Error installing plugin: No such property: ERROR_MESSAGE for class: Inst
allPlugin (Use --stacktrace to see the full trace)
Ran the last command above with option --stacktrace and --verbose but did not get any clue as to what the problem might be. I also removed %HOME%/.grails directory and reran the above commands and still came with the same error.
After googling, I found a JIRA for this issue which was closed stating that it happens when Grails version is changed and cleaning up cache files will get rid of this issue. However, that solution is not working for me and, by now, I have spent couple of hours trying to fix this. Also I did not change my Grails version.
Has anyone faced this issue with Grails 2.3.3 or with any recent version of Grails? What was the solution?
Don't use install-plugin, add a dependency in BuildConfig.groovy.
I don't know where the 2)InstallPlugin "option" is coming from. The maven-install script packages your plugin and generates a POM file and the other files needed to be a valid published plugins. Then it copies these files to your local M2 directory, e.g. if your plugin name is "mycoolplugin" the files are copied to $HOME/.m2/repository/org/grails/plugins/mycoolplugin
Now you can "install" the plugin as if it had been published in a remote repo. Add a dependency in the app's BuildConfig.groovy using the usual format, e.g.
plugins {
build ":tomcat:7.0.50"
compile ":scaffolding:2.0.1"
runtime ":hibernate:3.6.10.7"
...
compile ":mycoolplugin:0.1"
}
in my grails 2.3.4 application (after upgrading from grails 2.2.3) , when I run the grails command line grails install-plugin pluginname I get the below error , even I tried grails list-plugins I'm getting the same error:
Error Resolve error obtaining dependencies: Failed to resolve dependencies (Se log level to 'warn' in BuildConfig.groovy for more information): org.grails.plugins:tomcat:2.3.4 (Use --stacktrace to see the full trace)
i reviewed the BuildConfig.groovy there is no tomcat 2.3.4 what i'm using is 7.0.47 , here are my plugins :
runtime ":hibernate:3.6.10.6"
runtime ":jquery:1.8.3"
runtime :resources:1.1.6
build ":tomcat:7.0.47"
runtime database-migration:1.2.1
compile :cache:1.0.1
how i can solve this issue ?
you problem seems slovable due to the fact that ...you need to clean the grails project first without building it and then do
grails refresh-dependencies
and then finally
grails clean
and
grails compile
When you run refresh-dependencies your Grails application will try to resolve your grails plugins defined in BuildConfig.groovy file. If this doesn't work remove the plugins and do the above step until the error you have posted in the question vanished then add the correct plugin format and version with the correct precedence dependency, then make sure everything should work well.
Your dependencies are in a dependency block, but they are plugins. Put them in the plugins block of your BuildConfig.groovy file. So instead of what you have, put this:
plugins {
runtime ":hibernate:3.6.10.6"
runtime ":jquery:1.8.3"
runtime ":resources:1.1.6"
build ":tomcat:7.0.47"
runtime ":database-migration:1.2.1"
compile ":cache:1.0.1"
}
Also, this is no "dependency" block. This is a dependencies block, however. See this link for information on dependency resolution in Grails.
I need to add the following repo in buildconfig.groovy to the repositories section:
mavenRepo "https://repo.grails.org/grails/plugins"