Results 1 to 3 of 3

Thread: Confusing info message in 1.01

  1. #1
    Join Date
    Aug 2004
    Location
    Tacoma, WA USA
    Posts
    49

    Default 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?
    ElPapa

    The delusion that people care about what I think:
    http://www.codethought.com/blog

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default Re: Confusing info message in 1.01

    Quote 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.


    Quote 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.

    Quote 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).

    Quote 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

  3. #3
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    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.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

Similar Threads

  1. JBoss 3.2.6 & Spring Deployment issues
    By difranr in forum Container
    Replies: 2
    Last Post: Sep 18th, 2005, 10:08 PM
  2. Replies: 2
    Last Post: Aug 26th, 2005, 12:54 AM
  3. DefaultAdvisorAutoProxyCreator skipping beans
    By youngm in forum Container
    Replies: 6
    Last Post: Apr 12th, 2005, 04:29 PM
  4. Replies: 13
    Last Post: Dec 7th, 2004, 10:00 AM
  5. Replies: 2
    Last Post: Sep 5th, 2004, 10:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •