glassfish
  1. glassfish
  2. GLASSFISH-19786

CDI Instantiation Error - CDI deployment failure:WELD-001408 Unsatisfied dependencies for type [InstanceManager] with qualifiers

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 4.0_b78
    • Fix Version/s: 4.0
    • Component/s: cdi
    • Labels:
      None
    • Environment:

      All

      Description

      It would appear there is problem with the CDI Container service in Glassfish 4.0 b78 fails to be initialised.

      I even tried a new WAR with just a single POJO, a dummy Java class with no methods at all, and I received the same error.

      There is not an issue with GlassFish 4.0 b77 server, only since I upgraded.

      [main] INFO org.jboss.weld.Version - WELD-000900 SNAPSHOT
      [main] WARN org.jboss.weld.Bootstrap - WELD-001440 Scope type @javax.enterprise.context.ApplicationScoped() used on injection point [BackedAnnotatedField] @Inject @ApplicationScoped private je7hb.websocket.basic.FakeServlet.chatRoom
      >>>> SampleSingleton.init() called
      Mar 07, 2013 9:33:48 AM org.glassfish.tyrus.servlet.TyrusServletContainerInitializer onStartup
      INFO: Registering WebSocket filter for url pattern /*
      Mar 07, 2013 9:33:48 AM com.sun.enterprise.web.WebApplication start
      INFO: Loading application [mywebapp] at [/mywebapp]
      [weld-worker-2] WARN org.jboss.weld.Bootstrap - WELD-001440 Scope type @javax.enterprise.context.ApplicationScoped() used on injection point [BackedAnnotatedField] @Inject @ApplicationScoped private je7hb.websocket.basic.ChatServiceEndPoint.chatRoom
      [weld-worker-3] WARN org.jboss.weld.Bootstrap - WELD-001440 Scope type @javax.enterprise.context.ApplicationScoped() used on injection point [BackedAnnotatedField] @Inject @ApplicationScoped private je7hb.websocket.basic.FakeServlet.chatRoom
      [main] WARN org.jboss.weld.Bootstrap - WELD-001440 Scope type @javax.enterprise.context.ApplicationScoped() used on injection point [BackedAnnotatedField] @Inject @ApplicationScoped private je7hb.websocket.basic.FakeServlet.chatRoom
      Mar 07, 2013 9:33:48 AM com.sun.enterprise.v3.server.ApplicationLifecycle deploy
      SEVERE: Exception during lifecycle processing
      org.glassfish.deployment.common.DeploymentException: CDI deployment failure:WELD-001408 Unsatisfied dependencies for type [InstanceManager] with qualifiers [@Default] at injection point [[UnbackedAnnotatedParameter] Parameter 1 of [UnbackedAnnotatedConstructor] @Inject protected org.jboss.weld.environment.se.WeldContainer(InstanceManager, BeanManager)]
      at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:247)
      at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
      at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:364)
      >>>> SampleSingleton.destroy() called
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:497)
      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$1.run(CommandRunnerImpl.java:528)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:524)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.Subject.doAs(Subject.java:357)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:523)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:547)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1424)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1759)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1675)
      at com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:133)
      at je7hb.common.webcontainer.embedded.glassfish.AbstractEmbeddedRunner.deployWithRename(AbstractEmbeddedRunner.java:73)
      at je7hb.common.weber.embedded.glassfish.EmbeddedRunner.main(EmbeddedRunner.java:19)
      Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [InstanceManager] with qualifiers [@Default] at injection point [[UnbackedAnnotatedParameter] Parameter 1 of [UnbackedAnnotatedConstructor] @Inject protected org.jboss.weld.environment.se.WeldContainer(InstanceManager, BeanManager)]
      at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:381)
      at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:309)
      at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:172)
      at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:203)
      at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:493)
      at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:69)
      at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:67)
      at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
      at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
      at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:722)

      Mar 07, 2013 9:33:48 AM org.glassfish.api.ActionReport failure
      SEVERE: Exception while loading the app
      Mar 07, 2013 9:33:48 AM org.glassfish.tyrus.server.TyrusServerContainer stop
      INFO: Closing down : org.glassfish.tyrus.server.TyrusEndpoint@5e9b0166
      Mar 07, 2013 9:33:48 AM org.glassfish.tyrus.server.TyrusServerContainer stop
      INFO: Closing down : org.glassfish.tyrus.server.TyrusEndpoint@6150e9a2
      Mar 07, 2013 9:33:48 AM org.glassfish.tyrus.server.TyrusServerContainer stop
      INFO: Closing down : org.glassfish.tyrus.server.TyrusEndpoint@39ece0e3
      Mar 07, 2013 9:33:48 AM com.sun.web.server.WebContainerListener preDestroy
      SEVERE: Exception during invocation of InjectionManager.destroyManagedObject on org.glassfish.tyrus.servlet.TyrusServletFilter@24633a36 of web module StandardEngine[glassfish-web].StandardHost[server].StandardContext[/mywebapp]
      java.lang.IllegalStateException: Unknown JCDI-enabled managed bean org.glassfish.tyrus.servlet.TyrusServletFilter@24633a36 of class class org.glassfish.tyrus.servlet.TyrusServletFilter
      at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.destroyManagedBean(ManagedBeanManagerImpl.java:628)
      at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.destroyManagedObject(InjectionManagerImpl.java:439)
      at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.destroyManagedObject(InjectionManagerImpl.java:414)
      at com.sun.web.server.WebContainerListener.preDestroy(WebContainerListener.java:186)
      at com.sun.web.server.WebContainerListener.containerEvent(WebContainerListener.java:151)
      at org.apache.catalina.core.ContainerBase.fireContainerEvent(ContainerBase.java:1579)
      at org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:334)
      at org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:5319)
      at org.apache.catalina.core.StandardContext.stop(StandardContext.java:6082)
      at com.sun.enterprise.web.WebModule.stop(WebModule.java:725)
      at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1172)
      at com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:2438)
      at com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:2393)
      at com.sun.enterprise.web.WebApplication.stop(WebApplication.java:191)
      at org.glassfish.internal.data.EngineRef.stop(EngineRef.java:161)
      at com.sun.enterprise.v3.server.ApplicationLifecycle$2.actOn(ApplicationLifecycle.java:268)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:503)
      at com.sun.enterprise.v3.servecationLifecycle.deploy(ApplicationLifecycle.java:219)
      at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:528)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:524)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.Subject.doAs(Subject.java:357)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:523)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:547)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1424)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1759)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1675)
      at com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:133)
      at je7hb.common.webcontainer.embedded.glassfish.AbstractEmbeddedRunner.deployWithRename(AbstractEmbeddedRunner.java:73)
      at je7hb.common.webcontainer.embedded.glassfish.EmbeddedRunner.main(EmbeddedRunner.java:19)

      Mar 07, 2013 9:33:48 AM org.glassfish.weld.WeldDeployer event
      WARNING: JCDI shutdown error
      java.lang.IllegalStateException: Singleton is not set. Is your Thread.currentThread().getContextClassLoader() set correctly?
      at org.jboss.weld.bootstrap.api.helpers.IsolatedStaticSingletonProvider$IsolatedStaticSingleton.get(IsolatedStaticSingletonProvider.java:52)
      at org.jboss.weld.Container.instance(Container.java:54)
      at org.jboss.weld.bootstrap.WeldBootstrap.shutdown(WeldBootstrap.java:597)
      at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:293)
      at org.glassfish.kernel.event.EventsImpl$1.run(EventsImpl.java:123)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:722)

      Mar 07, 2013 9:33:48 AM org.glassfish.deployment.admin.DeployCommand execute
      SEVERE: Exception while loading the app : CDI deployment failure:WELD-001408 Unsatisfied dependencies for type [InstanceManager] with qualifiers [@Default] at injection point [[UnbackedAnnotatedParameter] Parameter 1 of [UnbackedAnnotatedConstructor] @Inject protected org.jboss.weld.environment.se.WeldContainer(InstanceManager, BeanManager)]
      org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [InstanceManager] with qualifiers [@Default] at injection point [[UnbackedAnnotatedParameter] Parameter 1 of [UnbackedAnnotatedConstructor] @Inject protected org.jboss.weld.environment.se.WeldContainer(InstanceManager, BeanManager)]
      at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:381)
      at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:309)
      at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:172)
      at org.jboss.weld.bootstrap.Validator.validateRIBean(Valjava:203)
      at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:493)
      at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:69)
      at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:67)
      at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
      at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
      at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:722)

            • Press the ENTER key to stop the server ****
              > Building > :run
              Mar 07, 2013 9:33:51 AM org.glassfish.admin.mbeanserver.JMXStartupService shutdown
              INFO: JMXStartupService and JMXConnectors have been shut down.
              JdbcRuntimeExtension, getAllSystemRAResourcesAndPools = [GlassFishConfigBean.org.glassfish.jdbc.config.JdbcResource, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcResource, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcConnectionPool, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcConnectionPool]
              Mar 07, 2013 9:33:51 AM com.sun.enterprise.v3.server.AppServerStartup stop
              INFO: Shutdown procedure finished

      BUILD SUCCESSFUL

      Total time: 14.432 secs
      peterpilgrim@Peters-MacBook-Pro-3.local [1110] >

        Activity

        Hide
        phil.zampino added a comment -

        A change was committed today to prevent the weld SE implementation from getting pulled into the server classpath. Please try again with the latest.

        Show
        phil.zampino added a comment - A change was committed today to prevent the weld SE implementation from getting pulled into the server classpath. Please try again with the latest.
        Hide
        peter_pilgrim added a comment -

        Thanks! I see there is 4.0-b79 in repo https://maven.java.net/content/groups/promoted/javax/javaee-api/ . I will give it a go.

        PP

        Show
        peter_pilgrim added a comment - Thanks! I see there is 4.0-b79 in repo https://maven.java.net/content/groups/promoted/javax/javaee-api/ . I will give it a go. PP
        Hide
        peter_pilgrim added a comment -

        I upgraded the build to 4.0-b79. Sadly, this fix is still not working and I get the same error: session

        INFO: EJB5181:Portable JNDI names for EJB SampleSingleton: [java:global/mywebapp/SampleSingleton, java:global/mywebapp/SampleSingleton!je7hb.websocket.basic.SampleSingleton]
        [main] INFO org.jboss.weld.Version - WELD-000900 SNAPSHOT
        [main] WARN org.jboss.weld.Bootstrap - WELD-001440 Scope type @javax.enterprise.context.ApplicationScoped() used on injection point [BackedAnnotatedField] @Inject @ApplicationScoped private je7hb.websocket.basic.FakeServlet.chatRoom
        >>>> SampleSingleton.init() called
        Mar 07, 2013 11:30:09 PM org.glassfish.tyrus.servlet.TyrusServletContainerInitializer onStartup
        INFO: Registering WebSocket filter for url pattern /*
        Mar 07, 2013 11:30:09 PM com.sun.enterprise.web.WebApplication start
        INFO: Loading application [mywebapp] at [/mywebapp]
        Mar 07, 2013 11:30:09 PM com.sun.enterprise.v3.server.ApplicationLifecycle deploy
        SEVERE: Exception during lifecycle processing
        org.glassfish.deployment.common.DeploymentException: CDI deployment failure:WELD-001408 Unsatisfied dependencies for type [InstanceManager] with qualifiers [@Default] at injection point [[UnbackedAnnotatedParameter] Parameter 1 of [UnbackedAnnotatedConstructor] @Inject protected org.jboss.weld.environment.se.WeldContainer(InstanceManager, BeanManager)]
        at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:247)
        at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
        at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:364)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:497)
        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$1.run(CommandRunnerImpl.java:527)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:357)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)
        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:1761)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
        at com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:133)
        at je7hb.common.webcontainer.embedded.glassfish.AbstractEmbeddedRunner.deployWithRename(AbstractEmbeddedRunner.java:73)
        at je7hb.common.we>>>> SampleSingleton.destroy() called
        ner.embedded.glassfish.EmbeddedRunner.main(EmbeddedRunner.java:19)
        Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [InstanceManager] with qualifiers [@Default] at injection point [[UnbackedAnnotatedParameter] Parameter 1 of [UnbackedAnnotatedConstructor] @Inject protected org.jboss.weld.environment.se.WeldContainer(InstanceManager, BeanManager)]
        at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:381)
        at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:309)
        at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:172)
        at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:203)
        at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:493)
        at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:69)
        at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:67)
        at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
        at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)

        Mar 07, 2013 11:30:09 PM org.glassfish.api.ActionReport failure
        SEVERE: Exception while loading the app
        Mar 07, 2013 11:30:09 PM org.glassfish.tyrus.server.TyrusServerContainer stop
        INFO: Closing down : org.glassfish.tyrus.server.TyrusEndpoint@720c51a0
        Mar 07, 2013 11:30:09 PM org.glassfish.tyrus.server.TyrusServerContainer stop
        INFO: Closing down : org.glassfish.tyrus.server.TyrusEndpoint@14fdaad6
        Mar 07, 2013 11:30:09 PM org.glassfish.tyrus.server.TyrusServerContainer stop
        INFO: Closing down : org.glassfish.tyrus.server.TyrusEndpoint@45c8899b
        Mar 07, 2013 11:30:09 PM com.sun.web.server.WebContainerListener preDestroy
        SEVERE: Exception during invocation of InjectionManager.destroyManagedObject on org.glassfish.tyrus.servlet.TyrusServletFilter@23644cf3 of web module StandardEngine[glassfish-web].StandardHost[server].StandardContext[/mywebapp]
        java.lang.IllegalStateException: Unknown JCDI-enabled managed bean org.glassfish.tyrus.servlet.TyrusServletFilter@23644cf3 of class class org.glassfish.tyrus.servlet.TyrusServletFilter
        at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.destroyManagedBean(ManagedBeanManagerImpl.java:628)
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.destroyManagedObject(InjectionManagerImpl.java:439)
        at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.destroyManagedObject(InjectionManagerImpl.java:414)
        at com.sun.web.server.WebContainerListener.preDestroy(WebContainerListener.java:186)
        at com.sun.web.server.WebContainerListener.containerEvent(WebContainerListener.java:151)
        at org.apache.catalina.core.ContainerBase.fireContainerEvent(ContainerBase.java:1579)
        at org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:334)
        at org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:5319)
        at org.apache.catalina.core.StandardContext.stop(StandardContext.java:6082)
        at com.sun.enterprise.web.WebModule.stop(WebModule.java:725)
        at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1172)
        at com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:2447)
        at com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:2402)
        at com.sun.enterprise.web.WebApplication.stop(WebApplication.java:191)
        at org.glassfish.internal.data.EngineRef.stop(EngineRef.java:161)
        at com.sun.enterprise.v3.server.ApplicationLifecycle$2.actOn(ApplicationLifecycle.java:268)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:503)
        at com.sun.enterprise.v3.servicationLifecycle.deploy(ApplicationLifecycle.java:219)
        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:357)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)
        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:1761)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
        at com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:133)
        at je7hb.common.webcontainer.embedded.glassfish.AbstractEmbeddedRunner.deployWithRename(AbstractEmbeddedRunner.java:73)
        at je7hb.common.webcontainer.embedded.glassfish.EmbeddedRunner.main(EmbeddedRunner.java:19)

        Mar 07, 2013 11:30:09 PM org.glassfish.deployment.admin.DeployCommand execute
        SEVERE: Exception while loading the app : CDI deployment failure:WELD-001408 Unsatisfied dependencies for type [InstanceManager] with qualifiers [@Default] at injection point [[UnbackedAnnotatedParameter] Parameter 1 of [UnbackedAnnotatedConstructor] @Inject protected org.jboss.weld.environment.se.WeldContainer(InstanceManager, BeanManager)]
        org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [InstanceManager] with qualifiers [@Default] at injection point [[UnbackedAnnotatedParameter] Parameter 1 of [UnbackedAnnotatedConstructor] @Inject protected org.jboss.weld.environment.se.WeldContainer(InstanceManager, BeanManager)]
        at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:381)
        at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:309)
        at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:172)
        at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:203)
        at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:493)
        at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:69)
        at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:67)
        at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60)
        at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)

        Mar 07, 2013 11:30:09 PM org.glassfish.weld.WeldDeployer event
        WARNING: JCDI shutdown error
        java.lang.IllegalStateException: Singleton is not set. Is your Thread.currentThread().getContextClassLoader() set correctly?
        at org.jboss.weld.bootstrap.api.helpers.IsolatedStaticSingletonProvider$IsolatedStaticSingleton.get(IsolatedStaticSingletonProvider.java:52)
        at org.jboss.weld.Container.instance(Container.java:54)
        at org.jboss.weld.bootstrap.WeldBootstrap.shutdown(WeldBootstrap.java:597)
        at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:293)
        at org.glassfish.kernel.event.EventsImpl$1.run(EventsImpl.java:123)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)

              • Press the ENTER key to stop the server ****
                > Building > :run
                Mar 07, 2013 11:32:35 PM org.glassfish.admin.mbeanserver.JMXStartupService shutdown
                INFO: JMXStartupService and JMXConnectors have been shut down.
                JdbcRuntimeExtension, getAllSystemRAResourcesAndPools = [GlassFishConfigBean.org.glassfish.jdbc.config.JdbcResource, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcResource, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcConnectionPool, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcConnectionPool]
                Mar 07, 2013 11:32:35 PM com.sun.enterprise.v3.server.AppServerStartup stop
                INFO: Shutdown procedure finished

        BUILD SUCCESSFUL

        Total time: 2 mins 35.427 secs

        ///////////

        package je7hb.websocket.basic;

        import javax.annotation.PostConstruct;
        import javax.annotation.PreDestroy;
        import javax.ejb.Singleton;
        import javax.ejb.Startup;
        import java.util.concurrent.atomic.AtomicInteger;

        /**

        • The type SampleSingleton
          *
        • @author Peter Pilgrim
          */
          @Singleton
          @Startup
          public class SampleSingleton {
          private AtomicInteger counter = new AtomicInteger(5000);
          @PostConstruct
          public void init() { System.out.printf(">>>> %s.init() called\n", getClass().getSimpleName()); }

        @PreDestroy
        public void destroy()

        { System.out.printf(">>>> %s.destroy() called\n", getClass().getSimpleName()); }

        public int count()

        { return counter.getAndAdd(2); }

        public String getFullName()

        { return "Peter Pilgrim"; }

        }

        ///////////

        package je7hb.websocket.basic;

        import javax.ejb.EJB;
        import javax.inject.Inject;
        import javax.naming.Context;
        import javax.naming.InitialContext;
        import javax.naming.NamingException;
        import javax.websocket.OnClose;
        import javax.websocket.OnMessage;
        import javax.websocket.OnOpen;
        import javax.websocket.Session;
        import javax.websocket.server.ServerEndpoint;
        import java.util.Date;

        /**

        • The type SingletonEJBWebSocketEndpoint
          *
        • @author Peter Pilgrim
          */
          @ServerEndpoint("/singleton")
          public class SingletonEJBWebSocketEndpoint {

        @Inject
        private SampleSingleton sampleSingleton;

        @OnOpen
        public void open(Session session) {
        System.out.printf("%s.open() called session=%s\n", getClass().getSimpleName(), session );

        // This is a work around
        System.out.printf(" sampleSingleton = %s BEFORE\n", sampleSingleton );
        if ( sampleSingleton == null) {
        // Look up the object
        Context initialContext = null;
        try

        { initialContext = new InitialContext(); Object obj = initialContext.lookup("java:global/mywebapp/SampleSingleton"); System.out.printf(" obj=%s\n", obj); sampleSingleton = (SampleSingleton)obj; }

        catch (NamingException e)

        { e.printStackTrace(); }

        }
        System.out.printf(" sampleSingleton = %s AFTER\n", sampleSingleton );
        }

        @OnClose
        public void close(Session session)

        { System.out.printf("%s.close() called session=%s\n", getClass().getSimpleName(), session); System.out.printf(" sampleSingleton = %s\n", sampleSingleton ); }

        @OnMessage
        public String generateReply( String message )

        { return String.format("%s - name: %s, counter: %d, message:%s", new Date(), sampleSingleton.getFullName(), sampleSingleton.count(), message.toUpperCase()); }

        }

        //////////

        package je7hb.websocket.basic;

        import javax.enterprise.context.ApplicationScoped;
        import javax.inject.Inject;
        import javax.servlet.ServletConfig;
        import javax.servlet.ServletException;
        import javax.servlet.annotation.WebServlet;
        import javax.servlet.http.HttpServlet;
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.http.HttpServletResponse;
        import java.io.IOException;
        import java.util.Date;

        /**

        • The type FakeServlet
          *
        • @author Peter Pilgrim
          */
          @WebServlet("/fake")
          public class FakeServlet extends HttpServlet {

        @Inject
        @ApplicationScoped
        private ChatRoom chatRoom;

        @Override
        public void init(ServletConfig config) throws ServletException

        { super.init(config); System.out.printf("%s.init() called with chatRoom=%s\n", getClass().getSimpleName(), chatRoom); }

        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException

        { resp.setContentType("text/plain"); resp.getWriter().printf("Date: %s Servlet %s with chatRoom=%s\n", new Date(), getClass(), chatRoom ); }

        }

        ///////////

        Show
        peter_pilgrim added a comment - I upgraded the build to 4.0-b79. Sadly, this fix is still not working and I get the same error: session INFO: EJB5181:Portable JNDI names for EJB SampleSingleton: [java:global/mywebapp/SampleSingleton, java:global/mywebapp/SampleSingleton!je7hb.websocket.basic.SampleSingleton] [main] INFO org.jboss.weld.Version - WELD-000900 SNAPSHOT [main] WARN org.jboss.weld.Bootstrap - WELD-001440 Scope type @javax.enterprise.context.ApplicationScoped() used on injection point [BackedAnnotatedField] @Inject @ApplicationScoped private je7hb.websocket.basic.FakeServlet.chatRoom >>>> SampleSingleton.init() called Mar 07, 2013 11:30:09 PM org.glassfish.tyrus.servlet.TyrusServletContainerInitializer onStartup INFO: Registering WebSocket filter for url pattern /* Mar 07, 2013 11:30:09 PM com.sun.enterprise.web.WebApplication start INFO: Loading application [mywebapp] at [/mywebapp] Mar 07, 2013 11:30:09 PM com.sun.enterprise.v3.server.ApplicationLifecycle deploy SEVERE: Exception during lifecycle processing org.glassfish.deployment.common.DeploymentException: CDI deployment failure:WELD-001408 Unsatisfied dependencies for type [InstanceManager] with qualifiers [@Default] at injection point [ [UnbackedAnnotatedParameter] Parameter 1 of [UnbackedAnnotatedConstructor] @Inject protected org.jboss.weld.environment.se.WeldContainer(InstanceManager, BeanManager)] at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:247) at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131) at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:364) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:497) 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$1.run(CommandRunnerImpl.java:527) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:357) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522) 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:1761) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674) at com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:133) at je7hb.common.webcontainer.embedded.glassfish.AbstractEmbeddedRunner.deployWithRename(AbstractEmbeddedRunner.java:73) at je7hb.common.we>>>> SampleSingleton.destroy() called ner.embedded.glassfish.EmbeddedRunner.main(EmbeddedRunner.java:19) Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [InstanceManager] with qualifiers [@Default] at injection point [ [UnbackedAnnotatedParameter] Parameter 1 of [UnbackedAnnotatedConstructor] @Inject protected org.jboss.weld.environment.se.WeldContainer(InstanceManager, BeanManager)] at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:381) at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:309) at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:172) at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:203) at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:493) at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:69) at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:67) at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60) at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Mar 07, 2013 11:30:09 PM org.glassfish.api.ActionReport failure SEVERE: Exception while loading the app Mar 07, 2013 11:30:09 PM org.glassfish.tyrus.server.TyrusServerContainer stop INFO: Closing down : org.glassfish.tyrus.server.TyrusEndpoint@720c51a0 Mar 07, 2013 11:30:09 PM org.glassfish.tyrus.server.TyrusServerContainer stop INFO: Closing down : org.glassfish.tyrus.server.TyrusEndpoint@14fdaad6 Mar 07, 2013 11:30:09 PM org.glassfish.tyrus.server.TyrusServerContainer stop INFO: Closing down : org.glassfish.tyrus.server.TyrusEndpoint@45c8899b Mar 07, 2013 11:30:09 PM com.sun.web.server.WebContainerListener preDestroy SEVERE: Exception during invocation of InjectionManager.destroyManagedObject on org.glassfish.tyrus.servlet.TyrusServletFilter@23644cf3 of web module StandardEngine [glassfish-web] .StandardHost [server] .StandardContext [/mywebapp] java.lang.IllegalStateException: Unknown JCDI-enabled managed bean org.glassfish.tyrus.servlet.TyrusServletFilter@23644cf3 of class class org.glassfish.tyrus.servlet.TyrusServletFilter at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.destroyManagedBean(ManagedBeanManagerImpl.java:628) at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.destroyManagedObject(InjectionManagerImpl.java:439) at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.destroyManagedObject(InjectionManagerImpl.java:414) at com.sun.web.server.WebContainerListener.preDestroy(WebContainerListener.java:186) at com.sun.web.server.WebContainerListener.containerEvent(WebContainerListener.java:151) at org.apache.catalina.core.ContainerBase.fireContainerEvent(ContainerBase.java:1579) at org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:334) at org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:5319) at org.apache.catalina.core.StandardContext.stop(StandardContext.java:6082) at com.sun.enterprise.web.WebModule.stop(WebModule.java:725) at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:1172) at com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:2447) at com.sun.enterprise.web.WebContainer.unloadWebModule(WebContainer.java:2402) at com.sun.enterprise.web.WebApplication.stop(WebApplication.java:191) at org.glassfish.internal.data.EngineRef.stop(EngineRef.java:161) at com.sun.enterprise.v3.server.ApplicationLifecycle$2.actOn(ApplicationLifecycle.java:268) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:503) at com.sun.enterprise.v3.servicationLifecycle.deploy(ApplicationLifecycle.java:219) at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:357) at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522) 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:1761) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674) at com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:133) at je7hb.common.webcontainer.embedded.glassfish.AbstractEmbeddedRunner.deployWithRename(AbstractEmbeddedRunner.java:73) at je7hb.common.webcontainer.embedded.glassfish.EmbeddedRunner.main(EmbeddedRunner.java:19) Mar 07, 2013 11:30:09 PM org.glassfish.deployment.admin.DeployCommand execute SEVERE: Exception while loading the app : CDI deployment failure:WELD-001408 Unsatisfied dependencies for type [InstanceManager] with qualifiers [@Default] at injection point [ [UnbackedAnnotatedParameter] Parameter 1 of [UnbackedAnnotatedConstructor] @Inject protected org.jboss.weld.environment.se.WeldContainer(InstanceManager, BeanManager)] org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [InstanceManager] with qualifiers [@Default] at injection point [ [UnbackedAnnotatedParameter] Parameter 1 of [UnbackedAnnotatedConstructor] @Inject protected org.jboss.weld.environment.se.WeldContainer(InstanceManager, BeanManager)] at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:381) at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:309) at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:172) at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:203) at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:493) at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:69) at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:67) at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:60) at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:53) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Mar 07, 2013 11:30:09 PM org.glassfish.weld.WeldDeployer event WARNING: JCDI shutdown error java.lang.IllegalStateException: Singleton is not set. Is your Thread.currentThread().getContextClassLoader() set correctly? at org.jboss.weld.bootstrap.api.helpers.IsolatedStaticSingletonProvider$IsolatedStaticSingleton.get(IsolatedStaticSingletonProvider.java:52) at org.jboss.weld.Container.instance(Container.java:54) at org.jboss.weld.bootstrap.WeldBootstrap.shutdown(WeldBootstrap.java:597) at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:293) at org.glassfish.kernel.event.EventsImpl$1.run(EventsImpl.java:123) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) at java.lang.Thread.run(Thread.java:722) Press the ENTER key to stop the server **** > Building > :run Mar 07, 2013 11:32:35 PM org.glassfish.admin.mbeanserver.JMXStartupService shutdown INFO: JMXStartupService and JMXConnectors have been shut down. JdbcRuntimeExtension, getAllSystemRAResourcesAndPools = [GlassFishConfigBean.org.glassfish.jdbc.config.JdbcResource, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcResource, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcConnectionPool, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcConnectionPool] Mar 07, 2013 11:32:35 PM com.sun.enterprise.v3.server.AppServerStartup stop INFO: Shutdown procedure finished BUILD SUCCESSFUL Total time: 2 mins 35.427 secs /////////// package je7hb.websocket.basic; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.ejb.Singleton; import javax.ejb.Startup; import java.util.concurrent.atomic.AtomicInteger; /** The type SampleSingleton * @author Peter Pilgrim */ @Singleton @Startup public class SampleSingleton { private AtomicInteger counter = new AtomicInteger(5000); @PostConstruct public void init() { System.out.printf(">>>> %s.init() called\n", getClass().getSimpleName()); } @PreDestroy public void destroy() { System.out.printf(">>>> %s.destroy() called\n", getClass().getSimpleName()); } public int count() { return counter.getAndAdd(2); } public String getFullName() { return "Peter Pilgrim"; } } /////////// package je7hb.websocket.basic; import javax.ejb.EJB; import javax.inject.Inject; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.websocket.OnClose; import javax.websocket.OnMessage; import javax.websocket.OnOpen; import javax.websocket.Session; import javax.websocket.server.ServerEndpoint; import java.util.Date; /** The type SingletonEJBWebSocketEndpoint * @author Peter Pilgrim */ @ServerEndpoint("/singleton") public class SingletonEJBWebSocketEndpoint { @Inject private SampleSingleton sampleSingleton; @OnOpen public void open(Session session) { System.out.printf("%s.open() called session=%s\n", getClass().getSimpleName(), session ); // This is a work around System.out.printf(" sampleSingleton = %s BEFORE \n", sampleSingleton ); if ( sampleSingleton == null) { // Look up the object Context initialContext = null; try { initialContext = new InitialContext(); Object obj = initialContext.lookup("java:global/mywebapp/SampleSingleton"); System.out.printf(" obj=%s\n", obj); sampleSingleton = (SampleSingleton)obj; } catch (NamingException e) { e.printStackTrace(); } } System.out.printf(" sampleSingleton = %s AFTER \n", sampleSingleton ); } @OnClose public void close(Session session) { System.out.printf("%s.close() called session=%s\n", getClass().getSimpleName(), session); System.out.printf(" sampleSingleton = %s\n", sampleSingleton ); } @OnMessage public String generateReply( String message ) { return String.format("%s - name: %s, counter: %d, message:%s", new Date(), sampleSingleton.getFullName(), sampleSingleton.count(), message.toUpperCase()); } } ////////// package je7hb.websocket.basic; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Date; /** The type FakeServlet * @author Peter Pilgrim */ @WebServlet("/fake") public class FakeServlet extends HttpServlet { @Inject @ApplicationScoped private ChatRoom chatRoom; @Override public void init(ServletConfig config) throws ServletException { super.init(config); System.out.printf("%s.init() called with chatRoom=%s\n", getClass().getSimpleName(), chatRoom); } @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/plain"); resp.getWriter().printf("Date: %s Servlet %s with chatRoom=%s\n", new Date(), getClass(), chatRoom ); } } ///////////
        Hide
        Tim Quinn added a comment -

        I suspect the problem is that we've recently added CDI support to the app client container, so the manifest Class-Path for the gf-client-module.jar (in the GlassFish modules/ directory) refers to weld-se.jar.

        I think GlassFish loads every module in the modules/ directory, so weld-se.jar ends up on the class path.

        The change Phil referred to was for embedded only.

        Show
        Tim Quinn added a comment - I suspect the problem is that we've recently added CDI support to the app client container, so the manifest Class-Path for the gf-client-module.jar (in the GlassFish modules/ directory) refers to weld-se.jar. I think GlassFish loads every module in the modules/ directory, so weld-se.jar ends up on the class path. The change Phil referred to was for embedded only.
        Hide
        peter_pilgrim added a comment -

        You say it could be a classpath issue, which is causing WELD to fail, and I am executing the embedded runner.

        Here is the Gradle file, which I am using now ``gradle.build'':-

        apply plugin: 'java'
        apply plugin: 'maven'
        apply plugin: 'war'
        apply plugin: 'eclipse'
        apply plugin: 'idea'

        // Define equivalent Maven GAV coordinates.
        group = 'com.javaeehandbook.book1'
        archivesBaseName = 'ch07-websockets-basic'
        version = '1.0'

        repositories {
        mavenCentral()
        ivy

        { url "http://maven.java.net/content/groups/promoted/" }

        maven

        { url 'https://maven.java.net/content/groups/promoted' }

        maven

        { url 'http://repository.jboss.org/nexus/content/groups/public' }

        }

        dependencies

        { providedCompile 'org.glassfish.main.extras:glassfish-embedded-all:4.0-b79' providedCompile 'javax:javaee-api:7.0-b79' compile 'org.glassfish.main.extras:glassfish-embedded-all:4.0-b79' compile 'javax:javaee-api:7.0-b79' testCompile 'junit:junit:4.10' }

        war

        { // webXml = file("src/main/webapp/WEB-INF/web.xml") }

        task wrapper(type: Wrapper)

        { gradleVersion = '1.4' }

        // Override Gradle defaults - a force an exploded JAR view
        sourceSets {
        main

        { output.resourcesDir = 'build/classes/main' output.classesDir = 'build/classes/main' }

        test

        { output.resourcesDir = 'build/classes/test' output.classesDir = 'build/classes/test' }

        }

        task(run, dependsOn: 'classes', type: JavaExec)

        { description = 'Runs the main application' main = 'je7hb.common.webcontainer.embedded.glassfish.EmbeddedRunner' classpath = sourceSets.main.runtimeClasspath args 'Mary', 'Peter', 'Jane' standardInput = System.in }

        See also my blog entry for an example of the sort of ``EmbeddedRunner'' that I am running for the book: http://www.xenonique.co.uk/blog/?p=980

        Show
        peter_pilgrim added a comment - You say it could be a classpath issue, which is causing WELD to fail, and I am executing the embedded runner. Here is the Gradle file, which I am using now ``gradle.build'':- apply plugin: 'java' apply plugin: 'maven' apply plugin: 'war' apply plugin: 'eclipse' apply plugin: 'idea' // Define equivalent Maven GAV coordinates. group = 'com.javaeehandbook.book1' archivesBaseName = 'ch07-websockets-basic' version = '1.0' repositories { mavenCentral() ivy { url "http://maven.java.net/content/groups/promoted/" } maven { url 'https://maven.java.net/content/groups/promoted' } maven { url 'http://repository.jboss.org/nexus/content/groups/public' } } dependencies { providedCompile 'org.glassfish.main.extras:glassfish-embedded-all:4.0-b79' providedCompile 'javax:javaee-api:7.0-b79' compile 'org.glassfish.main.extras:glassfish-embedded-all:4.0-b79' compile 'javax:javaee-api:7.0-b79' testCompile 'junit:junit:4.10' } war { // webXml = file("src/main/webapp/WEB-INF/web.xml") } task wrapper(type: Wrapper) { gradleVersion = '1.4' } // Override Gradle defaults - a force an exploded JAR view sourceSets { main { output.resourcesDir = 'build/classes/main' output.classesDir = 'build/classes/main' } test { output.resourcesDir = 'build/classes/test' output.classesDir = 'build/classes/test' } } task(run, dependsOn: 'classes', type: JavaExec) { description = 'Runs the main application' main = 'je7hb.common.webcontainer.embedded.glassfish.EmbeddedRunner' classpath = sourceSets.main.runtimeClasspath args 'Mary', 'Peter', 'Jane' standardInput = System.in } See also my blog entry for an example of the sort of ``EmbeddedRunner'' that I am running for the book: http://www.xenonique.co.uk/blog/?p=980
        Hide
        Tim Quinn added a comment -

        (blush)

        OK, you are using embedded!

        The change Phil referred to went in earlier today (March 7). I don't think promoted build 79 has it.

        Tonight's nightly build should, though.

        Show
        Tim Quinn added a comment - (blush) OK, you are using embedded! The change Phil referred to went in earlier today (March 7). I don't think promoted build 79 has it. Tonight's nightly build should, though.
        Hide
        peter_pilgrim added a comment -

        How do you grab the nightly build using Maven or Gradle?

        Show
        peter_pilgrim added a comment - How do you grab the nightly build using Maven or Gradle?
        Hide
        phil.zampino added a comment -

        Has this been tested with a more recent build, per Tim's suggestion?

        Show
        phil.zampino added a comment - Has this been tested with a more recent build, per Tim's suggestion?
        Hide
        phil.zampino added a comment -

        This appears to have been resolved since 4.0-b81

        Show
        phil.zampino added a comment - This appears to have been resolved since 4.0-b81

          People

          • Assignee:
            phil.zampino
            Reporter:
            peter_pilgrim
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: