1 2 Previous Next 16 Replies Latest reply on Feb 9, 2012 10:17 PM by Oleg Stepanov

    @Singleton @PostConstruct, multiple invocations

    Rich DiCroce Novice

      In our project, we have a class marked @Singleton. It implements a single interface, and all of our other code uses @Inject with that interface to obtain a reference to it. The class has a method marked @PostConstruct in it. Said method is getting invoked multiple times.

       

      I've searched high and low trying to figure out why, but I've found nothing. The closest I've come is some forum postings about no-interface singletons and how their no-arg constructors can be called multiple times, but my singleton implements an interface and doesn't have a no-arg constructor. I can definitely say that even though the post-construct is getting invoked several times, only one instance is actually hanging around, because the class also has several timers in it declared with @Schedule, and only one instance of the class ever invokes them. Also, other classes that use this class all appear to be using the same instance of it.

       

      This wouldn't really bother me, except for the fact that the post-construct does a couple time-consuming things, and doing those things several times seems to be making server startup take much longer than it needs to.

       

      Thoughts?

        • 1. Re: @Singleton @PostConstruct, multiple invocations
          Rich DiCroce Novice

          Writing my first post out gave me the idea that something must be influencing the number of post-construct calls.  It turns out that the post-construct is being called once for each method in the class marked with @Schedule, once for injection into each singleton marked with @Startup that uses the interface it implements, and, oddly enough, once for the @Startup on the class itself. When the @Schedule and @Startup annotations are removed, the post-construct method is only invoked once.

           

          EDIT: Got some things mixed up in my head. Actually, the post-construct is being called once for each method in the class marked @Schedule and once for the @Startup on itself. Injecting into other classes is not causing any additional invocations.

           

          Is this a bug or is this expected behavior?

          • 2. Re: @Singleton @PostConstruct, multiple invocations
            Riccardo Pasquini Novice

            googling around i've found the following

             

            http://www.adam-bien.com/roller/abien/entry/simplest_possible_ejb_3_16

             

            in that post, it is stated that "A timer doesn't have to be a singleton" but the provided example... is @Singleton! and it makes me confused...

             

            anyway, here http://stackoverflow.com/questions/2707733/eager-auto-loading-of-ejb-load-ejb-on-startup-on-jboss you can find a @Startup example that maybe can fix your @PostConstruct behavior, seems to be a nice try...

             

            bye

            • 3. Re: @Singleton @PostConstruct, multiple invocations
              jaikiran pai Master

              This looks like a bug. Which exact version of JBoss AS7 is this?

              • 4. Re: @Singleton @PostConstruct, multiple invocations
                Rich DiCroce Novice

                This is with version 7.0.2.Final.

                 

                I have more details now. Yesterday, I figured this is probably a bug and I could hack around it by introducing a separate class that's also a singleton and gets the target singleton injected into it, with timer methods on the new singleton that just call into the target singleton. That didn't work either: even though I removed the @Startup and @Schedule annotations from the target singleton, post-construct was still getting called multiple times. That was at the end of the day, so I just left it and figured I'd come back to it this morning.

                 

                Well this morning I had a new idea about the cause that seems to pan out. The singleton itself is marked @Startup and it gets injected into another singleton that is also @Startup. Removing the @Startup annotation from both fixes the problem. That is actually a viable workaround for me: the singleton with the timers gets instantiated anyway without @Startup and the other singleton doesn't need to be @Startup (though I would prefer it were).

                • 5. Re: @Singleton @PostConstruct, multiple invocations
                  iran zhou Newbie

                  I have same problem

                  my @Singleton Bean with @Startup

                  the @PostConstruct method run twice

                   

                  JBoss version 7.0.2.Final.

                   

                  can anyone help me ?

                   

                  first time:

                  GlobalInfoEJB.init() line: 47
                  NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
                  NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
                  DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
                  Method.invoke(Object, Object...) line: 597
                  ManagedReferenceLifecycleMethodInterceptor.processInvocation(InterceptorContext) line: 69
                  InterceptorContext.proceed() line: 287
                  WeavedInterceptor.processInvocation(InterceptorContext) line: 53
                  InterceptorContext.proceed() line: 287
                  ManagedReferenceFieldInjectionInterceptor.processInvocation(InterceptorContext) line: 65
                  InterceptorContext.proceed() line: 287
                  WeavedInterceptor.processInvocation(InterceptorContext) line: 53
                  InterceptorContext.proceed() line: 287
                  ManagedReferenceInterceptor.processInvocation(InterceptorContext) line: 53
                  InterceptorContext.proceed() line: 287
                  WeavedInterceptor.processInvocation(InterceptorContext) line: 53
                  InterceptorContext.proceed() line: 287
                  NamespaceContextInterceptor.processInvocation(InterceptorContext) line: 44
                  InterceptorContext.proceed() line: 287
                  SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed() line: 126
                  SingletonLifecycleCMTTxInterceptor(CMTTxInterceptor).invokeInOurTx(TransactionalInvocationContext, TransactionManager) line: 257
                  SingletonLifecycleCMTTxInterceptor(CMTTxInterceptor).requiresNew(TransactionalInvocationContext) line: 402
                  SingletonLifecycleCMTTxInterceptor.processInvocation(TransactionalInvocationContext) line: 57
                  SingletonLifecycleCMTTxInterceptor.processInvocation(InterceptorContext) line: 43
                  InterceptorContext.proceed() line: 287
                  SessionInvocationContextInterceptor.processInvocation(InterceptorContext) line: 71
                  InterceptorContext.proceed() line: 287
                  TCCLInterceptor.processInvocation(InterceptorContext) line: 45
                  InterceptorContext.proceed() line: 287
                  ChainedInterceptor.processInvocation(InterceptorContext) line: 61
                  SingletonComponent(BasicComponent).constructComponentInstance(ManagedReference) line: 152
                  SingletonComponent(BasicComponent).createInstance() line: 77
                  SingletonComponent.getComponentInstance() line: 125
                  SingletonComponent.start() line: 138
                  ComponentStartService.start(StartContext) line: 44
                  ServiceControllerImpl$StartTask.run() line: 1765
                  ServiceControllerImpl$ClearTCCLTask.run() line: 2291
                  ThreadPoolExecutor$Worker.runTask(Runnable) line: 886
                  ThreadPoolExecutor$Worker.run() line: 908 [local variables unavailable]
                  ServiceContainerImpl$ServiceThread(Thread).run() line: 662 [local variables unavailable]

                   

                  second time:(SysInfoEJB is a @Stateless bean)

                  GlobalInfoEJB.init() line: 47
                  NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
                  NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
                  DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
                  Method.invoke(Object, Object...) line: 597
                  ManagedReferenceLifecycleMethodInterceptor.processInvocation(InterceptorContext) line: 69
                  InterceptorContext.proceed() line: 287
                  WeavedInterceptor.processInvocation(InterceptorContext) line: 53
                  InterceptorContext.proceed() line: 287
                  ManagedReferenceFieldInjectionInterceptor.processInvocation(InterceptorContext) line: 65
                  InterceptorContext.proceed() line: 287
                  WeavedInterceptor.processInvocation(InterceptorContext) line: 53
                  InterceptorContext.proceed() line: 287
                  ManagedReferenceInterceptor.processInvocation(InterceptorContext) line: 53
                  InterceptorContext.proceed() line: 287
                  WeavedInterceptor.processInvocation(InterceptorContext) line: 53
                  InterceptorContext.proceed() line: 287
                  NamespaceContextInterceptor.processInvocation(InterceptorContext) line: 44
                  InterceptorContext.proceed() line: 287
                  SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed() line: 126
                  SingletonLifecycleCMTTxInterceptor(CMTTxInterceptor).invokeInOurTx(TransactionalInvocationContext, TransactionManager) line: 257
                  SingletonLifecycleCMTTxInterceptor(CMTTxInterceptor).requiresNew(TransactionalInvocationContext) line: 393
                  SingletonLifecycleCMTTxInterceptor.processInvocation(TransactionalInvocationContext) line: 57
                  SingletonLifecycleCMTTxInterceptor.processInvocation(InterceptorContext) line: 43
                  InterceptorContext.proceed() line: 287
                  SessionInvocationContextInterceptor.processInvocation(InterceptorContext) line: 71
                  InterceptorContext.proceed() line: 287
                  TCCLInterceptor.processInvocation(InterceptorContext) line: 45
                  InterceptorContext.proceed() line: 287
                  ChainedInterceptor.processInvocation(InterceptorContext) line: 61
                  SingletonComponent(BasicComponent).constructComponentInstance(ManagedReference) line: 152
                  SingletonComponent(BasicComponent).createInstance() line: 77
                  SingletonComponent.getComponentInstance() line: 125
                  SingletonComponentInstanceAssociationInterceptor.processInvocation(InterceptorContext) line: 48
                  InterceptorContext.proceed() line: 287
                  SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed() line: 126
                  CMTTxInterceptor(CMTTxInterceptor).invokeInCallerTx(TransactionalInvocationContext, Transaction) line: 233
                  CMTTxInterceptor(CMTTxInterceptor).required(TransactionalInvocationContext) line: 363
                  CMTTxInterceptor(CMTTxInterceptor).invoke(TransactionalInvocationContext) line: 219
                  CMTTxInterceptor.processInvocation(InterceptorContext) line: 35
                  InterceptorContext.proceed() line: 287
                  SessionInvocationContextInterceptor.processInvocation(InterceptorContext) line: 71
                  InterceptorContext.proceed() line: 287
                  ChainedInterceptor.processInvocation(InterceptorContext) line: 61
                  ViewDescription$1.processInvocation(InterceptorContext) line: 146
                  InterceptorContext.proceed() line: 287
                  ChainedInterceptor.processInvocation(InterceptorContext) line: 61
                  ProxyInvocationHandler.invoke(Object, Method, Object[]) line: 76
                  GlobalInfoLocal$$$view28.getStartupResources() line: not available
                  SysInfoEJB.loadWebStartupResources() line: 29
                  NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
                  NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
                  DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
                  Method.invoke(Object, Object...) line: 597
                  ManagedReferenceMethodInterceptor.processInvocation(InterceptorContext) line: 51
                  InterceptorContext.proceed() line: 287
                  WeavedInterceptor.processInvocation(InterceptorContext) line: 53
                  InterceptorContext.proceed() line: 287
                  SBInvocationInterceptor.processInvocation(InterceptorContext) line: 45
                  InterceptorContext.proceed() line: 287
                  NamespaceContextInterceptor.processInvocation(InterceptorContext) line: 44
                  InterceptorContext.proceed() line: 287
                  TCCLInterceptor.processInvocation(InterceptorContext) line: 45
                  InterceptorContext.proceed() line: 287
                  InitialInterceptor.processInvocation(InterceptorContext) line: 21
                  InterceptorContext.proceed() line: 287
                  ChainedInterceptor.processInvocation(InterceptorContext) line: 61
                  ViewDescription$ComponentDispatcherInterceptor.processInvocation(InterceptorContext) line: 202
                  InterceptorContext.proceed() line: 287
                  PooledInstanceInterceptor.processInvocation(InterceptorContext) line: 44
                  InterceptorContext.proceed() line: 287
                  SessionInvocationContextInterceptor$CustomSessionInvocationContext.proceed() line: 126
                  CMTTxInterceptor(CMTTxInterceptor).invokeInOurTx(TransactionalInvocationContext, TransactionManager) line: 257
                  CMTTxInterceptor(CMTTxInterceptor).required(TransactionalInvocationContext) line: 359
                  CMTTxInterceptor(CMTTxInterceptor).invoke(TransactionalInvocationContext) line: 219
                  CMTTxInterceptor.processInvocation(InterceptorContext) line: 35
                  InterceptorContext.proceed() line: 287
                  SessionInvocationContextInterceptor.processInvocation(InterceptorContext) line: 71
                  InterceptorContext.proceed() line: 287
                  ChainedInterceptor.processInvocation(InterceptorContext) line: 61
                  ViewDescription$1.processInvocation(InterceptorContext) line: 146
                  InterceptorContext.proceed() line: 287
                  ChainedInterceptor.processInvocation(InterceptorContext) line: 61
                  ProxyInvocationHandler.invoke(Object, Method, Object[]) line: 76
                  SysInfoRemote$$$view34.loadWebStartupResources() line: not available
                  StartupWebBean.getResource() line: 45
                  MacWebGlobal.initStartupResources() line: 33
                  MacWebGlobal.initGlobalVars() line: 29
                  ContextListener.contextInitialized(ServletContextEvent) line: 13
                  StandardContext.contextListenerStart() line: 3368
                  StandardContext.start() line: 3821
                  WebDeploymentService.start(StartContext) line: 70
                  ServiceControllerImpl$StartTask.run() line: 1765
                  ServiceControllerImpl$ClearTCCLTask.run() line: 2291
                  ThreadPoolExecutor$Worker.runTask(Runnable) line: 886
                  ThreadPoolExecutor$Worker.run() line: 908
                  ServiceContainerImpl$ServiceThread(Thread).run() line: 662
                  • 6. Re: @Singleton @PostConstruct, multiple invocations
                    Daniel Cullender Newbie

                    I had a similar problem, but mine was caused by integrating Spring with the Singleton - the @PostConstruct was invoked both by the jboss and the spring container since it is a javax annotation supported by both containers

                    • 7. Re: @Singleton @PostConstruct, multiple invocations
                      jaikiran pai Master

                      Can you attach an application which reproduces this? Also, see if you can reproduce this against our nightly builds http://community.jboss.org/thread/167590

                      • 8. Re: @Singleton @PostConstruct, multiple invocations
                        iran zhou Newbie

                        Dear jaikiran,

                         

                        i cant upload the real code,but i startup the test code as below.

                         

                        i use eclipse 3.7

                        jboss-as-7.1.0.Alpha2-SNAPSHOT(download from http://community.jboss.org/thread/167590 )

                         

                         

                         

                        after test, i found my singletonEJB'@PostConstruct method run twice

                         

                        11:23:39,438 INFO  [stdout] (MSC service thread 1-7) singletonEJB :@PostConstruct begin 

                         

                        11:23:40,168 INFO  [stdout] (MSC service thread 1-8) TestStartup : begin

                         

                        11:23:41,574 INFO  [stdout] (MSC service thread 1-7) singletonEJB :@PostConstruct end

                         

                        11:23:41,575 INFO  [stdout] (MSC service thread 1-8) singletonEJB :@PostConstruct begin

                         

                        11:23:43,710 INFO  [stdout] (MSC service thread 1-8) singletonEJB :@PostConstruct end

                         

                        11:23:43,712 INFO  [stdout] (MSC service thread 1-8) TestStartup : end myInt is 1234


                        thxxxxxxxxxxxxx

                         

                         

                        ---------------------------------------------------------------------------------------------------------------------------------------------

                        the code as below:

                        -------------------------------------------------

                        1.0 java Project for interface only

                        Build Path: only JRE1.6-26

                         

                        testLocal.java:

                         

                        package testif;

                         

                        public interface testLocal {

                         

                            public int getTest();

                        }

                        -----------------------------------------------------------------

                        2.0 jsf Project

                        Build Path: Jboss 7.0 runtime + interface + jsf-api.jar + JRE1.6-26

                         

                        web.xml:

                        <?xml version="1.0" encoding="UTF-8"?>

                        <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                            xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

                            xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

                            version="3.0">

                            <display-name>TestEF</display-name>

                            <welcome-file-list>

                                <welcome-file>index.jsp</welcome-file>

                            </welcome-file-list>

                           

                            <servlet>

                                <servlet-name>Faces Servlet</servlet-name>

                                <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

                                <load-on-startup>1</load-on-startup>

                            </servlet>

                            <servlet-mapping>

                                <servlet-name>Faces Servlet</servlet-name>

                                <url-pattern>*.faces</url-pattern>

                            </servlet-mapping>

                         

                            <context-param>

                                <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>

                                <param-name>javax.faces.STATE_SAVING_METHOD</param-name>

                                <param-value>server</param-value>

                            </context-param>

                            <context-param>

                                <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>

                                <param-value>resources.application</param-value>

                            </context-param>

                            <listener>

                                <listener-class>com.sun.faces.config.ConfigureListener</listener-class>

                            </listener>

                            <listener>

                                <listener-class>jsf.TestContextListener</listener-class>

                            </listener>

                            <context-param>

                                <param-name>javax.faces.PROJECT_STAGE</param-name>

                                <param-value>Depolyment</param-value>

                            </context-param>

                            <context-param>

                                <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>

                                <param-value>true</param-value>

                            </context-param>

                         

                        </web-app>

                         

                        TestContextListener.java

                         

                        package jsf;

                         

                        import javax.servlet.ServletContextEvent;

                        import javax.servlet.ServletContextListener;

                         

                        public class TestContextListener implements ServletContextListener {

                         

                           

                            public void contextDestroyed(ServletContextEvent arg0) {

                            }

                         

                            public void contextInitialized(ServletContextEvent arg0) {

                                TestGlobal.initVars();

                            }

                        }

                         

                        TestGlobal.java

                        package jsf;

                         

                        public class TestGlobal {

                         

                            public static void initVars() {

                                TestStartup.runMyTest();

                            }

                         

                        }

                        TestStartup.java

                        package jsf;

                         

                        import javax.ejb.EJB;

                        import javax.faces.bean.ApplicationScoped;

                        import javax.faces.bean.ManagedBean;

                        import testif.testLocal;

                         

                        @ManagedBean(name = "startup", eager = true)

                        @ApplicationScoped

                        public class TestStartup {

                           

                            @EJB

                            private testLocal test;

                         

                            private static TestStartup thisInstance;

                         

                            public TestStartup() {

                                setStartupInstance(this);

                            }

                         

                            public static TestStartup getStartupInstance() {

                                return thisInstance;

                            }

                         

                            public static void setStartupInstance(TestStartup thisInstance) {

                                TestStartup.thisInstance = thisInstance;

                            }

                         

                            public static boolean runMyTest() {

                                System.out.println("TestStartup : begin");

                                int myInt = getStartupInstance().test.getTest();

                                System.out.println("TestStartup : end myInt is " + myInt);

                                return false;

                               

                            }

                         

                        }

                        ----------------------------------------------------------------------------

                        3.0 EJB Project

                        Build Path: Jboss 7.0 runtime + interface  + JRE1.6-26

                         

                        StatelessEJB.java

                        package ejb;

                         

                        import javax.ejb.EJB;

                        import javax.ejb.Local;

                        import javax.ejb.Stateless;

                         

                        import testif.testLocal;

                         

                        @Stateless

                        @Local(testLocal.class)

                        public class StatelessEJB implements testLocal {

                         

                            @EJB

                            singletonEJB myTest;

                           

                            @Override

                            public int getTest() {

                                return myTest.test();

                               

                            }

                         

                        }

                        singletonEJB.java

                        package ejb;

                         

                        import javax.annotation.PostConstruct;

                        import javax.ejb.Singleton;

                        import javax.ejb.Startup;

                         

                        @Singleton

                        @Startup

                        public class singletonEJB {

                         

                            @PostConstruct

                            public void init(){

                                System.out.println("singletonEJB :@PostConstruct begin ");

                                try {

                                    //init need some time

                                    Thread.sleep(2135);

                                } catch (InterruptedException e) {

                                    e.printStackTrace();

                                }

                                System.out.println("singletonEJB :@PostConstruct end ");

                            }

                           

                            public int test(){

                                return 1234;

                            }

                           

                        }

                        ------------------------------

                        4.0 EAR

                        ejb + jsf

                        -----------------------------------------------------------------------------------------------------------------------------------------------------

                        and when i startup jboss with ther ear

                        the log is below:

                         

                         

                        11:42:50,700 信息[org.jboss.modules] JBoss Modules version 1.1.0.CR2

                        11:42:50,919 INFO  [org.jboss.msc] JBoss MSC version 1.0.1.GA

                        11:42:50,963 INFO  [org.jboss.as] JBoss AS 7.1.0.Alpha2-SNAPSHOT "Ahoy!" starting

                        11:42:51,677 WARN  [org.jboss.as] No security realm defined for native management service, all access will be unrestricted.

                        11:42:51,681 INFO  [org.xnio] XNIO Version 3.0.0.CR1

                        11:42:51,682 INFO  [org.jboss.as] creating http management service using network interface (management) port (9990)

                        11:42:51,730 WARN  [org.jboss.as] No security realm defined for http management service, all access will be unrestricted.

                        11:42:51,743 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.0.CR1

                        11:42:51,752 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.0.CR2

                        11:42:51,753 INFO  [org.jboss.as.logging] JBAS011501: Removing bootstrap log handlers

                        11:42:51,756 INFO  [org.jboss.as.ee] (ServerService Thread Pool -- 31) Activating EE subsystem

                        11:42:51,759 INFO  [org.jboss.as.clustering] (ServerService Thread Pool -- 34) JBAS010300: Activating Infinispan subsystem.

                        11:42:51,777 INFO  [org.jboss.as.cmp.subsystem.CmpSubsystemAdd] (ServerService Thread Pool -- 33) Activating EJB CMP Subsystem

                        11:42:51,780 INFO  [org.jboss.as.jacorb] (ServerService Thread Pool -- 35) Activating JacORB Subsystem

                        11:42:51,812 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 54) Activating WebServices Extension

                        11:42:51,815 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 50) Activating Security Subsystem

                        11:42:51,817 WARN  [org.jboss.as] (ServerService Thread Pool -- 47) No security realm defined for native management service, all access will be unrestricted.

                        11:42:51,827 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 44) JBAS011800: Activating Naming Subsystem

                        11:42:51,841 INFO  [org.jboss.as.security] (MSC service thread 1-7) Picketbox version=4.0.6.Beta1

                        11:42:51,832 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 45) JBAS011910: Activating OSGi Subsystem

                        11:42:51,891 INFO  [org.jboss.as.naming] (MSC service thread 1-2) JBAS011802: Starting Naming Service

                        11:42:51,904 INFO  [org.jboss.as.connector] (MSC service thread 1-1) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.5.Final)

                        11:42:51,905 INFO  [org.jboss.as.mail.extension.MailSessionAdd] (MSC service thread 1-6) Bound mail session [java:jboss/mail/Default]

                        11:42:51,911 INFO  [org.jboss.as.jmx.JMXConnectorService] (MSC service thread 1-6) Starting remote JMX connector

                        11:42:51,920 INFO  [org.jboss.as.remoting] (MSC service thread 1-5) Listening on /127.0.0.1:9999

                        11:42:51,967 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-8) JBoss Web Services - Stack CXF Server 4.0.0.Beta6

                        11:42:51,968 INFO  [org.jboss.as.remoting] (MSC service thread 1-5) Listening on /127.0.0.1:4447

                        11:42:51,985 WARN  [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011600: AIO wasn't located on this platform, it will fall back to using pure Java NIO. If your platform is Linux, install LibAIO to enable the AIO journal

                        11:42:52,140 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 29) JBAS010403: Deploying JDBC-compliant driver class com.microsoft.sqlserver.jdbc.SQLServerDriver (version 3.0)

                        11:42:52,504 INFO  [org.apache.catalina.core.AprLifecycleListener] (MSC service thread 1-5) The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Java\32\jdk1.6.0_26\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Java\32\jdk1.6.0_26\jre\bin;D:/eclipse/jre/bin/client;D:/eclipse/jre/bin;D:/eclipse/jre/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\apache-ant-1.7.0\bin\;C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\;C:\Java\jre6\bin;;C:\Program Files (x86)\SinoVoice\jTTS 5.0 Desktop\Bin;D:\eclipse;;.

                        11:42:52,537 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-5) Starting Coyote HTTP/1.1 on http-127.0.0.1-127.0.0.1-8080

                        11:42:52,528 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-6) JBAS015012: Started FileSystemDeploymentService for directory D:\IDE_JBOSS\jboss-7.0.x\jboss-as-7.1.0.Alpha2-SNAPSHOT\standalone\deployments

                        11:42:52,583 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found test_ear.ear in deployment directory. To trigger deployment create a file called test_ear.ear.dodeploy

                        11:42:52,614 WARN  [jacorb.codeset] (MSC service thread 1-4) Warning - unknown codeset (GBK) - defaulting to ISO-8859-1

                        11:42:52,640 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data source [java:jboss/datasources/sqlserverDS]

                        11:42:52,643 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-1) JBAS010406: Registered connection factory java:/JmsXA

                        11:42:52,649 INFO  [org.hornetq.ra.HornetQResourceAdapter] (MSC service thread 1-1) HornetQ resource adaptor started

                        11:42:52,649 INFO  [org.jboss.as.connector.services.ResourceAdapterActivatorService$ResourceAdapterActivator] (MSC service thread 1-1) IJ020002: Deployed: file://RaActivatorhornetq-ra

                        11:42:52,653 INFO  [org.jboss.as.deployment.connector] (MSC service thread 1-5) JBAS010401: Bound JCA ConnectionFactory [java:/JmsXA]

                        11:42:52,656 INFO  [org.jboss.as.jacorb] (MSC service thread 1-4) CORBA ORB Service Started

                        11:42:52,698 INFO  [org.apache.juddi.registry.RegistryServlet] (MSC service thread 1-8) Loading jUDDI configuration.

                        11:42:52,701 INFO  [org.apache.juddi.registry.RegistryServlet] (MSC service thread 1-8) Resources loaded from: /WEB-INF/juddi.properties

                        11:42:52,701 INFO  [org.apache.juddi.registry.RegistryServlet] (MSC service thread 1-8) Initializing jUDDI components.

                        11:42:52,750 信息[org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=D:\IDE_JBOSS\jboss-7.0.x\jboss-as-7.1.0.Alpha2-SNAPSHOT\standalone\data\messagingjournal,bindingsDirectory=D:\IDE_JBOSS\jboss-7.0.x\jboss-as-7.1.0.Alpha2-SNAPSHOT\standalone\data\messagingbindings,largeMessagesDirectory=D:\IDE_JBOSS\jboss-7.0.x\jboss-as-7.1.0.Alpha2-SNAPSHOT\standalone\data\messaginglargemessages,pagingDirectory=D:\IDE_JBOSS\jboss-7.0.x\jboss-as-7.1.0.Alpha2-SNAPSHOT\standalone\data\messagingpaging)

                        11:42:52,757 INFO  [org.jboss.as.jacorb] (MSC service thread 1-4) CORBA Naming Service Started

                        11:42:52,765 警告[org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) Security risk! It has been detected that the cluster admin user and password have not been changed from the installation default. Please see the HornetQ user guide, cluster chapter, for instructions on how to do this.

                        11:42:52,856 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-3) Started Netty Acceptor version 3.2.3.Final-r${buildNumber} 127.0.0.1:5445 for CORE protocol

                        11:42:52,858 INFO  [org.hornetq.core.remoting.impl.netty.NettyAcceptor] (MSC service thread 1-3) Started Netty Acceptor version 3.2.3.Final-r${buildNumber} 127.0.0.1:5455 for CORE protocol

                        11:42:52,859 信息[org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) Server is now live
                        11:42:52,859 信息[org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-3) HornetQ Server version 2.2.7.Final (HQ_2_2_7_FINAL_AS7, 121) [1185ee8b-0b4e-11e1-b80f-485b39d52c39] started
                        11:42:52,860 信息[org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-6) trying to deploy queue jms.queue.testQueue

                        11:42:52,910 INFO  [org.jboss.as.messaging] (MSC service thread 1-6) JBAS011601: Bound messaging object to jndi name java:/queue/test

                        11:42:52,920 INFO  [org.jboss.as.messaging] (MSC service thread 1-2) JBAS011601: Bound messaging object to jndi name java:/RemoteConnectionFactory

                        11:42:52,920 INFO  [org.jboss.as.messaging] (MSC service thread 1-3) JBAS011601: Bound messaging object to jndi name java:/ConnectionFactory

                        11:42:52,921 信息[org.hornetq.core.server.impl.HornetQServerImpl] (MSC service thread 1-1) trying to deploy queue jms.topic.testTopic

                        11:42:52,933 INFO  [org.jboss.as.messaging] (MSC service thread 1-1) JBAS011601: Bound messaging object to jndi name java:/topic/test

                        11:42:53,148 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report%nJBAS014775:New missing/unsatisfied dependencies:%n  service jboss.data-source.java:jboss/datasources/ExampleDS (missing) dependents: [service jboss.jaxr.as.bootstrap]

                         

                        11:42:53,153 ERROR [org.jboss.as] (Controller Boot Thread) JBoss AS 7.1.0.Alpha2-SNAPSHOT "Ahoy!" started (with errors) in 2606ms - Started 147 of 211 services (1 services failed or missing dependencies, 60 services are passive or on-demand)

                        11:42:53,163 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) Starting deployment of "test_ear.ear"

                        11:42:53,192 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) Starting deployment of "test_jsf.war"

                        11:42:53,192 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) Starting deployment of "test_ejb.jar"

                        11:42:53,421 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-8) JNDI bindings for session bean named singletonEJB in deployment unit subdeployment "test_ejb.jar" of deployment "test_ear.ear" are as follows:

                         

                        java:global/test_ear/test_ejb/singletonEJB!ejb.singletonEJB
                        java:app/test_ejb/singletonEJB!ejb.singletonEJB
                        java:module/singletonEJB!ejb.singletonEJB
                        java:global/test_ear/test_ejb/singletonEJB
                        java:app/test_ejb/singletonEJB
                        java:module/singletonEJB

                         

                        11:42:53,421 INFO  [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-8) JNDI bindings for session bean named StatelessEJB in deployment unit subdeployment "test_ejb.jar" of deployment "test_ear.ear" are as follows:

                         

                        java:global/test_ear/test_ejb/StatelessEJB!testif.testLocal
                        java:app/test_ejb/StatelessEJB!testif.testLocal
                        java:module/StatelessEJB!testif.testLocal
                        java:global/test_ear/test_ejb/StatelessEJB
                        java:app/test_ejb/StatelessEJB
                        java:module/StatelessEJB

                         

                        11:42:53,554 INFO  [org.apache.catalina.core.StandardContext] (MSC service thread 1-3) The listener "com.sun.faces.config.ConfigureListener" is already configured for this context. The duplicate definition has been ignored.

                        11:42:53,571 INFO  [stdout] (MSC service thread 1-6) singletonEJB :@PostConstruct begin

                         

                        11:42:53,599 信息[javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-3) 初始化上下文 '/test_jsf' 的 Mojarra 2.1.3 (SNAPSHOT 20110825)
                        11:42:54,212 信息[javax.enterprise.resource.webcontainer.jsf.application] (MSC service thread 1-3) Unable to discern ProjectStage for value Depolyment.

                        11:42:54,270 INFO  [org.hibernate.validator.util.Version] (MSC service thread 1-3) Hibernate Validator 4.2.0.Final

                        11:42:54,407 INFO  [stdout] (MSC service thread 1-3) TestStartup : begin

                         

                        11:42:55,706 INFO  [stdout] (MSC service thread 1-6) singletonEJB :@PostConstruct end

                         

                        11:42:55,707 INFO  [stdout] (MSC service thread 1-3) singletonEJB :@PostConstruct begin

                         

                        11:42:57,842 INFO  [stdout] (MSC service thread 1-3) singletonEJB :@PostConstruct end

                         

                        11:42:57,843 INFO  [stdout] (MSC service thread 1-3) TestStartup : end myInt is 1234

                         

                        11:42:57,849 INFO  [org.jboss.web] (MSC service thread 1-3) registering web context: /test_jsf

                        11:42:57,893 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 2) Deployed "test_ear.ear"

                         

                         

                         

                         

                        • 9. Re: @Singleton @PostConstruct, multiple invocations
                          iran zhou Newbie

                          Anyone follow up? or Need any other info..?

                          • 10. Re: @Singleton @PostConstruct, multiple invocations
                            jaikiran pai Master

                            Sorry I haven't been able to look into this. What would really help is if you create a source and binary jars of that test code and attach it to this thread (you can click on the "Use advanced editor" link on top right corner of the editor which allows you to attach files to posts).

                            • 11. Re: @Singleton @PostConstruct, multiple invocations
                              iran zhou Newbie

                              Testing source code is as attached.  Thanks a lot.

                              • 12. Re: @Singleton @PostConstruct, multiple invocations
                                daniel_spasojevic Newbie

                                Hi,

                                 

                                We are seeing the same behaviour in 7.1.0.Beta1.

                                 

                                Does anyone know if there is there an issue open to track this?

                                 

                                Thanks,

                                -Dan

                                1 2 Previous Next