Upgrading Grails from v3.0 to v3.1 or v3.2 - grails

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

Related

Unable to compile groovy script in Jenkins

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 :)

Grails 3 scaffolding issue

I'm trying to port my project from Grails 2.4 to 3.0. Nothing fancy: 12 Domains, 13 Controllers and a service.
Everything works fine, except when I try to include the Scaffolding plugin. I literally follow the manual here, but the syntax must be wrong. Adding the plugin line as specified:
plugins {
…
compile ":scaffolding:2.0.0"
…
}
leads to this:
BUILD FAILED
Total time: 1.559 secs
| Error Error initializing classpath: startup failed:
build file 'E:\GrailsIdeaProjects\HcaServer\build.gradle': 17: only id(String) method calls allowed in plugins {} script block
See http://gradle.org/docs/2.3/userguide/plugins.html#sec:plugins_block for information on the plugins {} block
# line 17, column 5.
compile ":scaffolding:2.0.0"
^
1 error
(Use --stacktrace to see the full trace)
Somebody knows the right syntax to include the Scaffolding plugin in Grails 3?
EDIT: Thanks to Casey for pointing me in the right direction: Scaffolding plugin is actually already included in default build.gradle. Anyway, i still get a webpage like this on every controller:
Error: Page Not Found (404)
Path: /*controllerName*/index
I've been using the same syntax as per the manual, declaring a static scaffold = true on each controller. Why do I get a 404 page then? I do have index.gsp, error.gsp and notFound.gsp in my views folder.
It looks like that documentation hasn't been updated for Grails 3.0 yet. Your build.gradle file should have a dependencies block, where you can specify the dependency:
dependencies {
// ...
runtime "org.grails.plugins:scaffolding"
}
You can also see this by creating a new app using Grails 3.0 and checking out the default build.gradle file.
After researching for a while, turns out dynamic scaffolding hasn't made it yet into Grails 3:
https://groups.google.com/forum/m/#!topic/grails-dev-discuss/6R2YaF96Uts
Try this, It works for me.
dependencies {
compile "org.grails.plugins:scaffolding"
}
I am using grails 3.09.

Grails Plugin Uploadr doesn't run

I'm trying to use uploadr but I cannot put it to work... Even the Uploadr-demo does not run.
So, it's what I have tried so far:
Using Grails 2.4.2 and adding the plugin in a existing project:
I get this error when I run the project:
| Error 2014-07-16 16:00:54,667 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/jquery.tipTip.minified.js
| Error 2014-07-16 16:00:54,697 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/tipTip.css
| Error 2014-07-16 16:00:54,727 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/jquery.uploadr.js
| Error 2014-07-16 16:00:54,754 [localhost-startStop-1] ERROR resource.ResourceMeta - Resource not found: /assets/jquery.uploadr.css
However the server starts, but when I try to open the page using uploadr I get this error:
Error 500: Internal Server Error
[...]
Class: java.lang.IllegalArgumentException
Message: Module [tipTip] depends on resource [/assets/jquery.tipTip.minified.js] but the file cannot be found
The page I'm trying to open is just to call the uploadr demo:
<head>
<g:javascript library='jquery' />
<r:require modules="uploadr"/>
<r:layoutResources/>
</head>
<body>
<uploadr:demo/>
<r:layoutResources/>
</body>
The BuildConfig:
plugins {
// plugins for the build system only
build ":tomcat:7.0.54"
// plugins for the compile step
compile ":scaffolding:2.1.2"
compile ':cache:1.1.7'
compile ":asset-pipeline:1.8.11"
//uploadr
runtime ":resources:latest.integration"
compile ":modernizr:latest.integration"
compile ":uploadr:latest.integration"
compile ":quartz:latest.integration" //1.0.1"
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.5.4" // or ":hibernate:3.6.10.16"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
}
As it didn't work I tried to download the Uploadr-demo from github.
First it I couldn't import (I'm using Spring Tool Suite v.:3.5.1.RELEASE) because the demo is to grails 2.3.3. Fine, I got grails 2.3.3, and again it didn't work. This time a new error:
Loading Grails 2.3.3
|Environment set to development
........
|Compiling 10 source files
..
|Compiling 154 source files
.Error
|
Compilation error: startup failed:
/home/ainsoph/workspace-sts-3.5.1.RELEASE/grails-uploadr-demo/target/work/plugins/uploadr-0.8.2/grails-app/controllers/hungry/wombat/UploadController.groovy: -1: Repetitive method name/signature for method 'java.lang.Object withFormat(groovy.lang.Closure)' in class 'hungry.wombat.UploadController'.
# line -1, column -1.
/home/ainsoph/workspace-sts-3.5.1.RELEASE/grails-uploadr-demo/target/work/plugins/uploadr-0.8.2/grails-app/controllers/hungry/wombat/UploadController.groovy: -1: Repetitive method name/signature for method 'java.lang.Object withFormat(groovy.lang.Closure)' in class 'hungry.wombat.UploadController'.
# line -1, column -1.
/home/ainsoph/workspace-sts-3.5.1.RELEASE/grails-uploadr-demo/target/work/plugins/database-migration-1.3.8/grails-app/controllers/grails/plugin/databasemigration/DbdocController.groovy: -1: Repetitive method name/signature for method 'java.lang.Object withFormat(groovy.lang.Closure)' in class 'grails.plugin.databasemigration.DbdocController'.
# line -1, column -1.
/home/ainsoph/workspace-sts-3.5.1.RELEASE/grails-uploadr-demo/target/work/plugins/database-migration-1.3.8/grails-app/controllers/grails/plugin/databasemigration/DbdocController.groovy: -1: Repetitive method name/signature for method 'java.lang.Object withFormat(groovy.lang.Closure)' in class 'grails.plugin.databasemigration.DbdocController'.
# line -1, column -1.
4 errors
I also tried to create a new project with grails 2.3.3, but it doesn't even compile:
Command terminated with an exception: java.lang.Exception (see details for partial output)
Command: GrailsCommand(P/grails-uploadr> compile --non-interactive --refresh-dependencies)
---- System.out ----
Loading Grails 2.3.3
.
|Environment set to development
..........
|Compiling 79 source files
.Error
|
Compilation error: startup failed:
/home/ainsoph/workspace-sts-3.5.1.RELEASE/grails-uploadr/target/work/plugins/database-migration-1.3.8/grails-app/controllers/grails/plugin/databasemigration/DbdocController.groovy: -1: Repetitive method name/signature for method 'java.lang.Object withFormat(groovy.lang.Closure)' in class 'grails.plugin.databasemigration.DbdocController'.
# line -1, column -1.
/home/ainsoph/workspace-sts-3.5.1.RELEASE/grails-uploadr/target/work/plugins/database-migration-1.3.8/grails-app/controllers/grails/plugin/databasemigration/DbdocController.groovy: -1: Repetitive method name/signature for method 'java.lang.Object withFormat(groovy.lang.Closure)' in class 'grails.plugin.databasemigration.DbdocController'.
# line -1, column -1.
2 errors
When I tried to create a new project with grails 2.3.3 I first changed the $GRAILS_HOME to point to 2.3.3 and I called spring from a terminal that had its path updated
Well I tried everything that I could think or find on Google... Any ideas?
I managed a work around, it's running, but still with errors...
I installed Grails 2.3.3 and Oracle jdk1.7.0_65. Using both I can create a new project where uploadr works, and I also can run the uploadr-demo, but both with the errors below:
Groovy: compiler mismatch Project level is: 2.1 Workspace level is 2.3
Groovy compiler level expected by the project does not match workspace compiler level.
Go to Project properties -> Groovy compiler to set the Groovy compiler level for this project uploadr-Grails2.3.3-JDK7 uploadr-Grails2.3.3-JDK7 Groovy compiler mismatch problem
The resource is a duplicate of .link_to_grails_plugins/hibernate-3.6.10.4/grails-app/i18n/messages.properties and was not copied to the output folder messages.properties /uploadr-Grails2.3.3-JDK7/.link_to_grails_plugins/resources-1.2.1/grails-app/i18n Unknown Java Problem
Groovy:Repetitive method name/signature for method 'java.lang.Object withFormat(groovy.lang.Closure)' in class 'br.eti.andersonq.UploadrController'. UploadrController.groovy /uploadr-Grails2.3.3-JDK7/grails-app/controllers/br/eti/andersonq line 1 Java Problem
Groovy:Repetitive method name/signature for method 'java.lang.Object withFormat(groovy.lang.Closure)' in class 'br.eti.andersonq.UploadrController'. UploadrController.groovy /uploadr-Grails2.3.3-JDK7/grails-app/controllers/br/eti/andersonq line 1 Java Problem
The resource is a duplicate of .link_to_grails_plugins/resources-1.2.9-SNAPSHOT/grails-app/i18n/messages.properties and was not copied to the output folder messages.properties /Blogito/.link_to_grails_plugins/uploadr-0.8.2/grails-app/i18n Unknown Java Problem
Groovy:Repetitive method name/signature for method 'java.lang.Object withFormat(groovy.lang.Closure)' in class 'grails.plugin.databasemigration.DbdocController'. DbdocController.groovy /uploadr-Grails2.3.3-JDK7/.link_to_grails_plugins/database-migration-1.3.8/grails-app/controllers/grails/plugin/databasemigration line 1 Java Problem
Groovy:Repetitive method name/signature for method 'java.lang.Object withFormat(groovy.lang.Closure)' in class 'grails.plugin.databasemigration.DbdocController'. DbdocController.groovy /uploadr-Grails2.3.3-JDK7/.link_to_grails_plugins/database-migration-1.3.8/grails-app/controllers/grails/plugin/databasemigration line 1 Java Problem
Finally I found out a solution to everything \o/
uploadr doesn't seem to work with any grails version newer then 2.3.3
The errors 'Groovy:Repetitive method name/signature' are due a incompatibility between grails 2.3.3 and JDK8. However to solve properly it is necessary to also change the STS.ini from spring to use JDK7. Because even though I had changed all my system and preferences inside spring to use JDK7 it wasn't enough.
STS.ini is located at:
springsource/sts-3.5.1.RELEASE/STS.ini
and add/change:
-vm
/path/to/your/jdk/installation
to me it was:
-vm
/usr/lib/jvm/jdk1.7.0_65/bin/java

Grails inline (inplace) plugin unable to resolve dependency

I've got a plugin called Media which should take care of image resizing and so on.
It has these dependences:
dependencies {
compile group: 'org.ccil.cowan.tagsoup',
name: 'tagsoup',
version: '1.2'
runtime group: 'org.codehaus.groovy.modules.http-builder',
name: 'http-builder',
version: '0.5.2'
compile group: 'org.imgscalr',
name: 'imgscalr-lib',
version:'4.2'
compile group: 'org.apache.tika',
name: 'tika-core',
version: '1.3'
}
When I run plugin as a standalone application everything works fine.
Than I created an application and added inplace plugin dependency to my BuildConfig.groovy file.
// there is grails.project.dependency.resolution closure above
grails.plugin.location.Media = "../../plugins/Media";
When I run-app my application I get this error:
| Error Compilation error: startup failed:
/home/grails/plugins/Media/grails-app/controllers/frod/media/ImageServiceController.groovy: 14: unable to resolve class org.imgscalr.Scalr
# line 14, column 1.
import org.imgscalr.Scalr
^
/home/grails/plugins/Media/src/groovy/frod/media/download/CachedContentDownloader.groovy: 3: unable to resolve class org.apache.http.HttpResponse
# line 3, column 1.
import org.apache.http.HttpResponse
^
/home/grails/plugins/Media/src/groovy/frod/media/download/ContentDownloader.groovy: 3: unable to resolve class org.apache.http.HttpResponse
# line 3, column 1.
import org.apache.http.HttpResponse
^
/home/grails/plugins/Media/src/groovy/frod/media/download/ContentDownloader.groovy: 4: unable to resolve class org.apache.http.client.HttpClient
# line 4, column 1.
import org.apache.http.client.HttpClient
^
/home/grails/plugins/Media/src/groovy/frod/media/download/ContentDownloader.groovy: 6: unable to resolve class org.apache.http.impl.client.DefaultHttpClient
# line 6, column 1.
import org.apache.http.impl.client.DefaultHttpClient
^
/home/grails/plugins/Media/src/groovy/frod/media/download/ContentDownloader.groovy: 5: unable to resolve class org.apache.http.client.methods.HttpGet
# line 5, column 1.
import org.apache.http.client.methods.HttpGet
^
/home/grails/plugins/Media/src/groovy/frod/media/download/DownloadedContent.groovy: 3: unable to resolve class org.apache.http.HttpEntity
# line 3, column 1.
import org.apache.http.HttpEntity
^
/home/grails/plugins/Media/src/groovy/frod/media/download/IContentDownloader.groovy: 3: unable to resolve class org.apache.http.HttpResponse
# line 3, column 1.
import org.apache.http.HttpResponse
^
/home/grails/plugins/Media/src/groovy/frod/media/image/thumbnail/adjustment/crop/CropProcessor.groovy: 5: unable to resolve class org.imgscalr.Scalr
# line 5, column 1.
import org.imgscalr.Scalr
^
/home/grails/plugins/Media/src/groovy/frod/media/image/thumbnail/adjustment/resize/IResizeAdjustment.groovy: 3: unable to resolve class org.imgscalr.Scalr
# line 3, column 1.
import org.imgscalr.Scalr
^
/home/grails/plugins/Media/src/groovy/frod/media/image/thumbnail/adjustment/resize/IResizeAdjustment.groovy: 16: unable to resolve class Scalr.Mode
# line 16, column 5.
public Scalr.Mode getMode();
^
/home/grails/plugins/Media/src/groovy/frod/media/image/thumbnail/adjustment/resize/IResizeAdjustment.groovy: 18: unable to resolve class Scalr.Method
# line 18, column 5.
public Scalr.Method getMethod();
^
// and many others
As you can see it couldn't resolve dependencies (you can see http-builder imgscalr-lib).
I googled much and found I could try to set legacyResolve true. I tried all combinations (plugin, app, plugin + app) with these settings and with the same result - the error above.
Can anyone help me with this?
My grails version is 2.2.3
Thank you very much
Frank
Dependencies are resolved by Ivy, but this depends on POM files being available. This isn't the case when you use inline plugins since you're just pointing to the plugin source. You can either be redundant and add the dependencies to the app's BuildConfig, or use the maven-install script which packages the plugin and copies it to your local Maven cache.
maven-install is a bit less convenient since you have to re-run it every time you make a change in the plugin that you need to have available to the application, but it's closer to the real install process. To use a plugin that's been published locally like this, ensure that mavenLocal() is uncommented in BuildConfig.groovy and add a dependency like you would if you had released the plugin, e.g. compile ':myplugin:0.1'

grails startup error when run-app

When I copied my old project from my old computer and typed grails run-app in project folder, I get the following error:
| Error Compilation error: startup failed:
G:\Windows NT 5.0 Workstation Profile\.grails\2.0.0\projects\timesheet\plugins\g
orm-labs-0.8.5\src\groovy\GormLabsHibernateCriteriaBuilder.groovy: 35: The retur
n type of java.lang.Object order(java.lang.String) in grails.orm.GormLabsHiberna
teCriteriaBuilder is incompatible with org.grails.datastore.mapping.query.api.Cr
iteria order(java.lang.String) in grails.orm.HibernateCriteriaBuilder
. At [35:5] # line 35, column 5.
Object order(String propertyName) {
^
1 error
Can anyone tell me what this relates to?
Thanks
You said you just copied the project, but you must have at least partially upgraded it since your error shows that you're using Grails 2.0.0. The error message has to do with the Gorm Labs plugin, which has been abandoned for over a year and is unlikely to be compatible with newer versions of Grails. I'd remove that and any usage of it and see where you get from there.

Resources