hk2
  1. hk2
  2. HK2-7

Inhabitant.get tries to instantiate instead of retrieving the existing once if PostConstruct isn't implemented

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.*
    • Fix Version/s: 1.*
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: Macintosh

    • Issuezilla Id:
      7

      Description

      Trying to get EmbeddedWebContainer (Singleton Scope) instance by using
      Inhabitant.get() gives me "Failed to create class
      com.sun.enterprise.web.EmbeddedWebContainer". It seems that Inhabitant.get() is
      trying to instantiate com.sun.enterprise.web.EmbeddedWebContainer instead of
      retrieving the existing one. The workaround is to have EmbeddedWebContainer
      implement PostConstruct. The instance correctly retrieved using
      Inhabitant.get() after PostConstruct implementation.

      Embedded embedded = (org.apache.catalina.startup.Embedded)embeddedInhabitant.get();

      @Service(name="com.sun.enterprise.web.EmbeddedWebContainer")
      @Scoped(Singleton.class)
      public final class EmbeddedWebContainer extends Embedded implements PostConstruct {

        Activity

        Hide
        tlcksnyder added a comment -

        completed.

        Show
        tlcksnyder added a comment - completed.

          People

          • Assignee:
            dochez
            Reporter:
            Amy Roh
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: