Announcement Announcement Module
No announcement yet.
No scope specified when using Proxy Target Class, despite singleton = true Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • No scope specified when using Proxy Target Class, despite singleton = true


    I've tried to configure that for one class I use a CGLIB proxy class. I used the following annotation to configure this:

    @Scope(value = ConfigurableBeanFactory.SCOPE_SINGLETON, proxyMode = ScopedProxyMode.TARGET_CLASS)
    However, the resulting Bean definition (ScopedProxyFactoryBean) has a scope value of "", despite the singleton flag being set to true. This is not true of the which it proxies to, which instead has a scope of "singleton" as I'd expect. It seems that in org.springframework.aop.scope.ScopedProxyUtils#cre ateScopedProxy the scope is never set on the proxy definition from the originating bean definition.

    Why is this? Isn't that wrong?
    I can see that:

         * Constant for the default scope name: "", equivalent to singleton status
         * but to be overridden from a parent bean definition (if applicable).
        public static final String SCOPE_DEFAULT = "";
    However, third party code does not treat these as equivalent always.

    My root problem is that I use Spring with Jersey as my JSR-311 implementation. They have an ExceptionMapper interface and special annotations. They seem to basically have these classes looked up by their code somehow. I want to use AOP for some logging around my ExceptionMapper implementation, however, they don't retrieve the proxy on lookup unless it's a physical object (hence the CGLIB configuration attempt). However, within their code they map Spring scopes to Jersey scopes, and the empty string does not map to a singleton. This makes Jersey complain. I wasn't sure whether to take this up with Jersey or Spring, but thought it may be more appropriate here, since I also find it odd that the "singleton" scope isn't propagated to the proxy bean that claims it is a singleton.

    com.sun.jersey.spi.spring.container.SpringComponen tProviderFactory#createScopeMap
            m.put(BeanDefinition.SCOPE_SINGLETON, ComponentScope.Singleton);
    I'm currently using Spring 3.1.3 with Jersey 1.1x. This may not be an issue in org.glassfish.jersey.server.spring.SpringComponent Provider from Jersey 2.x, but I haven't confirmed this yet, and we can't migrate right now.

    Any help is appreciated here. If you think there's fundamentally something wrong with my approach, I'm happy to take other suggestions. If I've misunderstood the issue here, please correct me. If you think this should be a Jersey bug, please say so also.


    Last edited by louisburton; Jan 27th, 2014, 12:50 PM.

  • #2
    We are currently in the process of moving to for our forums. If you're still having this issue please consider asking it again at using the #spring tag. If you do post it there, please reply here with the link. Thanks!