2 Replies Latest reply on Mar 25, 2013 9:14 AM by Jonathan Fuerth

    Why is my @Singleton @Service MyService not auto started?

    Hilco Wijbenga Newbie

      Using the Errai CDI Maven Archetype, I managed to get the following working (i.e. it prints "Running!" at startup so MyService is started automatically as intended):

       

      import javax.inject.Singleton;

      import org.jboss.errai.bus.server.annotations.Service;

       

      @Singleton

      @Service

      public MyService {

        public MyService() {

          System.out.println("Running!");

        }

      }

       

      After this initial success, I tried to do the same in my own app. So I added all the Errai&Weld JARs to my own project, I included Tomcat's context.xml, and I updated the web.xml. All copied from the Maven archetype's generated code.

       

      Everything starts up properly (i.e. no stack traces and the right JAR is being scanned) but I do not see "Running!" (the actual message is very big and impossible to miss). Does anyone have an idea what I did wrong?

       

      Apache Maven 3.0.4 (r1232337; 2012-01-17 00:44:56-0800)

      Java version: 1.7.0_09, vendor: Oracle Corporation

      Java home: /usr/lib64/icedtea7/jre

      Default locale: en_CA, platform encoding: UTF-8

      OS name: "linux", version: "3.7.10-gentoo", arch: "amd64", family: "unix"

      Apache Tomcat 6.0.36

       

      The relevant logging is below (mvn tomcat6:run-war):

       

      [INFO] Creating Tomcat server configuration at /home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat

      Mar 22, 2013 6:19:08 PM org.apache.catalina.startup.Embedded start

      INFO: Starting tomcat server

      Mar 22, 2013 6:19:08 PM org.apache.catalina.core.StandardEngine start

      INFO: Starting Servlet Engine: Apache Tomcat/6.0.36

      18:19:09.815 [main                                                             ] INFO                                        org.jboss.weld.Version - WELD-000900 1.1.9 (Final)

      18:19:11.651 [main                                                             ] INFO                                      org.jboss.weld.Bootstrap - WELD-000101 Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.

      18:19:11.764 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000103 Enabled alternatives for Manager

      Enabled alternatives: [] []

      Registered contexts: [interface javax.enterprise.context.RequestScoped, interface javax.enterprise.context.SessionScoped, interface javax.enterprise.context.ApplicationScoped, interface javax.enterprise.context.ConversationScoped, interface javax.inject.Singleton, interface javax.enterprise.context.Dependent]

      Registered beans: 0

      : [] []

      18:19:11.765 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000104 Enabled decorator types for Manager

      Enabled alternatives: [] []

      Registered contexts: [interface javax.enterprise.context.RequestScoped, interface javax.enterprise.context.SessionScoped, interface javax.enterprise.context.ApplicationScoped, interface javax.enterprise.context.ConversationScoped, interface javax.inject.Singleton, interface javax.enterprise.context.Dependent]

      Registered beans: 0

      : []

      18:19:11.765 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000105 Enabled interceptor types for Manager

      Enabled alternatives: [] []

      Registered contexts: [interface javax.enterprise.context.RequestScoped, interface javax.enterprise.context.SessionScoped, interface javax.enterprise.context.ApplicationScoped, interface javax.enterprise.context.ConversationScoped, interface javax.inject.Singleton, interface javax.enterprise.context.Dependent]

      Registered beans: 0

      : []

      18:19:11.866 [main                                                             ] INFO                 org.jboss.errai.cdi.server.CDIExtensionPoints - starting errai cdi ...

      18:19:11.889 [main                                                             ] INFO            org.jboss.weld.environment.tomcat.Tomcat6Container - Tomcat 6 detected, CDI injection will be available in Servlets and Filters. Injection into Listeners is not supported

      18:19:11.917 [main                                                             ] WARN      org.jboss.weld.interceptor.util.InterceptionTypeRegistry - Class 'javax.ejb.PostActivate' not found, interception based on it is not enabled

      18:19:11.918 [main                                                             ] WARN      org.jboss.weld.interceptor.util.InterceptionTypeRegistry - Class 'javax.ejb.PrePassivate' not found, interception based on it is not enabled

      18:19:11.923 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000108 Decorator: Decorator [class org.jboss.weld.environment.se.threading.RunnableDecorator] decorates [Runnable] with delegate type [Runnable] and delegate qualifiers [@Default]

      18:19:11.925 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: Implicit Bean [javax.enterprise.inject.spi.InjectionPoint] with qualifiers [@Default]

      18:19:11.925 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: org.jboss.weld.bean-flat-Built-in-org.jboss.weld.context.bound.BoundRequestContext

      18:19:11.929 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: Managed Bean [class org.jboss.weld.environment.se.beans.InstanceManager] with qualifiers [@Any @Default]

      18:19:11.935 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: Implicit Bean [javax.enterprise.inject.Instance] with qualifiers [@Default]

      18:19:11.935 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: org.jboss.weld.bean-flat-Built-in-org.jboss.weld.context.SingletonContext

      18:19:11.935 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: org.jboss.weld.bean-flat-Built-in-org.jboss.weld.context.DependentContext

      18:19:11.937 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: Managed Bean [class org.jboss.weld.environment.se.ShutdownManager] with qualifiers [@Any @Default]

      18:19:11.942 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: Producer Method [String[]] with qualifiers [@Any @Parameters] declared as [[method] @Produces @Parameters public org.jboss.weld.environment.se.beans.ParametersFactory.getArgsAsArray()]

      18:19:11.942 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: org.jboss.weld.bean-flat-Built-in-org.jboss.weld.context.http.HttpRequestContext

      18:19:11.943 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: org.jboss.weld.bean-flat-Built-in-org.jboss.weld.context.http.HttpConversationContext

      18:19:11.944 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: org.jboss.weld.bean-flat-Built-in-org.jboss.weld.context.RequestContext

      18:19:11.944 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: Managed Bean [class org.jboss.weld.environment.se.beans.ParametersFactory] with qualifiers [@Any @Default]

      18:19:11.945 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: org.jboss.weld.bean-flat-Built-in-org.jboss.weld.context.http.HttpSessionContext

      18:19:11.946 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: Managed Bean [class org.jboss.weld.environment.se.WeldContainer] with qualifiers [@Any @Default]

      18:19:11.947 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: org.jboss.weld.bean-flat-Built-in-javax.enterprise.context.Conversation

      18:19:11.949 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: Implicit Bean [javax.enterprise.event.Event] with qualifiers [@Default]

      18:19:11.949 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: Producer Method [List<String>] with qualifiers [@Any @Parameters] declared as [[method] @Produces @Parameters public org.jboss.weld.environment.se.beans.ParametersFactory.getArgs()]

      18:19:11.950 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: org.jboss.weld.bean-flat-Built-in-org.jboss.weld.context.ApplicationContext

      18:19:11.950 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: org.jboss.weld.bean-flat-Built-in-org.jboss.weld.context.bound.BoundSessionContext

      18:19:11.950 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000106 Bean: org.jboss.weld.bean-flat-Built-in-org.jboss.weld.context.bound.BoundConversationContext

      18:19:12.072 [Thread-19                                                        ] DEBUG                                            ClasspathScanning - scanning inside: /home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/backend-impl-1.0-SNAPSHOT.jar

      18:19:12.072 [Thread-19                                                        ] DEBUG                                            ClasspathScanning - scanning inside: /home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-bus-2.2.0.Final.jar

      18:19:12.072 [Thread-19                                                        ] DEBUG                                            ClasspathScanning - scanning inside: /home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-cdi-client-2.2.0.Final.jar

      18:19:12.072 [Thread-19                                                        ] DEBUG                                            ClasspathScanning - scanning inside: /home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-ioc-2.2.0.Final.jar

      18:19:12.072 [Thread-19                                                        ] DEBUG                                            ClasspathScanning - scanning inside: /home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-marshalling-2.2.0.Final.jar

      18:19:12.072 [Thread-19                                                        ] DEBUG                                            ClasspathScanning - scanning inside: /home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-weld-integration-2.2.0.Final.jar

      18:19:12.104 [Thread-19                                                        ] DEBUG                      org.jboss.errai.reflections.Reflections - going to scan these urls:

              jar:file:/home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-ioc-2.2.0.Final.jar!/

              jar:file:/home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-bus-2.2.0.Final.jar!/

              jar:file:/home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-weld-integration-2.2.0.Final.jar!/

              jar:file:/home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-cdi-client-2.2.0.Final.jar!/

              jar:file:/home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-marshalling-2.2.0.Final.jar!/

              jar:file:/home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/backend-impl-1.0-SNAPSHOT.jar!/

       

       

      18:19:12.359 [Thread-19                                                        ] INFO                       org.jboss.errai.reflections.Reflections - Reflections took 253 ms to scan 6 urls, producing 309 keys and 1042 values [using 2 cores]

      18:19:12.365 [main                                                             ] DEBUG                        org.jboss.errai.config.rebind.EnvUtil - checking file:/home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/backend-impl-1.0-SNAPSHOT.jar!/ErraiApp.properties for configured types ...

      18:19:12.365 [main                                                             ] DEBUG                        org.jboss.errai.config.rebind.EnvUtil - checking file:/home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-bus-2.2.0.Final.jar!/ErraiApp.properties for configured types ...

      18:19:12.365 [main                                                             ] DEBUG                        org.jboss.errai.config.rebind.EnvUtil - checking file:/home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-cdi-client-2.2.0.Final.jar!/ErraiApp.properties for configured types ...

      18:19:12.366 [main                                                             ] DEBUG                        org.jboss.errai.config.rebind.EnvUtil - checking file:/home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-ioc-2.2.0.Final.jar!/ErraiApp.properties for configured types ...

      18:19:12.366 [main                                                             ] DEBUG                        org.jboss.errai.config.rebind.EnvUtil - checking file:/home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-marshalling-2.2.0.Final.jar!/ErraiApp.properties for configured types ...

      18:19:12.368 [main                                                             ] DEBUG                        org.jboss.errai.config.rebind.EnvUtil - checking file:/home/hilco/workspaces/igniteplay-project-add-errai/server/backend-war/target/tomcat/webapps/backend-war/WEB-INF/lib/errai-weld-integration-2.2.0.Final.jar!/ErraiApp.properties for configured types ...

      18:19:12.376 [pool-4-thread-1                                                  ] INFO                 org.jboss.errai.cdi.server.CDIExtensionPoints - all services registered successfully

      18:19:12.386 [main                                                             ] DEBUG                                     org.jboss.weld.Bootstrap - WELD-000100 Weld initialized. Validating beans

      18:19:12.624 [main                                                             ] INFO  org.jboss.errai.bus.server.service.bootstrap.OrderedBootstrap - starting errai bus ...

      18:19:12.625 [main                                                             ] INFO  org.jboss.errai.bus.server.service.bootstrap.DefaultComponents - using dispatcher implementation: org.jboss.errai.bus.server.SimpleDispatcher

      18:19:12.630 [main                                                             ] INFO  org.jboss.errai.bus.server.service.bootstrap.DefaultComponents - using session provider implementation: org.jboss.errai.bus.server.HttpSessionProvider

      18:19:12.644 [main                                                             ] INFO   org.jboss.errai.bus.server.service.bootstrap.LoadExtensions - searching for errai extensions ...

      18:19:12.653 [main                                                             ] DEBUG org.jboss.errai.bus.server.service.bootstrap.DiscoverServices - auto-discovery of services disabled.

      18:19:12.654 [main                                                             ] DEBUG org.jboss.errai.bus.server.service.bootstrap.BootstrapContext - running deferred bootstrap tasks ...

      18:19:12.654 [main                                                             ] INFO  org.jboss.errai.bus.server.service.bootstrap.OrderedBootstrap - errai bus started.

      Mar 23, 2013 1:19:12 AM com.sun.jersey.api.core.PackagesResourceConfig init

      INFO: Scanning for root resource and provider classes in the packages:

        com.igniteplay

        org.codehaus.jackson.jaxrs

      Mar 23, 2013 1:19:12 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses

      INFO: Root resource classes found:

        class com.igniteplay.backend.impl.DefaultRestApiResource

      Mar 23, 2013 1:19:12 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses

      INFO: Provider classes found:

        class org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider

        class org.codehaus.jackson.jaxrs.JsonParseExceptionMapper

        class org.codehaus.jackson.jaxrs.JacksonJsonProvider

        class com.igniteplay.backend.impl.MrBeanProvider

        class org.codehaus.jackson.jaxrs.JsonMappingExceptionMapper

      Mar 23, 2013 1:19:12 AM com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer initialize

      INFO: CDI support is enabled

      Mar 23, 2013 1:19:12 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate

      INFO: Initiating Jersey application, version 'Jersey: 1.17 01/17/2013 03:31 PM'

      Mar 23, 2013 1:19:13 AM org.apache.coyote.http11.Http11Protocol init

      INFO: Initializing Coyote HTTP/1.1 on http-9601

      Mar 23, 2013 1:19:13 AM org.apache.coyote.http11.Http11Protocol start

      INFO: Starting Coyote HTTP/1.1 on http-9601

      18:19:20.619 [pool-5-thread-1                                                  ] DEBUG              org.jboss.errai.bus.server.api.ServerMessageBus - [bus] buffer status [freebytes: 33554432 (100.0%) tail rng: 0; actv tails: 0]