Announcement Announcement Module
Collapse
No announcement yet.
Trouble eagerly instantiating bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Trouble eagerly instantiating bean

    I am using a bean factory to load a basic RmiServiceExporter example which I want to be eagerly instantiated as soon as I create my XmlBeanFactory object. I am setting lazy-init to be false and my bean is a singleton scope so according to the docs it should be eagerly instantiated. This is not the case however and the RMI server is not started until I get a reference to the bean by calling factory.getBean(...). Can anyone tell me what I am missing in order to get this bean to eagerly instantiate and launch the RMI server as soon as the factory is created?? Does the creation of the factory not cause the bean definitions file to be parsed? Is the parsing defered until the first getBean method invocation?

    Code:
    XmlBeanFactory factory = new XmlBeanFactory(new ClassPathResource("beanDefinitions.xml"));
    My beanDefinitions.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD//EN" 
    	"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
    	
    <beans default-lazy-init="false">
    	<bean id="calculationService" class="CalculationServiceImpl" />	
    		
    	<bean id="calculationServiceExporter" class="org.springframework.remoting.rmi.RmiServiceExporter" 
    		scope="singleton" lazy-init="false">
    		<property name="serviceName" value="CalculationService" />
    		<property name="service" ref="calculationService" />
    		<property name="serviceInterface" value="CalculationService" />
    		<property name="registryPort" value="1199" />	
    	</bean>		
    </beans>

  • #2
    Can you post the log that shows it's not being eagerly init'ed?

    Comment


    • #3
      I have no log...after creating the XmlBeanFactory I tried telnetting to the RMI server/port and it's not running If I call getBean("rmiServiceExporter") after I create the factory and then telnet, I can establish a connection to the server. So this tells me the bean is not eagerly being instantiated.

      Comment


      • #4
        It would be a good idea to turn on logging to see what is going on here. What version of Spring are you using?

        Comment


        • #5
          Version 2.0.2

          Comment

          Working...
          X