Announcement Announcement Module
Collapse
No announcement yet.
Confusing info message in 1.01 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Confusing info message in 1.01

    OK.. I'm having some confusion with the Singleton/Prototype management system in spring - especially with respect to POJO access and EJB access.

    I have a EJB defined in a context file as shown below. Now, I know that the ProxyFactoryBean is a singleton - but that DOESN'T mean that the EJB I'm trying to access is also a singleton, does it??

    Code:
            <bean id="Stations"
              class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
              <property name="jndiName">
                <value>ejb/Stations</value>
              </property>
              <property name="jndiEnvironment">
                <props>
                  <prop key="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</prop>
                  <prop key="java.naming.factory.url.pkgs">org.jboss.naming&#58;org.jnp.interfaces</prop>
                  <prop key="java.naming.provider.url">jnp&#58;//localhost&#58;1099</prop>
                </props>
              </property>
              <property name="businessInterface">
                <value>com.bar.foo.StationsService</value>
              </property>
            </bean>
    Also I have the following POJO data objects defined..

    Code:
            <bean name = "RequestListColorsDAO"
                       singleton="false"
                       class="com.far.foo.dao.RequestListColorsDAOImpl" >
            </bean>
    But what's confusing is that I'm seeing these types of messages from the logs in JBoss coming from Spring..

    Code:
    13&#58;01&#58;37,006 INFO  &#91;DefaultListableBeanFactory&#93; Pre-instantiating singletons in factory &#91;org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans &#91;dataSource,RequestListColorsDAO,RequestListDAO,RequestHoldersDAO,HoldersDAO,HolderEquipmentDAO,OSMRequest,Stations,Devices&#93;; Root of BeanFactory hierarchy
    And I'll see multiple lines that say singletons are being created for EJBs as well...

    Code:
    13&#58;01&#58;36,075 INFO  &#91;DefaultListableBeanFactory&#93; Creating shared instance of singleton bean 'Stations'
    13&#58;01&#58;36,085 INFO  &#91;DefaultListableBeanFactory&#93; Creating shared instance of singleton bean 'Stations'
    AND I see muliple lines like this:

    Code:
    13&#58;01&#58;38,728 INFO  &#91;ClassPathXmlApplicationContext&#93; 9 beans defined in ApplicationContext &#91;org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=15235194&#93;
    13&#58;01&#58;38,738 INFO  &#91;ClassPathXmlApplicationContext&#93; 9 beans defined in ApplicationContext &#91;org.springframework.context.support.ClassPathXmlApplicationContext;hashCode=16651101&#93;
    Now.. I can't have EJBs being singletons.. I need to create mulitple instances in JBoss. Otherwise I can't handle multiple requests with any decent efficiency.

    Am I misunderstanding these messages? How do I make sure that the singleton 'factory' is actually creating *muliple* EJB instances and *multiple* DAO implementations?

  • #2
    Re: Confusing info message in 1.01

    Originally posted by ElPapa
    OK.. I'm having some confusion with the Singleton/Prototype management system in spring - especially with respect to POJO access and EJB access.

    I have a EJB defined in a context file as shown below. Now, I know that the ProxyFactoryBean is a singleton - but that DOESN'T mean that the EJB I'm trying to access is also a singleton, does it??
    The point is, that you are accessing EJB instances via the ProxyFactoryBean. The ProxyFactoryBean is a singleton, which allows to access multiple instances of your EJB.


    Originally posted by ElPapa
    Also I have the following POJO data objects defined..

    Code:
            <bean name = "RequestListColorsDAO"
                       singleton="false"
                       class="com.far.foo.dao.RequestListColorsDAOImpl" >
            </bean>
    But what's confusing is that I'm seeing these types of messages from the logs in JBoss coming from Spring..

    Code:
    13&#58;01&#58;37,006 INFO  &#91;DefaultListableBeanFactory&#93; Pre-instantiating singletons in factory &#91;org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans &#91;dataSource,RequestListColorsDAO,RequestListDAO,RequestHoldersDAO,HoldersDAO,HolderEquipmentDAO,OSMRequest,Stations,Devices&#93;; Root of BeanFactory hierarchy
    I would say it just tells you that singletons of the bean factory are pre-instantiated. To clarify, which bean-factory it is, all defined beans (including the prototypes) are listed. I guess it does not mean that prototypes are also created upfront.

    Originally posted by ElPapa
    And I'll see multiple lines that say singletons are being created for EJBs as well...

    Code:
    13&#58;01&#58;36,075 INFO  &#91;DefaultListableBeanFactory&#93; Creating shared instance of singleton bean 'Stations'
    13&#58;01&#58;36,085 INFO  &#91;DefaultListableBeanFactory&#93; Creating shared instance of singleton bean 'Stations'
    It is _NOT_ the instantiation of EJBs. Rather the instantiiation of proxies accessing these. The duplicate appearance of the message seems to indicate that the XML configuration file is interpreted twice in parallel (maybe from pooled instances).

    Originally posted by ElPapa
    Am I misunderstanding these messages? How do I make sure that the singleton 'factory' is actually creating *muliple* EJB instances and *multiple* DAO implementations?
    As I said, it's only the proxy which is a singleton. From the client side you (and hence Spring) have no influence of the number of instances created in the application server.

    Hope that helps,
    Andreas

    Comment


    • #3
      Thanks Andreas--spot on. The ProxyFactoryBean on the client is a singleton, but it's not a point of contention. Your client code is still able to access any number of pooled SLSBs just as if you wrote all the JNDI lookup and EJB location code yourself.

      Comment

      Working...
      X