Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BeanDefinitions are no longer singletons by default which breaks apache cxf [SPR-6391] #11057

Closed
spring-projects-issues opened this issue Nov 19, 2009 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Matt Goldspink opened SPR-6391 and commented

While trying to migrate to 3.0 RC2 I found that my cxf application would not start up. After digging around a bit I found that the default scope for all beans is no longer singleton scope (found in AbstractBeanDefinition) and this breaks a lot of core code in CXF. Is this an intentional change? If so what was the reasoning as it seems like it could have a lot of consequences on other frameworks which make use of the default scope for beans being singletons. Is there any workaround?


Affects: 3.0 RC2

@spring-projects-issues
Copy link
Collaborator Author

Matt Goldspink commented

Specifically it breaks the BindingInfo registration which is done lazily using the SpringBeanMap and code which does:

        // Take any bean name or alias that has a web service annotation
        for (int i = 0; i < beanNames.length; i++) {
            BeanDefinition def = ctxt.getBeanFactory().getBeanDefinition(beanNames[i]);

            if (!def.isSingleton() || def.isAbstract()) {
                continue;
            }
       // ... then goes and registers the bean as binding

unfortunately because the default scope is no longer singleton the if statement above fails.

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

This should be fixed in trunk now.

Note that iterating over raw BeanDefinitions for metadata checking purposes is never a good idea because - by definition - it doesn't work with bean definition inheritance and bean definition post-processing at runtime, which may still override all sorts of metadata fields in the BeanDefinition. From that perspective, CXF and others should check merged bean definitions in those places instead (i.e. beanFactory.getMergedBeanDefinition instead of beanFactory.getBeanDefinition), or simply use beanFactory.isSingleton / beanFactory.getType / etc lookups and never touch bean definitions to begin with.

Juergen

@spring-projects-issues spring-projects-issues added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0 RC3 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants