spring security - Cannot run grails plugin after creation. Get ERROR o.s.boot.SpringApplication Application startup failed -


i having hard time figure out why grails fails run plugin created. environment:

  • grails version: 3.2.6
  • groovy version: 2.4.7
  • jvm version: 1.8.0_91

and these steps:

  1. i created plugin with:

    grails create-plugin bioprofile 
  2. i add spring security core plugin, adding line build.gradle:

    compile 'org.grails.plugins:spring-security-core:3.1.1' 
  3. i ran s2-quickstart command set user, role , userrole:

    grails s2-quickstart cscie56.ps5 user role 
  4. i modified user domain class include new fields

  5. created few other domain classes

    grails create-domain-class cscie56.ps5.blogentry grails create-domain-class cscie56.ps5.comment 
  6. i generated controllers, etc...

    grails generate-all blogentry grails generate-all user grails generate-all role grails generate-all userrole 
  7. i added following initialization in bootstrap.groovy file:

    package bioprofile  import cscie56.ps5.role import cscie56.ps5.user import cscie56.ps5.userrole  class bootstrap {      def init = { servletcontext ->         environments {             development {                 setupdata()                 setupusersandroles()                 println "developement execution"             }             test {                 setupdata()                 setupusersandroles()                 println "test execution"             }             production {                 // nothing                 println "production execution"             }         }     }      def destroy = {     }      def setupusersandroles() {         user admin = new user(username: 'admin', password: 'password')         admin.save(flush: true)         user user = new user(username: 'user', password: 'user')         user.save(flsuh:true)          role adminrole = new role(authority: role.role_admin)         adminrole.save(flush:true)          role userrole = new role(authority: role.role_user)         userrole.save(flush:true)          userrole.create(admin, adminrole)         userrole.create(admin, userrole)         userrole.create(user, userrole)     }      def setupdata() {      } } 

when run app grails run-app tedious error:

running application... objc[84720]: class javalaunchhelper implemented in both /library/java/javavirtualmachines/jdk1.8.0_91.jdk/contents/home/bin/java , /library/java/javavirtualmachines/jdk1.8.0_91.jdk/contents/home/jre/lib/libinstrument.dylib. 1 of 2 used. 1 undefined.  configuring spring security core ... ... finished configuring spring security core  2017-04-06 06:20:06.032 error --- [           main] o.s.boot.springapplication               : application startup failed  java.lang.illegalstateexception: either class [cscie56.ps5.user] not domain class or gorm has not been initialized correctly or has been shutdown. ensure gorm loaded , configured correctly before calling methods on gorm entity.     @ org.grails.datastore.gorm.gormenhancer.stateexception(gormenhancer.groovy:387)     @ org.grails.datastore.gorm.gormenhancer.findinstanceapi(gormenhancer.groovy:273)     @ org.grails.datastore.gorm.gormenhancer.findinstanceapi(gormenhancer.groovy:270)     @ org.grails.datastore.gorm.gormentity$trait$helper.currentgorminstanceapi(gormentity.groovy:1326)     @ org.grails.datastore.gorm.gormentity$trait$helper.save(gormentity.groovy:151)     @ org.grails.datastore.gorm.gormentity$trait$helper$save.call(unknown source)     @ org.codehaus.groovy.runtime.callsite.callsitearray.defaultcall(callsitearray.java:48)     @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:113)     @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:133)     @ cscie56.ps5.user.save(user.groovy)     @ cscie56.ps5.user.save(user.groovy)     @ org.grails.datastore.gorm.gormentity$save.call(unknown source)     @ org.codehaus.groovy.runtime.callsite.callsitearray.defaultcall(callsitearray.java:48)     @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:113)     @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:125)     @ bioprofile.bootstrap.setupusersandroles(bootstrap.groovy:33)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:498)     @ org.springsource.loaded.ri.reflectiveinterceptor.jlrmethodinvoke(reflectiveinterceptor.java:1426)     @ org.codehaus.groovy.reflection.cachedmethod.invoke(cachedmethod.java:93)     @ groovy.lang.metamethod.domethodinvoke(metamethod.java:325)     @ org.codehaus.groovy.runtime.metaclass.closuremetaclass.invokemethod(closuremetaclass.java:384)     @ groovy.lang.metaclassimpl.invokemethod(metaclassimpl.java:1024)     @ org.codehaus.groovy.runtime.callsite.pogometaclasssite.callcurrent(pogometaclasssite.java:69)     @ org.codehaus.groovy.runtime.callsite.callsitearray.defaultcallcurrent(callsitearray.java:52)     @ org.codehaus.groovy.runtime.callsite.abstractcallsite.callcurrent(abstractcallsite.java:154)     @ org.codehaus.groovy.runtime.callsite.abstractcallsite.callcurrent(abstractcallsite.java:158)     @ bioprofile.bootstrap$_closure1$_closure3$_closure4.docall(bootstrap.groovy:13)     @ bioprofile.bootstrap$_closure1$_closure3$_closure4.docall(bootstrap.groovy)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:62)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43)     @ java.lang.reflect.method.invoke(method.java:498)     @ org.springsource.loaded.ri.reflectiveinterceptor.jlrmethodinvoke(reflectiveinterceptor.java:1426)     @ org.codehaus.groovy.reflection.cachedmethod.invoke(cachedmethod.java:93)     @ groovy.lang.metamethod.domethodinvoke(metamethod.java:325)     @ org.codehaus.groovy.runtime.metaclass.closuremetaclass.invokemethod(closuremetaclass.java:294)     @ groovy.lang.metaclassimpl.invokemethod(metaclassimpl.java:1024)     @ groovy.lang.closure.call(closure.java:414)     @ bioprofile.bootstrap$_closure1$_closure3$_closure4.call(bootstrap.groovy)     @ groovy.lang.closure.call(closure.java:408)     @ bioprofile.bootstrap$_closure1$_closure3$_closure4.call(bootstrap.groovy)     @ grails.util.environment$environmentblockevaluator.execute(environment.java:529)     @ grails.util.environment.executeforenvironment(environment.java:510)     @ grails.util.environment.executeforcurrentenvironment(environment.java:485)     @ org.grails.web.servlet.boostrap.defaultgrailsbootstrapclass.callinit(defaultgrailsbootstrapclass.java:62)     @ org.grails.web.servlet.context.grailsconfigutils.executegrailsbootstraps(grailsconfigutils.java:65)     @ org.grails.plugins.web.servlet.context.bootstrapclassrunner.onstartup(bootstrapclassrunner.groovy:53)     @ grails.boot.config.grailsapplicationpostprocessor.onapplicationevent(grailsapplicationpostprocessor.groovy:256)     @ grails.boot.config.grailsapplicationpostprocessor.onapplicationevent(grailsapplicationpostprocessor.groovy)     @ org.springframework.context.event.simpleapplicationeventmulticaster.invokelistener(simpleapplicationeventmulticaster.java:167)     @ org.springframework.context.event.simpleapplicationeventmulticaster.multicastevent(simpleapplicationeventmulticaster.java:139)     @ org.springframework.context.support.abstractapplicationcontext.publishevent(abstractapplicationcontext.java:383)     @ org.springframework.context.support.abstractapplicationcontext.publishevent(abstractapplicationcontext.java:337)     @ org.springframework.context.support.abstractapplicationcontext.finishrefresh(abstractapplicationcontext.java:882)     @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.finishrefresh(embeddedwebapplicationcontext.java:144)     @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:545)     @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.refresh(embeddedwebapplicationcontext.java:122)     @ org.springframework.boot.springapplication.refresh(springapplication.java:762)     @ org.springframework.boot.springapplication.refreshcontext(springapplication.java:372)     @ org.springframework.boot.springapplication.run(springapplication.java:316)     @ grails.boot.grailsapp.run(grailsapp.groovy:83)     @ grails.boot.grailsapp.run(grailsapp.groovy:388)     @ grails.boot.grailsapp.run(grailsapp.groovy:375)     @ grails.boot.grailsapp$run.call(unknown source)     @ org.codehaus.groovy.runtime.callsite.callsitearray.defaultcall(callsitearray.java:48)     @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:113)     @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:133)     @ bioprofile.application.main(application.groovy:10) 

i tried run

grails clean grails clean --refresh-dependencies grails compile 

but same result.

anyone has encountered issue or have idea root cause is?

this worked me, if else going have same problem. seems hibernate dependencies issue. not obvious, , subtle bug of whatever generating boilerplate stuff across several files (never been big fan of "i'll you" frameworks). in specific case (and might specific environment) replacing generated hibernate5 dependencies hibernate4 in build.gradle file, error above went away. have (removed hibernate5 stuff):

classpath "org.grails.plugins:hibernate4:5.0.10"  compile "org.grails.plugins:hibernate4" compile "org.hibernate:hibernate-core:4.3.10.final" compile "org.hibernate:hibernate-ehcache:4.3.10.final" 

the .withtransaction { hack did not seem have effect in solving problem.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -