2 Replies Latest reply on Jan 23, 2014 9:09 AM by Donghwan Kim

    Injection fails in ServerApplicationConfig

    Donghwan Kim Newbie

      I've tried to inject some bean to javax.websocket.server.ServerApplicationConfig instance to be scanned and instantiated by container but it doesn't work.


      Use case

      I need to make some bean be available to ServletContextListener and ServerApplicationConfig to handle HTTP request and WebSocket together. Although I made it static, I'd like to try graceful solution using CDI. Spring and Guice can't help here because they are created by container.

      portal-java-examples/server/platform/jee7/src/main/java/io/github/flowersinthesand/portal/testsuite/Bootstrap.java at ma…


      To reproduce

      I used wildfly-maven-plugin




      public class TestBean {}



      public class TestServerApplicationConfig implements ServerApplicationConfig {
        TestBean testBean;
        public Set<ServerEndpointConfig> getEndpointConfigs(Set<Class<? extends Endpoint>> endpointClasses) {
        return null;
        public Set<Class<?>> getAnnotatedEndpointClasses(Set<Class<?>> scanned) {
        return null;



      public class TestServletContextListener implements ServletContextListener {
        TestBean testBean;
        public void contextInitialized(ServletContextEvent sce) {
        public void contextDestroyed(ServletContextEvent sce) {}


      And the result:

      21:09:49,507 INFO  [stdout] (MSC service thread 1-4) ServerApplicationConfig

      21:09:49,508 INFO  [stdout] (MSC service thread 1-4) null

      21:09:50,776 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016005: Starting Services for CDI deployment: portal-example-0.war

      21:09:51,550 INFO  [org.jboss.weld.Version] (MSC service thread 1-6) WELD-000900: 2.1.0 (CR1)

      21:09:51,838 INFO  [org.jboss.weld.deployer] (MSC service thread 1-6) JBAS016008: Starting weld service for deployment portal-example-0.war

      21:09:57,273 INFO  [stdout] (MSC service thread 1-5) ServletContextListener

      21:09:57,284 INFO  [stdout] (MSC service thread 1-5) io.github.flowersinthesand.portal.example.TestBean@16acb345

      21:09:58,689 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-5) JBAS018210: Register web context: /portal-example-0

      21:09:59,679 INFO  [org.jboss.as.server] (management-handler-thread - 4) JBAS018559: Deployed "portal-example-0.war" (runtime-name : "portal-example-0



      As you can see, CDI service starts after instantiation of ServerApplicationConfig. Is this expected or bug?