4 Replies Latest reply on Mar 25, 2011 5:23 AM by lvdberg

    JBoss Seam EntityManager

    richfaces_ahop

      Hi all,


        I have figured out how to persist and retrieve data to the HyperSonic DB via the click of a command button.  BUT, I have the need to store data in the HyperSonic DB upon startup of the JBoss AS (without clicking a button).  Is this possible?  Essentially, I retrieve data via a socket and need to persist it in the HyperSonic DB upon JBoss AS startup.  Any assistance would be appreciated.

        • 1. Re: JBoss Seam EntityManager
          antibrumm.mfrey0.bluewin.ch

          What about an application scoped bean with the @startup annotation?

          • 2. Re: JBoss Seam EntityManager
            richfaces_ahop
            So, the Session Bean that I am using, use the @Startup annotation in conjunction with the EntityManager?  Everytime I tried to use the EntityManager previously, I kept getting NullPointerException, unless I was clicking a button (which would make use of an action listener).  I am not familiar with the @startup.  Would the code look like this?


            @In EntityManager em; //a Seam-managed persistence context

            @Startup
            public class Test() {
            public void beginClaimWizard() {
                claim = em.find(Claim.class, claimId);
            }

            }
            • 3. Re: JBoss Seam EntityManager
              richfaces_ahop
              I really am trying to figure out "How do I make Seam call an action method at JBoss AS startup time?
              • 4. Re: JBoss Seam EntityManager
                lvdberg

                Hi,



                A seam application is usually the last in the chain to start up, so you're NOT able to start up a Seam bean at Jboss start up, You can create a simple JBoss service which does that for you. However be aware that the basic JBoss services (such as persistency) must be active first, so at start-up time really means after some N-seconds.


                Leo