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.
Related
similar question: Grails got error when war file deployed to Heroku (Factory method 'requestMappingHandlerAdapter' threw exception)
but I'm facing it when deploying a war file generated by grails 4.0.11 into Tomcat(v8.5.39):
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method 'requestMappingHandlerAdapter' threw exception; nested exception is java.lang.BootstrapMethodError: java.lang.IllegalAccessError: no such method: reactor.core.publisher.Mono.from(Publisher)Mono/invokeStatic
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622)
... 33 more
Caused by: java.lang.BootstrapMethodError: java.lang.IllegalAccessError: no such method: reactor.core.publisher.Mono.from(Publisher)Mono/invokeStatic
at org.springframework.core.ReactiveAdapterRegistry$ReactorRegistrar.registerAdapters(ReactiveAdapterRegistry.java:194)
at org.springframework.core.ReactiveAdapterRegistry.<init>(ReactiveAdapterRegistry.java:70)
at org.springframework.core.ReactiveAdapterRegistry.getSharedInstance(ReactiveAdapterRegistry.java:179)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.<init>(RequestMappingHandlerAdapter.java:169)
I'm in the process of upgrading the project from grails 3.3.11.
WAR is being build with ./gradlew bootWar.
Local development env starts without problems.
dependencies in my build.gradle:
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'
provided 'org.springframework.boot:spring-boot-starter-tomcat'
compile 'org.grails:grails-web-boot'
compile 'org.grails:grails-logging'
compile 'org.grails:grails-plugin-rest'
compile 'org.grails:grails-plugin-databinding'
compile 'org.grails:grails-plugin-i18n'
compile 'org.grails:grails-plugin-services'
compile 'org.grails:grails-plugin-url-mappings'
compile 'org.grails:grails-plugin-interceptors'
compile 'org.grails.plugins:cache'
compile 'org.grails.plugins:scaffolding'
compile 'org.grails.plugins:gsp'
compile 'org.grails:grails-web-fileupload'
compile 'org.apache.tomcat:tomcat-jdbc'
runtime "com.bertramlabs.plugins:asset-pipeline-grails:3.2.4"
compile "org.grails.plugins:async"
compile 'com.google.code.gson:gson:2.8.5'
testCompile 'org.grails:grails-gorm-testing-support'
testCompile 'org.grails:grails-web-testing-support'
testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1'
testRuntime 'net.sourceforge.htmlunit:htmlunit:2.18'
agent "org.springframework:springloaded:1.2.8.RELEASE"
runtimeOnly "io.methvin:directory-watcher:0.9.6"
compileOnly "io.micronaut:micronaut-inject-groovy"
compile 'org.postgresql:postgresql:42.2.20'
compile 'org.codehaus.groovy:groovy-dateutil:2.5.14'
compile 'org.grails.plugins:hibernate5'
compile 'org.hibernate:hibernate-core:5.4.18.Final'
compile 'org.hibernate:hibernate-ehcache:5.4.18.Final'
compile 'org.grails.plugins:spring-security-core:4.0.3'
compile 'org.grails.plugins:spring-security-acl:4.0.0.M2'
compile 'org.grails.plugins:postgresql-extensions:7.0.0'
compile 'org.springframework.security.extensions:spring-security-saml2-core:1.0.3.RELEASE'
compile 'org.grails.plugins:quartz:2.0.13'
compile("org.quartz-scheduler:quartz:2.2.3") {
exclude group: 'slf4j-api', module: 'c3p0'
}
compile 'com.google.api-ads:ads-lib:4.2.0'
compile 'com.google.api-ads:adwords-axis:4.2.0'
compile "com.googlecode.java-diff-utils:diffutils:1.2.1"
compile 'net.coobird:thumbnailator:0.4.8'
compile 'org.apache.ant:ant:1.9.4'
compile 'commons-io:commons-io:2.5'
compile 'com.cloudbees.thirdparty:zendesk-java-client:0.6.2'
compile 'org.yaml:snakeyaml:1.23'
compile 'cglib:cglib:2.2.2'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'org.apache.pdfbox:pdfbox:1.8.9'
compile 'commons-validator:commons-validator:1.6'
compile 'io.fastjson:boon:0.33'
compile 'com.thoughtworks.xstream:xstream:1.4.8'
compile 'com.amazonaws:aws-java-sdk-s3:1.11.423'
compile 'com.amazonaws:aws-java-sdk-core:1.11.423'
compile 'com.amazonaws:aws-java-sdk-lambda:1.11.423'
compile 'com.jcraft:jsch:0.1.53'
compile 'com.opencsv:opencsv:5.2'
compile project(':common')
compile project(':query')
compile project(':query-generator')
compile 'org.grails.plugins:audit-logging:4.0.3'
compile 'bouncycastle:bcprov-jdk14:138'
compile 'org.grails.plugins:csv:1.0'
compile 'org.grails.plugins:cookie:2.0.5'
runtime 'org.grails.plugins:grails-console:2.1.1'
compile 'org.grails.plugins:database-migration:3.1.0'
compile 'org.liquibase:liquibase-core:3.10.1'
compile 'org.grails.plugins:qrcode:0.9'
compile 'org.grails.plugins:mail:3.0.0'
compile 'org.grails.plugins:grails-executor:0.4'
compile 'org.reflections:reflections:0.9.10'
compile 'org.grails.plugins:sentry:11.7.25'
runtime 'org.jolokia:jolokia-core'
testRuntime 'net.sourceforge.htmlunit:htmlunit:2.18'
testRuntime 'org.seleniumhq.selenium:selenium-support:2.53.1'
testCompile 'org.seleniumhq.selenium:selenium-chrome-driver:2.53.1'
compile 'org.grails.plugins:views-json:2.0.4'
testCompile 'org.grails.plugins:greenmail:2.0.0.RC3'
compile (group: 'com.nimbusds', name: 'nimbus-jose-jwt', version: '8.10')
{ exclude group: 'org.ow2.asm' }
testCompile group: 'org.skyscreamer', name: 'jsonassert', version: '1.5.0'
compile 'org.codehaus.gpars:gpars:1.1.0'
testCompile 'org.grails:grails-test-mixins:3.3.0'
compile 'com.syncron.amazonaws:simba-athena-jdbc-driver:2.0.2'
testCompile 'org.mock-server:mockserver-netty:5.11.2'
I did a dependency scan and searched for anything reactive related.
It found reactive-streams as a dependency from micronaut.
+--- org.grails:grails-core -> 4.0.10
| +--- org.codehaus.groovy:groovy:2.5.14
| +--- org.slf4j:slf4j-api:1.7.30
| +--- org.slf4j:jcl-over-slf4j:1.7.30
| | \--- org.slf4j:slf4j-api:1.7.30
| +--- io.micronaut:micronaut-inject:1.3.7
| | +--- org.slf4j:slf4j-api:1.7.26 -> 1.7.30
| | +--- javax.annotation:javax.annotation-api:1.3.2
| | +--- javax.inject:javax.inject:1
| | +--- io.micronaut:micronaut-core:1.3.7
| | | +--- org.slf4j:slf4j-api:1.7.26 -> 1.7.30
| | | +--- org.reactivestreams:reactive-streams:1.0.3
Excluding it resolved the problem but I don't know what consequences it might cause.
configurations.all {
exclude group: 'org.reactivestreams', module: 'reactive-streams'
}
Deployment to Tomcat as war works and the app appears to be stable so far.
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 .
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.
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
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.*).