Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring request-scoped bean - all fields null/empty
    primarykey
    data
    text
    <p>I am creating a class with two request-scoped beans. The beans classes are annotated with:</p> <pre><code>@Component @Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS) public class RequestScopedBean1 { // stuff } </code></pre> <p>and their declaration as field in my class is:</p> <pre><code>@Resource private RequestScopedBean1 requestScopedBean1 @Resource private RequestScopedBean2 requestScopedBean2 </code></pre> <p>This system has been used all over the code base I am working on with no problems. However, in my class, one of the injected beans (not both, only one!) has all its fields null/empty.</p> <p>I am aware that simply looking at a request-scoped bean's fields in debug mode will normally show that they are all null because of how Spring's manages such beans with proxies. I am also aware that fields should be accessed with getters and setters, not directly, for the same reason. However, this bean still appears null/empty when using the Evaluate Expression function in intelliJ.</p> <p>My class and each bean class are in different projects. The working bean is in the core project. The broken bean is in a project with a dependency on the core project, and my class is in a project with a dependency on the broken bean's project.</p> <p>Please let me know if you need any more information to help me out here!</p> <p><strong>Edit</strong> A brief description of my XML config files:</p> <p>There are 4 relevant projects, lets call them 'core', 'web', 'common' and 'specific'. Each has its own corresponding application-context.xml The application is deployed from a .war file built from the 'specific' project. In the tag for the 'specific' web.xml the application contexts for 'web' and 'specific' are imported. The first line of the 'specific' application-context.xml imports the application-context for 'common', which is where my new class resides. The first line of 'web' application-context.xml imports the 'core' application-context. The working request-scoped bean resides in 'core'; the broken one in 'web'. I hope that is clear - let me know if not! Would any other info be useful?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload