Announcement Announcement Module
Collapse
No announcement yet.
ContextSingletonBeanFactoryLocator error during initialisation in EJB Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ContextSingletonBeanFactoryLocator error during initialisation in EJB

    Hello,

    I'm actually trying to use the ContextSingletonBeanFactoryLocator BeanFactory in my EJB's, but I have the following exception:
    Code:
    [1/30/07 15:06:33:833 GMT+01:00] 00000039 SystemOut     O 15:06:33,833 ERROR [ParameterTableServiceSession]  NO ID-setSessionContext for Singletion bean factory usage.
    
    [1/30/07 15:06:33:834 GMT+01:00] 00000039 ExceptionUtil E   CNTR0019E: EJB threw an unexpected (non-declared) exception during invocation of method "remove". Exception data: com.ibm.ejs.container.CreateFailureException: ; nested exception is: 
    
    	java.lang.reflect.InvocationTargetException
    
    	at com.ibm.ejs.container.StatelessBeanO.<init>(StatelessBeanO.java:172)
    
    	at com.ibm.ejs.container.BMStatelessBeanOFactory.create(BMStatelessBeanOFactory.java:40)
    
    	at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:928)
    
    	at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1031)
    
    	at com.ibm.ejs.container.activator.UncachedActivationStrategy.atActivate(UncachedActivationStrategy.java:84)
    
    	at com.ibm.ejs.container.activator.Activator.activateBean(Activator.java:597)
    
    	at com.ibm.ejs.container.EJSContainer.preInvokeActivate(EJSContainer.java:3435)
    
    	at com.ibm.ejs.container.EJSContainer.preInvoke(EJSContainer.java:2839)
    
    	at com.ibm.ejs.container.EJSContainer.removeBean(EJSContainer.java:2375)
    
    	at com.ibm.ejs.container.EJSWrapper.remove(EJSWrapper.java:196)
    
    	at com.cwsoft.technicalframework.parametertable.service.interfaces._EJSRemoteStatelessParameterTableService_4ba1d0d8_Tie.remove(_EJSRemoteStatelessParameterTableService_4ba1d0d8_Tie.java:175)
    
    	at com.cwsoft.technicalframework.parametertable.service.interfaces._EJSRemoteStatelessParameterTableService_4ba1d0d8_Tie._invoke(_EJSRemoteStatelessParameterTableService_4ba1d0d8_Tie.java:90)
    
    	at com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:613)
    
    	at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:466)
    
    	at com.ibm.rmi.iiop.ORB.process(ORB.java:503)
    
    	at com.ibm.CORBA.iiop.ORB.process(ORB.java:1552)
    
    	at com.ibm.rmi.iiop.Connection.respondTo(Connection.java:2673)
    
    	at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2551)
    
    	at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:62)
    
    	at com.ibm.ejs.oa.pool.PooledThread.run(ThreadPool.java:95)
    
    	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1469)
    
    Caused by: java.lang.reflect.InvocationTargetException
    
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    
    	at java.lang.reflect.Method.invoke(Method.java:615)
    
    	at com.ibm.ejs.container.StatelessBeanO.<init>(StatelessBeanO.java:165)
    
    	... 20 more
    
    Caused by: java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
    
    	at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:118)
    
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:642)
    
    	at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.useBeanFactory(SingletonBeanFactoryLocator.java:393)
    
    	at org.springframework.ejb.support.AbstractEnterpriseBean.loadBeanFactory(AbstractEnterpriseBean.java:117)
    
    	at org.springframework.ejb.support.AbstractStatelessSessionBean.ejbCreate(AbstractStatelessSessionBean.java:64)
    
    	at com.cwsoft.technicalframework.parametertable.service.ejb.ParameterTableServiceBean.ejbCreate(ParameterTableServiceBean.java:59)
    
    	... 25 more
    I follow the instructions found in the doc, as:
    Code:
    public void setSessionContext(javax.ejb.SessionContext ctx) 
       {
    	   super.setSessionContext(ctx);
    	   CWLogger.error(this, "setSessionContext for Singletion bean factory usage.");
    	   this.setBeanFactoryLocatorKey("technicalframeworkBeanFactory");
    	   this.setBeanFactoryLocator(ContextSingletonBeanFactoryLocator.getInstance());
       }
    beanRefContext.xml file
    Code:
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    	<bean id="technicalframeworkBeanFactory" class="org.springframework.context.support.ClassPathXmlApplicationContext">
    		<constructor-arg value="applicationContext.xml" />
    	</bean>
    </beans>
    But I always have this error.
    I'm running under Spring-2.0.jar.

    Does anyone can help me ?

    Thanks in advance...

  • #2
    I would locate the code you have in your setSessionContext method to the constructor of the EJB. the setSessionContext is called after that (and after the ejbCreate) if I'm not mistaken.

    In the ejbCreate method in the AbstractStatelessSessionBean there is stuff done with the BeanFactory if that one isn't present.

    Comment


    • #3
      Thanks a lot for your reply.
      But why do I have this error while I read in every doc that this code must be put in the setSessionContext method ? Is this a bug of Spring-2.0 ?

      For info, I'm running under WAS 6.1.0.3.

      Thanks a lot for your help !

      Comment


      • #4
        Originally posted by mdeinum View Post
        I would locate the code you have in your setSessionContext method to the constructor of the EJB.
        No I guess that is correct. It is stated like that in the reference manual as well.

        From the stacktrace I wonder why a call to remove() causes a bean creation. That appears strange to me.

        Comment


        • #5
          Checking some documentation it is even clear that the setSessionContext is called before the create method.

          But I have to agree with Andreas it is strange that a remove results in a create. What is even stranger why is the setSessionContext being bypassed while creating the ejb?!

          Comment


          • #6
            Indeed, I added some log and the method setSessionContext is really invoked before the method ejbCreate.

            I can't explain also the fact that the method remove has been invoked for the EJB.
            Any help would be great...

            Thanks a lot for your response !

            Comment


            • #7
              Can you post your ejb-jar.xml please (at least the section describing the bean in question). Maybe that could provide a clue.

              Regards,
              Andreas

              Comment


              • #8
                Here it is
                Code:
                <?xml version="1.0" encoding="UTF-8"?>
                
                <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
                
                <ejb-jar >
                
                   <description><![CDATA[No Description.]]></description>
                   <display-name>Generated by XDoclet</display-name>
                   <enterprise-beans>
                      <!-- Session Beans -->
                      <session >
                         <description><![CDATA[Generated EJB 2.x SLSB for WordingOfPromptService]]></description>
                         <display-name>WordingOfPromptService (SLSB)</display-name>
                         <ejb-name>WordingOfPromptService</ejb-name>
                         <home>com.cwsoft.technicalframework.prompt.service.interfaces.WordingOfPromptServiceRemoteHome</home>
                         <remote>com.cwsoft.technicalframework.prompt.service.interfaces.WordingOfPromptServiceRemote</remote>
                         <local-home>com.cwsoft.technicalframework.prompt.service.interfaces.WordingOfPromptServiceLocalHome</local-home>
                         <local>com.cwsoft.technicalframework.prompt.service.interfaces.WordingOfPromptServiceLocal</local>
                         <ejb-class>com.cwsoft.technicalframework.prompt.service.ejb.WordingOfPromptServiceSession</ejb-class>
                         <session-type>Stateless</session-type>
                         <transaction-type>Bean</transaction-type>
                         <env-entry>
                            <env-entry-name>ejb/BeanFactoryPath</env-entry-name>
                            <env-entry-type>java.lang.String</env-entry-type>
                            <env-entry-value><![CDATA[applicationContext.xml]]></env-entry-value>
                         </env-entry>
                      </session>
                      <session >
                         <description><![CDATA[Generated EJB 2.x SLSB for ErrorMessageService]]></description>
                         <display-name>ErrorMessageService (SLSB)</display-name>
                         <ejb-name>ErrorMessageService</ejb-name>
                         <home>com.cwsoft.technicalframework.errormessage.service.interfaces.ErrorMessageServiceRemoteHome</home>
                         <remote>com.cwsoft.technicalframework.errormessage.service.interfaces.ErrorMessageServiceRemote</remote>
                         <local-home>com.cwsoft.technicalframework.errormessage.service.interfaces.ErrorMessageServiceLocalHome</local-home>
                         <local>com.cwsoft.technicalframework.errormessage.service.interfaces.ErrorMessageServiceLocal</local>
                         <ejb-class>com.cwsoft.technicalframework.errormessage.service.ejb.ErrorMessageServiceSession</ejb-class>
                         <session-type>Stateless</session-type>
                         <transaction-type>Bean</transaction-type>
                         <env-entry>
                            <env-entry-name>ejb/BeanFactoryPath</env-entry-name>
                            <env-entry-type>java.lang.String</env-entry-type>
                            <env-entry-value><![CDATA[applicationContext.xml]]></env-entry-value>
                         </env-entry>
                      </session>
                
                     <!--
                       To add session beans that you have deployment descriptor info for, add
                       a file to your XDoclet merge directory called session-beans.xml that contains
                       the <session></session> markup for those beans.
                     -->
                
                      <!-- Entity Beans -->
                     <!--
                       To add entity beans that you have deployment descriptor info for, add
                       a file to your XDoclet merge directory called entity-beans.xml that contains
                       the <entity></entity> markup for those beans.
                     -->
                
                      <!-- Message Driven Beans -->
                     <!--
                       To add message driven beans that you have deployment descriptor info for, add
                       a file to your XDoclet merge directory called message-driven-beans.xml that contains
                       the <message-driven></message-driven> markup for those beans.
                     -->
                
                   </enterprise-beans>
                
                   <!-- Relationships -->
                
                   <!-- Assembly Descriptor -->
                     <!--
                       To specify your own assembly descriptor info here, add a file to your
                       XDoclet merge directory called assembly-descriptor.xml that contains
                       the <assembly-descriptor></assembly-descriptor> markup.
                     -->
                
                   <assembly-descriptor >
                     <!--
                       To specify additional security-role elements, add a file in the merge
                       directory called ejb-security-roles.xml that contains them.
                     -->
                
                   <!-- method permissions -->
                     <!--
                       To specify additional method-permission elements, add a file in the merge
                       directory called ejb-method-permissions.ent that contains them.
                     -->
                
                   <!-- transactions -->
                     <!--
                       To specify additional container-transaction elements, add a file in the merge
                       directory called ejb-container-transactions.ent that contains them.
                     -->
                
                   <!-- finder transactions -->
                
                   <!-- message destinations -->
                     <!--
                       To specify additional message-destination elements, add a file in the merge
                       directory called ejb-message-destinations.ent that contains them.
                     -->
                
                   <!-- exclude list -->
                     <!--
                       To specify an exclude-list element, add a file in the merge directory
                       called ejb-exclude-list.xml that contains it.
                     -->
                   </assembly-descriptor>
                
                </ejb-jar>

                Comment


                • #9
                  That seems to be ok so far. Please turn on debug logging to see what happens there. Maybe it can be seen there what happens to the application context.

                  Regards,
                  Andreas

                  Comment


                  • #10
                    Originally posted by Andreas Senft View Post
                    That seems to be ok so far. Please turn on debug logging to see what happens there. Maybe it can be seen there what happens to the application context.

                    Regards,
                    Andreas

                    I have a similar ejb-jar.xml problem:

                    the result is that two application contexts are created.(at least in my case)

                    2007-02-13 18:54:28,604 DEBUG jndi.JndiLocatorSupport - Located object with JNDI name [java:comp/env/ejb/BeanFactoryPath]
                    2007-02-13 18:54:28,604 DEBUG jndi.JndiLocatorSupport - Located object with JNDI name [java:comp/env/ejb/BeanFactoryPath]
                    2007-02-13 18:54:28,604 DEBUG access.ContextJndiBeanFactoryLocator - Bean factory path from JNDI environment variable [java:comp/env/ejb/BeanFactoryPath] is: applicationContext-ejb.xml
                    2007-02-13 18:54:28,604 DEBUG access.ContextJndiBeanFactoryLocator - Bean factory path from JNDI environment variable [java:comp/env/ejb/BeanFactoryPath] is: applicationContext-ejb.xml

                    Comment


                    • #11
                      Do not override ejbCreate()

                      Hello,

                      have you overriden ejbCreate() ?

                      If you use an ide-wizard to create an ejb, it probably creates empty ejb lifecycle methods.

                      The implementation of AbstractStatelessSessionBean.ejbCreate() is:
                      Code:
                      public void ejbCreate() throws CreateException {
                          loadBeanFactory();
                          onEjbCreate();
                      }
                      if you override it, loadbeanFactory won't be called

                      -Patrick

                      Comment


                      • #12
                        Originally posted by gavieritei View Post
                        I have a similar ejb-jar.xml problem:

                        the result is that two application contexts are created.(at least in my case)
                        Well, it might be that just two EJBs got instantiated. Each of them has its own application context.

                        Another explanation for the duplicates might be that logging is misconfigured (in that case, all lines should be doubled).

                        Regards,
                        Andreas

                        Comment


                        • #13
                          Originally posted by Andreas Senft View Post
                          Well, it might be that just two EJBs got instantiated. Each of them has its own application context.

                          Another explanation for the duplicates might be that logging is misconfigured (in that case, all lines should be doubled).

                          Regards,
                          Andreas
                          The logging was bad indeed.
                          But each EJB has it's own applicationContext.
                          Lets say I have EJB_1 with method a , and EJB_2 with method c.

                          When I call EJB_1.a an applicationContext is created.
                          When I call EJB_2.c another one is created.

                          Each of them is individual (has it's own hibernate session and stuff ...).

                          How can I create only one ApplicationContext for all EJB's alive in an application?
                          Another issue i'm having at this point is hibernate session timeouts. The hibernate session (for both ejb's) keeps closing after a limited amount of time, thus leading to an OOME (OutOfMemoryException) in the end. Session times out, closes, but I presume it never gets GC-ed.

                          How can I deal with this problem, keeping the applicationContext alive?

                          Thanks.

                          PS: in case anyone wonders, when calling the EJB_2.c method the first hibernate session hasn't yet timed-out.
                          Last edited by gavieritei; Feb 14th, 2007, 09:58 AM.

                          Comment


                          • #14
                            Originally posted by gavieritei View Post
                            How can I create only one ApplicationContext for all EJB's alive in an application?
                            Have a look at ContextSingletonBeanFactoryLocator. There is a section about it in the reference manual.

                            Originally posted by gavieritei View Post
                            Another issue i'm having at this point is hibernate session timeouts. The hibernate session (for both ejb's) keeps closing after a limited amount of time, thus leading to an OOME (OutOfMemoryException) in the end. Session times out, closes, but I presume it never gets GC-ed.
                            Did you use a memory profiler to verify this? I suspect there might be other issues. And as this now leaves the original topic: When you find out more details, please open a new thread for that one (this one is rather full already ;-).

                            Regards,
                            Andreas

                            Comment


                            • #15
                              env-entry

                              Do we need an
                              <env-entry>
                              <env-entry-name>ejb/BeanFactoryPath</env-entry-name>
                              <env-entry-type>java.lang.String</env-entry-type>
                              <env-entry-value><![CDATA[xyz.xml]]></env-entry-value>
                              </env-entry>
                              in our ejb-jar, when using the ContextSingletonBeanFactoryLocator in our setSessionContext ?

                              Comment

                              Working...
                              X