Announcement Announcement Module
No announcement yet.
Issues with class paths Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issues with class paths

    Hi all, I'm a Grails newbie and have been away from Java for a couple of years and am running into an issue that's driving me crazy.

    I have the latest STS 2.5.0 M3 and Grails 1.3.4.

    I have been following a tutorial at to play around with Spring Security and I get to the portion where I setup my Bootstrap.groovy to create a couple of Roles and a User and get the following error on the SpringSecurityService object:

    2010-09-03 09:31:11,013 [main] ERROR context.GrailsContextLoader  Error executing bootstraps: No such property: springSecurityService for class: BootStrap
    groovy.lang.MissingPropertyException: No such property: springSecurityService for class: BootStrap
    at BootStrap$_closure1.doCall(BootStrap.groovy:18)
    at grails.util.Environment.evaluateEnvironmentSpecificBlock(
    at grails.util.Environment.executeForEnvironment(
    at grails.util.Environment.executeForCurrentEnvironment(
    at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:164)
    at grails.web.container.EmbeddableServer$ Source)
    at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:158)
    at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy)
    at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
    at _GrailsSettings_groovy$
    at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:149)
    at _GrailsRun_groovy$
    at _GrailsRun_groovy.runInline(_GrailsRun_groovy:116)
    at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
    at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59)
    at RunApp$_run_closure1.doCall(RunApp.groovy:33)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:590)
    at gant.Gant.executeTargets(Gant.groovy:589)
    Even if I import grails.plugins.springsecurity.SpringSecurityServic e into the file I get the same error.

    As if this wasn't bad enough, I ran grails clean via STS and now all of my domain objects are marked as unresolvable in Bootstrap.groovy and if I modify any other classes and save, their imports show as unresolvable too. If I do a grails run-app those errors don't seem to bother anything (just my original SpringSecurityService issue).

    What gives? Why is STS deciding that everything is unresolvable? Why does SpringSecurityService unrecognized?

    I created the app, ran 'install-plugin spring-security-core', ran 's2-quickstart edu.conncoll.tests User Role', ran 'create-controller edu.conncoll.tests.Secure' and added a few entries to that file along with their @Secured annotations, and then setup the Bootstrap.groovy exactly as mentioned in the tutorial.

    Thanks for any advice/help!

  • #2
    Could you paste your BootStrap code? Thanks.


    • #3
      Here it is ... didn't want to make the above post too long!

      import grails.util.Environment;
      import edu.conncoll.tests.*;
      class BootStrap {
          def init = { servletContext ->
      			case Environment.DEVELOPMENT:
      				//def requestMap = new Requestmap(url: '/secure/**', configAttribute: 'ROLE_ADMIN').save(flush: true)
      				def userRole = Role.findByAuthority('ROLE_USER') ?: new Role(authority: 'ROLE_USER').save(flush: true, failOnError: true)
      				def adminRole = Role.findByAuthority('ROLE_ADMIN') ?: new Role(authority: 'ROLE_ADMIN').save(flush: true, failOnError: true)
      				def adminUser = User.findByUsername('admin') ?: new User(
      																	username: 'admin',
      																	password: springSecurityService.encodePassword('admin'),
      																	enabled: true
      																).save(flush: true, failOnError: true)
      				if (!adminUser.authorities.contains(adminRole)) {
      					UserRole.create adminUser, adminRole
      				def userUser = User.findByUsername('user') ?: new User(
      																	username: 'user',
      																	password: springSecurityService.encodePassword('user'),
      																	enabled: true
      																).save(flush: true, failOnError: true)
      				if (!userUser.authorities.contains(userRole)) {
      					UserRole.create userUser, userRole
      			case Environment.TEST:
      				println "No special configuration required"
      			case Environment.PRODUCTION:
      				println "No special configuration required"
          def destroy = {


      • #4
        You haven't declared 'springSecurityService' as a property of the class:

        class BootStrap {
            def springSecurityService
        I'm not sure why you're having the STS issues. Try a clean build (via the Project menu).


        • #5
          That did it. Thanks pledbrook!

          I guess it was a complete newbie question! The Project -> clean fixed the red 'unresolvable' issues as well. I will stick with that then instead of running 'grails clean'.