glassfish
  1. glassfish
  2. GLASSFISH-19091

Method call to injected singleton hangs when called from an asynchronous task whose future is blocking

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Cannot Reproduce
    • Affects Version/s: 3.1.2.2
    • Fix Version/s: 4.0
    • Component/s: cdi
    • Labels:
      None

      Description

      If you attempt to execute a call to an @Asynchronous method in a stateless bean, and then call get on the returned future, any calls to injected singletons in the @Asynchronous method will hang unless the singleton has previously been used outside the @Asynchronous method.

      The workaround is to call a method on the singleton before calling it in the @Asynchronous method so that the proxy has already resolved a concrete implementation from the glassfish server before the @Asynchronous method is called.

      I have attached an example application source that replicates the issue in 3.1.2.2.

        Activity

        Hide
        tlcksnyder added a comment -

        Provided app fails to deploy:
        Exception while deploying the app [test] : The lifecycle method [doTest] must not throw a checked exception. Related annotation information: annotation [@javax.annotation.PostConstruct()] on annotated element [public void StartupSingleton.doTest() throws java.lang.Exception] of type [METHOD]
        The lifecycle method [doTest] must not throw a checked exception. Related annotation information: annotation [@javax.annotation.PostConstruct()] on annotated element [public void StartupSingleton.doTest() throws java.lang.Exception] of type [METHOD]
        at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:367)
        at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:375)
        at org.glassfish.apf.impl.AnnotationProcessorImpl.processAnnotations(AnnotationProcessorImpl.java:289)
        at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:217)
        at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:134)
        at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:626)
        at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:462)
        at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:446)
        at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:419)
        at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:396)
        at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:271)
        at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:280)
        at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:241)
        at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:161)
        at org.glassfish.javaee.core.deployment.DolProvider.processDOL(DolProvider.java:198)
        at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:222)
        at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:96)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:878)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:818)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:374)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:537)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
        at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:164)
        at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:595)
        at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:482)
        at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:410)
        at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:401)
        at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:233)
        at java.util.TimerThread.mainLoop(Timer.java:555)
        at java.util.TimerThread.run(Timer.java:505)
        Caused by: java.lang.IllegalArgumentException: The lifecycle method [doTest] must not throw a checked exception
        at com.sun.enterprise.deployment.annotation.handlers.AbstractResourceHandler.validateAnnotatedLifecycleMethod(AbstractResourceHandler.java:186)
        at com.sun.enterprise.deployment.annotation.handlers.PostConstructHandler.processAnnotation(PostConstructHandler.java:72)
        at com.sun.enterprise.deployment.annotation.handlers.AbstractResourceHandler.processAnnotation(AbstractResourceHandler.java:142)
        at com.sun.enterprise.deployment.annotation.factory.SJSASFactory$LazyAnnotationHandler.processAnnotation(SJSASFactory.java:148)
        at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:344)
        ... 34 more

        Upon fixing app, it deploys & no hang present.

        Show
        tlcksnyder added a comment - Provided app fails to deploy: Exception while deploying the app [test] : The lifecycle method [doTest] must not throw a checked exception. Related annotation information: annotation [@javax.annotation.PostConstruct()] on annotated element [public void StartupSingleton.doTest() throws java.lang.Exception] of type [METHOD] The lifecycle method [doTest] must not throw a checked exception. Related annotation information: annotation [@javax.annotation.PostConstruct()] on annotated element [public void StartupSingleton.doTest() throws java.lang.Exception] of type [METHOD] at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:367) at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:375) at org.glassfish.apf.impl.AnnotationProcessorImpl.processAnnotations(AnnotationProcessorImpl.java:289) at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:217) at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:134) at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:626) at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:462) at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:446) at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:419) at com.sun.enterprise.deployment.archivist.Archivist.readDeploymentDescriptors(Archivist.java:396) at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:271) at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:280) at com.sun.enterprise.deployment.archivist.Archivist.open(Archivist.java:241) at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:161) at org.glassfish.javaee.core.deployment.DolProvider.processDOL(DolProvider.java:198) at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:222) at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:96) at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:878) at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:818) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:374) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219) at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:537) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423) at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762) at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:164) at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:595) at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:482) at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:410) at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:401) at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:233) at java.util.TimerThread.mainLoop(Timer.java:555) at java.util.TimerThread.run(Timer.java:505) Caused by: java.lang.IllegalArgumentException: The lifecycle method [doTest] must not throw a checked exception at com.sun.enterprise.deployment.annotation.handlers.AbstractResourceHandler.validateAnnotatedLifecycleMethod(AbstractResourceHandler.java:186) at com.sun.enterprise.deployment.annotation.handlers.PostConstructHandler.processAnnotation(PostConstructHandler.java:72) at com.sun.enterprise.deployment.annotation.handlers.AbstractResourceHandler.processAnnotation(AbstractResourceHandler.java:142) at com.sun.enterprise.deployment.annotation.factory.SJSASFactory$LazyAnnotationHandler.processAnnotation(SJSASFactory.java:148) at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:344) ... 34 more Upon fixing app, it deploys & no hang present.

          People

          • Assignee:
            jjsnyder83
            Reporter:
            GarethSiret
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: