wrschneider
wrschneider

Reputation: 18770

Grails session-scoped service - not working

I added static scope = "session" in one of my Grails services (Grails 2.2.2), but for some reason it is behaving like a singleton.

Can you not inject session services into singleton (default) services?

In other words, is there any reason why this shouldn't work?

class DefaultService {
  def sessionService
}

class SessionService {
  static scope = 'session'

  def instanceVar = ...
}

How would I troubleshoot why this isn't working?

Upvotes: 1

Views: 2238

Answers (1)

era.tolekov
era.tolekov

Reputation: 88

I hope this help you.

In short, you can not use session scoped services in singletons, like usual services or taglibs. Use service proxy by manually, or Scoped Proxy Plugin.

Upvotes: 1

Related Questions