Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1032

Lifecycle stacktrace in the exception message: What's causing is my bean being to be created too early?

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Unresolved
    • Major
    • Unscheduled
    • None
    • None

    Description

      When not using (C)DI, you can easily see when a component is created too early by looking at the stacktrace:

      "database username is null"
      at ConnectionManager.createConnection()
      at DogDao.createInstance()
      at DogDao.getInstance()
      at PersonDao.createInstance()
      at PersonDao.getInstance()
      at PersonService.createInstance()
      at PersonService.getInstance()
      at Main.beforeDatabaseUsernameIsAsked()
      

      Clearly, beforeDatabaseUsernameIsAsked() has the problem: it shouldn't call PersonService.getInstance().

      However, turn this code into (C)DI and you get something like this stacktrace:

      "database username is null"
      at ConnectionManager.createConnection()
      at java.reflect....
      at org.jboss.weld...
      at org.jboss.arquillian...
      

      Now, it's not clear any more that Main.beforeDatabaseUsernameIsAsked() is the problem, isn't it?
      There is absolutely no mention of Main.
      And then it is a challenge to find out what's causing the lifecycle to behave differently that you expected
      and how the lifecycle is actually behaving now.

      It would be nice if the exception message contains something like

      "database username is null"
        during creation of ConnectionManager
        for DogDao
        for PersonDao
        for PersonService
        for Main
      at ConnectionManager.createConnection()
      ....
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: