Announcement Announcement Module
No announcement yet.
A weird bean problem Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • A weird bean problem

    I have a class as

    class A implements InitializingBean {

    private string someString;

    public void setSomeString(String str) {
    this.someString = str;
    logger.debug("SomeString: " + someString); // *

    public void afterPropertiesSet() {
    // ...
    if (someString == null)
    throw new BeanCreationException(
    "Must set ...");

    When I bring up the application, the exception is thrown even though I see the debugging message of the line * for a non-null data.

    How come?

  • #2
    Post your Spring xml file.

    Have you maybe got 2 instances configured in Spring, with only one of them having the someString property set?


    • #3
      Thanks for your response.

      You are absolutely right. There are two instances of the class, one with an interceptors; the other without it. I added the new attribute into the class and change one instance configuration, but forgot the other one after the project gets bigger (more than 400 lines in the servlet.xml).

      Thanks again.