Skip to content
This repository has been archived by the owner on May 28, 2018. It is now read-only.

Spring RequestScope breaks SpringComponentProvider #3789

Open
nick-pww opened this issue Mar 21, 2018 · 0 comments
Open

Spring RequestScope breaks SpringComponentProvider #3789

nick-pww opened this issue Mar 21, 2018 · 0 comments

Comments

@nick-pww
Copy link

Utilizing the new(ish) @RequestScope annotation causes integration issues as Spring is registering multiple bean names when this annotation is present. You now end up with originalBeanName and scopedTarget.originalBeanName as bean name entries in the context for the affected class.

The specific piece that breaks is:

if (beanNames == null || beanNames.length != 1) {
    LOGGER.severe(LocalizationMessages.NONE_OR_MULTIPLE_BEANS_AVAILABLE(component));
    return false;
}

The application still actually works in my parituclar case as Jersey was able to use the constructor and populate the other requested beans (from spring). This is dangerous though, as it will have hidden side affects as the resources is not actually being provided by Spring when we expect to be and things like @Transactional or other Spring specific things will fail. This seems like a red flag as well, should something more severe be done in these cases? Fail faster?

Note: There is a valid workaround, just use the old @Scope annotation. That does not register another bean name

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant