Grails 3 war -Inline plugin issues - grails

I am trying to war the grails 3.1.9 application with inline plugin , its throwing an error saying "java.lang.IllegalStateException: Unable to rename 'C:\test\grails_demo\plugins\grails_demo_plugin\build\libs\grails_demo_plugin-0.1.jar' to 'C:\test\grails_demo\plugins\grails_demo_plugin\build\libs\grails_demo_plugin-0.1.jar.original'".
I am not sure why it cant rename the file. My settings.gradle file contains :
include 'grails_demo_plugin'
project(":grails_demo_plugin").projectDir = new File("plugins/grails_demo_plugin")
And in build.gradle file dependencies block contain as shown :
dependencies {
compile project(":grails_demo_plugin")
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-ehcache"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2"
runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}
when I tried to run the application , everything is working fine but when I did grails war , i am getting this error.
After few hours of google I found that, the error is from Gradle-Spring-Boot task bootRepackage .
As per this link(https://github.com/spring-projects/spring-boot/issues/1113) I just added "bootRepackage { classifier = 'exec' }" to my plugin's build.gradle file , the error went away but the plugin-jar is not added to the war file.
Here is the github link for my application(https://github.com/Vigneshwaran082/grails_demo)
Here is my complete stacktrace link (https://github.com/Vigneshwaran082/grails_demo/blob/Vigneshwaran082-stackTrace/stackTrace.txtenter link description here)

I am answering my own question , so that it might be useful for someone in future.
Just disabling the bootRepackage task has fixed this issue .Just by adding "bootRepackage.enabled = false" to all build.gradle inside the plugins directory fixed this issue .

Related

Can't import grails.plugin.springsecurity.annotation in Grails 3?

I've been following Burt Beckwith's tutorial on Spring Security for Grails 3. I installed the plugin build.gradle as it said in the tutorial, and ran s2-quickstart, which seems to work fine. The project compiles without complaint.
However when I try the import statement
import grails.plugin.springsecurity.annotation.Secured
the import isn't recognized and won't build, with error
Error:(2, 1) Groovyc: unable to resolve class grails.plugin.springsecurity.annotation.Secured
What's missing?
dependencies section of build.gradle:
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-ehcache"
compile 'org.grails.plugins:spring-security-core:3.1.1' //***
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2"
runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
I was able to resolve this issue in IntelliJ by clicking the "refresh" icon in the View \ Tools \ Gradle window.

Grails : How to migrate dependencies upgrading from 2.x.x to 3.0.8?

I am attempting to upgrade an existing Grails application from version 2.4.4 to 3.0.8. I have a couple issues that I am currently unable to resolve.
First issue: The old version's BuildConfig.groovy referenced a jar file that was in the lib directory. I tried copying the same configuration from BuildConfig.groovy to build.gradle and created a lib directory with the jar but Grails is unable to resolve the dependency.
Second issue: The old version had a plugin defined. I tried copying the same plugin definition from BuildConfig.groovy into build.gradle, but this isn't working. I noticed that the plugin isn't currently listed in Bintray, is this the problem?
Below is the dependency section of the build.gradle file.
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:hibernate"
compile "org.grails.plugins:cache"
compile "org.hibernate:hibernate-ehcache"
compile "org.grails.plugins:scaffolding"
compile "com.stripe:stripe-java:1.32.1"
compile "com.google.code.gson:gson:2.3.1"
compile "javax.mail:mail:1.4"
runtime "org.grails.plugins:asset-pipeline"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
// Note: It is recommended to update to a more robust driver (Chrome, Firefox etc.)
testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.44.0'
console "org.grails:grails-console"
//jar file located in lib directory
runtime "com.easypost:easypost-java:2.1.2"
//grails plugin
compile ":shiro:1.2.1"
}
Thanks in advance for any guidance provided.
Issue 1: If that jar is a standard jar and you can reference it from maven then that would be good. But still if you need to include it from some local directory then you can do this:
repositories {
flatDir {
//Directory path containing Jar
dirs 'libs'
}
}
dependencies {
//Jar File Name - No need to add suffix .jar
compile name: 'someJarFile'
}
Issue 2: If the plugin is not listed in bintray then that means it has not been upgraded for Grails 3.x. Either you can upgrade it for yourself or remove the plugin if possible.

envers and hibernate plugins incompatibility

I'm using hibernate plugin and trying to integrate envers plugins to my project. But the following issue appears:
when I'm trying to start project it gives me an exception:
[groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
[groovyc] General error during conversion: java.lang.NoClassDefFoundError: org/hibernate/event/PostInsertEventListener
my build config is as follows:
{
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"
compile ":spring-security-ui:1.0-RC2"
// plugins needed at runtime but not for compilation
runtime ":hibernate4:4.3.5.4" // or ":hibernate:3.6.10.16"
runtime ":envers:2.1.0"
runtime ":database-migration:1.4.0"
runtime ":jquery:1.11.1"
}
I tried to find PostInsertEventListener class and I found it but under different package - under org.hibernate.event.spi and for some reason it tries to find it in under org/hibernate/event. Is it some plugins incompatibility issue? Thank you!
run grails dependency-report to see the conflicts
you can also try replacing the hib4 plugin with hib3. this should most probably be causing the compile error

Update to 2.3.9 - Error executing script RunApp: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling

I am update grails from 2.3.7 to 2.3.9 and it has error
Error executing script RunApp:
org/codehaus/groovy/runtime/typehandling/ShortTypeHandling.
Here is run-app --stacktrace --verbose :
|Loading Grails 2.3.9
|Configuring classpath
.
|Environment set to development
.................................
|Packaging Grails application
...........
|Compiling 1 source files
[groovyc] Compiling 1 source file to
Z:\future13_grails\cerp\target\classes
.....................................Error
|
Error executing script RunApp:
org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
java.lang.NoClassDefFoundError:
org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
at
org.grails.plugins.tomcat.TomcatServer.(TomcatServer.groovy:81)
at
org.grails.plugins.tomcat.InlineExplodedTomcatServer.(InlineExplodedTomcatServer.groovy)
at
org.grails.plugins.tomcat.TomcatServerFactory.createInline(TomcatServerFactory.groovy:38)
at
org.codehaus.groovy.grails.project.container.GrailsProjectRunner.runInline(GrailsProjectRunner.groovy:183)
at
org.codehaus.groovy.grails.project.container.GrailsProjectRunner.runApp(GrailsProjectRunner.groovy:119)
at
org.codehaus.groovy.grails.project.container.GrailsProjectRunner$runApp$0.call(Unknown
Source)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
...
Error | Error executing script RunApp:
org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
And here is BuildConfig.groovy
... plugins {
// plugins for the build system only
build ':tomcat:7.0.52.1'
// plugins for the compile step
compile ':scaffolding:2.0.3'
compile ':cache:1.1.1'
compile ":spring-security-core:2.0-RC2"
compile ":searchable:0.6.6"
// plugins needed at runtime but not for compilation
runtime ':hibernate:3.6.10.15' // ':hibernate4:4.3.5.3' for Hibernate 4
runtime ':database-migration:1.4.0'
runtime ":jquery:1.10.2"
runtime ':resources:1.2.8'
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0.1"
//runtime ":cached-resources:1.1"
//runtime ":yui-minify-resources:0.1.5"
runtime ":cors:1.1.2"
} ...
I deleted target folder and run grails, it run successfully.
If deleting the target folder doesn't work for your, use the clean and compile commands before trying to run your project again.
Duplicate question Groovy ShortTypeHandling ClassNotFoundException.
I doubt any of the plugin's version is only compatible with Grails version 2.4.0 and above (which comes with Groovy 2.3.*).

grails upgrade from 2.2.0 to 2.3.4

Hi I upgraded my Grails application from 2.2.0 to Grails 2.3.4, but I'm getting this error :
|Loading Grails 2.3.4
|Configuring classpath
Error |
Resolve error obtaining dependencies: Failed to resolve dependencies (Set log level to 'warn' in BuildConfig.groovy for more information):
- org.apache.tomcat.embed:tomcat-embed-core:7.0.47
- org.apache.tomcat:tomcat-catalina-ant:7.0.47
- org.apache.tomcat.embed:tomcat-embed-jasper:7.0.47
(Use --stacktrace to see the full trace)
Error |
Resolve error obtaining dependencies: Failed to resolve dependencies (Set log level to 'warn' in BuildConfig.groovy for more information):
- org.grails:grails-datastore-gorm-hibernate:2.0.6.RELEASE
- junit:junit-dep:4.10
(Use --stacktrace to see the full trace)
Error |
Resolve error obtaining dependencies: Failed to resolve dependencies (Set log level to 'warn' in BuildConfig.groovy for more information):
- org.grails:grails-datastore-gorm-hibernate:2.0.6.RELEASE
(Use --stacktrace to see the full trace)
Error |
Failed to resolve dependencies (Set log level to 'warn' in BuildConfig.groovy for more information):
- org.apache.tomcat.embed:tomcat-embed-core:7.0.47
- org.apache.tomcat:tomcat-catalina-ant:7.0.47
- org.apache.tomcat.embed:tomcat-embed-jasper:7.0.47
Any recommendations to fix this issue ?
From the Grails 2.3.4 Release Notes
If you are upgrading from previous versions of Grails 2.3.x and you use the Hibernate and/or Tomcat plugins you will need to update the versions in BuildConfig:
build ':tomcat:7.0.47'
runtime ':hibernate:3.6.10.6'
And since you are upgrading from 2.3, I think you should also read What's new in Grails 2.3?
Grails 2.3.4 requires you to upgrade most of your dependencies. I don't know all but I think you have to upgrade hibernate to hibernate 3. Here's what my current project's BuildConfig looks like:
dependencies {
// specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
runtime 'mysql:mysql-connector-java:5.1.24'
//compile 'com.paypal.sdk:merchantsdk:2.4.103'
compile 'joda-time:joda-time:2.2'
compile ('org.apache.poi:poi:3.9','org.apache.poi:poi-ooxml:3.9')
compile 'com.stripe:stripe-java:1.3.0'
}
plugins {
// plugins for the build system only
build ":tomcat:7.0.41"
// plugins for the compile step
compile ":scaffolding:2.0.0.RC1"
compile ':cache:1.1.1'
// plugins needed at runtime but not for compilation
runtime ":hibernate:3.6.10.6" // or ":hibernate4:4.1.11.M2"
runtime ":database-migration:1.3.5"
compile ":jquery:1.10.2"
runtime ":resources:1.2"
// Uncomment these (or add new ones) to enable additional resources capabilities
//runtime ":zipped-resources:1.0.1"
//runtime ":cached-resources:1.1"
//runtime ":yui-minify-resources:0.1.5"
//app plugins
compile ':webflow:2.0.8.1'
compile ":mail:1.0.1"
compile ":asynchronous-mail:1.0-RC5" //1.0
compile ":spring-security-core:1.2.7.3"
compile ':excel-export:0.1.10'
compile ":spring-security-core:1.2.7.3"
test ":spock:0.7"
}
This works for me.

Resources