Iam new to groovy on grails.
In my grails application i have to edit a property file without deleting other key values for that Iam using apache commons following code
PropertiesConfiguration conf = new PropertiesConfiguration("config.properties");
props.setProperty("key", "value");
conf.save();
In BuildConfig.groovy I have included the depentencies
dependencies {
compile 'org.apache.commons:commons-configuration2:2.2'
compile 'org.apache.commons:commons-lang3:3.1'
}
While executing grails compile the dependencies seems to be downloaded without any error, but that Iam getting the compilation error
unable to resolve class org.apache.commons.configuration.PropertiesConfiguration
[groovyc] # line 5, column 1.
[groovyc] import org.apache.commons.configuration.PropertiesConfiguration;
[groovyc] ^
[groovyc]
What additional settings that i need to do in grails please suggest
Use
import org.apache.commons.configuration2.PropertiesConfiguration;
Note the 2 at the end of configuration!
I'm in process of upgrading an app from Grails v2 to v3 .
I got to a point where it works reasonably well with Grails 3.0.17.
I wanted to upgrade it to v3.1 or v3.2. But after changing the version in gradle.properties that's what I get after executing grails run-app:
me#host:[~/](feature/grails3-migration) : grails run-app
| Error Error occurred running Grails CLI: startup failed:
script14867378818131525390840.groovy: 3: unable to resolve class xxx.yyy.CollectorsJob
# line 3, column 1.
import xxx.yyy.jobs.CollectorsJob
^
script14867378818131525390840.groovy: 6: unable to resolve class xxx.yyy.domain.business.Company
# line 6, column 1.
import xxx.yyy.domain.business.Company
^
script14867378818131525390840.groovy: 5: unable to resolve class xxx.yyy.domain.access.User
# line 5, column 1.
import xxx.yyy.domain.access.User
^
...
There's about 15 errors like that printed.
What's the problem here? I've tried clear the project and change the jdk version fro 1.8 -> 1.7. Each time the same result.
If you are referencing application classes in grails-app/conf/application.groovy these will need to be moved to your runtime configuration in grails-app/conf/runtime.groovy
The application.groovy file is parsed by the build system in addition to the runtime so cannot contain references to classes that are not yet compiled
The script is working fine in groovy console. But when I do check-syntax for the same script in Jenkins, the following error message is coming up -
Script1.groovy: 6: unable to resolve class groovyx.net.http.RESTClient
# line 6, column 1.
import groovyx.net.http.RESTClient
^
Script1.groovy: 4: unable to resolve class groovyx.net.http.ContentType
# line 4, column 1.
import groovyx.net.http.ContentType
^
Script1.groovy: 3: unable to resolve class groovyx.net.http.HTTPBuilder
# line 3, column 1.
import groovyx.net.http.HTTPBuilder....
How to get this issue resolved?
This exception is because you dont have these dependencies (Jars) that has these classes so you have two option :
1- if you currently using any dependency management framework like (maven,gradle) then just add these dependencies
2- in the groovy file at the top add #Grapes and then add the dependency here an example :
#Grapes(
#Grab(group='yourDependencyGroupID', module='yourDependencyArtifactID'
, version='theDesireVersion')
)
you can search for these dependencies in Maven Repository
i hope this will help :)
I am trying to install excel-plugin but I got an error resolving class.
..\plugins\excel-export-0.2.1\src\groovy\pl\touk\excel\export\XlsxExporter.groovy: 3: unable to resolve class groovy.transform.TypeChecked
# line 3, column 1.
import groovy.transform.TypeChecked
^
as installations say I have this in my BuildConfig file.
inherits("global") {
excludes 'xercesImpl'
excludes 'xercesImpl', 'xml-apis'
}
plugins {
runtime (":excel-export:0.2.1")
}
Any ideas ? I dont know which library I need.
I am using Grails 2.1.5
I've run into the same problem.
If you just uncomment the annotation at the start of the AdditionalSheet.groovy and XlsxExporter.groovy (and the import), your project should compile.
Here are the logs from startup
| Compiling 342 source files.
| Error Compilation error: startup failed:
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 19: unable to resolve class org.tmatesoft.svn.core.wc.SVNStatus
# line 19, column 1.
import org.tmatesoft.svn.core.wc.SVNStatus
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 7: unable to resolve class org.tmatesoft.svn.core.SVNProperties
# line 7, column 1.
import org.tmatesoft.svn.core.SVNProperties
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 10: unable to resolve class org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory
# line 10, column 1.
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 16: unable to resolve class org.tmatesoft.svn.core.wc.SVNCopyClient
# line 16, column 1.
import org.tmatesoft.svn.core.wc.SVNCopyClient
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 17: unable to resolve class org.tmatesoft.svn.core.wc.SVNCopySource
# line 17, column 1.
import org.tmatesoft.svn.core.wc.SVNCopySource
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 4: unable to resolve class org.tmatesoft.svn.core.SVNDepth
# line 4, column 1.
import org.tmatesoft.svn.core.SVNDepth
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 5: unable to resolve class org.tmatesoft.svn.core.SVNException
# line 5, column 1.
import org.tmatesoft.svn.core.SVNException
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 20: unable to resolve class org.tmatesoft.svn.core.wc.SVNStatusClient
# line 20, column 1.
import org.tmatesoft.svn.core.wc.SVNStatusClient
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 12: unable to resolve class org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl
# line 12, column 1.
import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 3: unable to resolve class org.tmatesoft.svn.core.SVNAuthenticationException
# line 3, column 1.
import org.tmatesoft.svn.core.SVNAuthenticationException
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 24: unable to resolve class org.tmatesoft.svn.core.wc.SVNWCUtil
# line 24, column 1.
import org.tmatesoft.svn.core.wc.SVNWCUtil
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 6: unable to resolve class org.tmatesoft.svn.core.SVNNodeKind
# line 6, column 1.
import org.tmatesoft.svn.core.SVNNodeKind
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 21: unable to resolve class org.tmatesoft.svn.core.wc.SVNStatusType
# line 21, column 1.
import org.tmatesoft.svn.core.wc.SVNStatusType
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 13: unable to resolve class org.tmatesoft.svn.core.io.SVNRepositoryFactory
# line 13, column 1.
import org.tmatesoft.svn.core.io.SVNRepositoryFactory
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 11: unable to resolve class org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory
# line 11, column 1.
import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 15: unable to resolve class org.tmatesoft.svn.core.wc.SVNCommitClient
# line 15, column 1.
import org.tmatesoft.svn.core.wc.SVNCommitClient
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 18: unable to resolve class org.tmatesoft.svn.core.wc.SVNRevision
# line 18, column 1.
import org.tmatesoft.svn.core.wc.SVNRevision
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 22: unable to resolve class org.tmatesoft.svn.core.wc.SVNUpdateClient
# line 22, column 1.
import org.tmatesoft.svn.core.wc.SVNUpdateClient
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 23: unable to resolve class org.tmatesoft.svn.core.wc.SVNWCClient
# line 23, column 1.
import org.tmatesoft.svn.core.wc.SVNWCClient
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 8: unable to resolve class org.tmatesoft.svn.core.SVNPropertyValue
# line 8, column 1.
import org.tmatesoft.svn.core.SVNPropertyValue
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 14: unable to resolve class org.tmatesoft.svn.core.wc.ISVNStatusHandler
# line 14, column 1.
import org.tmatesoft.svn.core.wc.ISVNStatusHandler
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnClient.groovy: 9: unable to resolve class org.tmatesoft.svn.core.SVNURL
# line 9, column 1.
import org.tmatesoft.svn.core.SVNURL
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnScmProvider.groovy: 4: unable to resolve class org.tmatesoft.svn.core.wc.SVNWCUtil
# line 4, column 1.
import org.tmatesoft.svn.core.wc.SVNWCUtil
^
C:\Users\shravan64\.grails\2.1.0\projects\gurujiAatma\plugins\svn-1.0.2\src\groovy\grails\plugin\svn\SvnScmProvider.groovy: 3: unable to resolve class org.tmatesoft.svn.core.SVNAuthenticationException
# line 3, column 1.
import org.tmatesoft.svn.core.SVNAuthenticationException
While my colleague and I have still have not discovered the reason this is happening (the Release 1.0.1 and SVN 1.0.2 plugins are being pulled into this app despite no reference in any of the in-house plugins or app itself's application.properties or BuildConfig.groovy), we have discovered a make-shift solution.
In the failing app's BuildConfig.groovy, if you specify
build ":release:2.2.1"
as a dependency, and you run
grails uninstall-plugin svn
on your command line, you should be able to stay on Grails 2.1.0 and keep this compilation error from occuring.
I will update my answer here if I'm ever able to find out why the old release plugin was being pulled in as a dependency ( I had bombed my ~/.grails folder as well as my ~/.ivy2, so I really have no idea why it was being pulled in ).
I encountered this when first building a WAR file containing a reference to a plugin in my company's Grails SVN repository. I fixed it by adding the following to the dependencies section in BuildConfig.groovy, taken from the svn plugin's dependencies:
build("org.tmatesoft.svnkit:svnkit:1.3.5") {
excludes "jna", "trilead-ssh2", "sqljet"
}
It appears that the svn 1.0.2 plugin is not working well with grails 2.1.0. Downgrading to grails 2.0.4 seems to have resolved the issue.
I had checked out the project with svn 1.7 and had the exact same problem.
A friend mentioned svnkit is very sensitive about svn version. I removed the project and checked it out again with svn 1.6 and then it compiled with no issue.
Needless to say, I'll be moving this project to git ASAP. :)