glassfish
  1. glassfish
  2. GLASSFISH-18585

embedded glassfish: jersey-test does not honor @Singleton and @ManagedBean

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: embedded
    • Labels:
      None
    • Environment:

      Linux + Glassfish.

      Description

      I am trying to switch my project to run in Glassfish. The application seems to work, but I have problems with tests. They all seem to fail, as my class, annoted as

      import javax.annotation.ManagedBean;
      import javax.inject.Singleton;

      @Path("/")
      @Singleton
      @ManagedBean
      public class Quoridor {
      }

      is instantiate more than one per each test run. Could the Jersey framework honor the @Singleton + @ManagedBean annotation as glassfish does?

      1. embedded_log.txt
        27 kB
        sakshi.jain
      2. UsingEmbeddedGlassfish.diff
        44 kB
        jst
      3. UsingExternalGlassfish.diff
        45 kB
        jst

        Activity

        Hide
        jbenoit added a comment -

        I see attachments:
        UsingEmbeddedGlassfish.diff
        UsingExternalGlassfish.diff
        but when I execute command it shows error:

        C:\a\fresh\jersey-757\2\quoridor>patch -p1 <UsingEmbeddedGlassfish.diff
        Hmm... I can't seem to find a patch in there anywhere.

        C:\a\fresh\jersey-757\2\quoridor>patch -p1 <UsingExternalGlassfish.diff
        Hmm... I can't seem to find a patch in there anywhere.

        Show
        jbenoit added a comment - I see attachments: UsingEmbeddedGlassfish.diff UsingExternalGlassfish.diff but when I execute command it shows error: C:\a\fresh\jersey-757\2\quoridor>patch -p1 <UsingEmbeddedGlassfish.diff Hmm... I can't seem to find a patch in there anywhere. C:\a\fresh\jersey-757\2\quoridor>patch -p1 <UsingExternalGlassfish.diff Hmm... I can't seem to find a patch in there anywhere.
        Hide
        jst added a comment -

        I don't know what can be wrong. Maybe patch does not work well on windows? Try:

        $ hg up -C 92bd2090dd5f
        $ wget http://java.net/jira/secure/attachment/47163/UsingExternalGlassfish.diff
        $ hg import --no-commit UsingExternalGlassfish.diff

        These three commands just did the trick for me (on Linux).

        Show
        jst added a comment - I don't know what can be wrong. Maybe patch does not work well on windows? Try: $ hg up -C 92bd2090dd5f $ wget http://java.net/jira/secure/attachment/47163/UsingExternalGlassfish.diff $ hg import --no-commit UsingExternalGlassfish.diff These three commands just did the trick for me (on Linux).
        Hide
        sakshi.jain added a comment -

        I have been able to run the webidor test using external glassfish.Hence the issue does lie with embedded.
        As you said the class annotated as Singleton is instantiated more than once.This is because it is bootstrapping embedded glassfish twice.
        Attached herewith is the log which I obtain on running the webidor test.

        Show
        sakshi.jain added a comment - I have been able to run the webidor test using external glassfish.Hence the issue does lie with embedded. As you said the class annotated as Singleton is instantiated more than once.This is because it is bootstrapping embedded glassfish twice. Attached herewith is the log which I obtain on running the webidor test.
        Hide
        sakshi.jain added a comment -

        Since embedded glassfish was being bootstrapped twice, I declared the Glassfish instance as static so it will bootstrap only once.So after the first test, embedded glassfish would merely stop instead of shutting down, and for the second test it will start again.However, another issue is encountered here which looks like a design issue & we are looking into that.

        Show
        sakshi.jain added a comment - Since embedded glassfish was being bootstrapped twice, I declared the Glassfish instance as static so it will bootstrap only once.So after the first test, embedded glassfish would merely stop instead of shutting down, and for the second test it will start again.However, another issue is encountered here which looks like a design issue & we are looking into that.
        Hide
        Michal Gajdos added a comment -

        is there any progress on this issue?

        Show
        Michal Gajdos added a comment - is there any progress on this issue?

          People

          • Assignee:
            sakshi.jain
            Reporter:
            jst
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: