Announcement Announcement Module
Collapse
No announcement yet.
problem with PropertyPlaceholderConfigurer Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem with PropertyPlaceholderConfigurer

    Hello,

    i am using a property placeholder confirure in my applicationcontext.xml
    It reads the properties of a rmi.properties file.
    This works fine when starting the webserver (with an ContextLoaderListener in the web.xml).
    But when i use the same applicationcontext.xml file from my unittest i get the following error.

    The following is the initialisation code in the unittest
    Code:
     
    String[] paths = { "applicationContext-unittest-resources.xml", "applicationContext-hibernate.xml", "applicationContext-service.xml" };
    		ctx = new ClassPathXmlApplicationContext(paths);
    	}
    and this is the exception that is logged.
    Code:
        [junit] java.lang.ExceptionInInitializerError
        [junit]     at java.lang.Class.forName0(Native Method)
        [junit]     at java.lang.Class.forName(Class.java:141)
        &#91;junit&#93;     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>&#40;JUnitTestRunner.java&#58;204&#41;
        &#91;junit&#93;     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>&#40;JUnitTestRunner.java&#58;177&#41;
        &#91;junit&#93;     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch&#40;JUnitTestRunner.java&#58;651&#41;
        &#91;junit&#93;     at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main&#40;JUnitTestRunner.java&#58;537&#41;
        &#91;junit&#93; Caused by&#58; org.springframework.beans.factory.BeanDefinitionStoreException&#58; Error registering bean with name 'org.springframework.remoting.
    rmi.RmiServiceExporter' defined in class path resource &#91;applicationContext-service.xml&#93;&#58; Could not resolve placeholder 'rmi.port'
        &#91;junit&#93;     at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties&#40;PropertyPlaceholderConfigurer.java&#58;230&#41;
        &#91;junit&#93;     at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory&#40;PropertyResourceConfigurer.java&#58;184&#41;
        &#91;junit&#93;     at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors&#40;AbstractApplicationContext.java&#58;361&#41;
    
        &#91;junit&#93;     at org.springframework.context.support.AbstractApplicationContext.refresh&#40;AbstractApplicationContext.java&#58;299&#41;
        &#91;junit&#93;     at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;80&#41;
        &#91;junit&#93;     at org.springframework.context.support.ClassPathXmlApplicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;65&#41;
        &#91;junit&#93;     at nl.iza.verzekerdenadministratie.model.PolisTest.<clinit>&#40;PolisTest.java&#58;51&#41;
        &#91;junit&#93;     ... 6 more
        &#91;junit&#93; Exception in thread "main"
        &#91;junit&#93; Tests FAILED
    this are the parts of the applicationcontext that are used for this situation.
    The really strange thing is the fact that it seems to complain about the placeholder, before it complains about the properties file.
    I tried to rename the property file to a not existing location, and got the same error until i removed the placeholder. Only after that action it complained about the file that could not be found.
    To be complete; The filename as specified in the given applicationcontext.xml can be found if there is no placeholder in the file, so that is not the problem.

    Code:
    	<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="location" value="classpath&#58;rmi.properties"></property>
    	</bean>
    
        <bean class="org.springframework.remoting.rmi.RmiServiceExporter">
        	<property name="serviceName"><value>VARemoteService</value></property>
        	<property name="service"><ref bean="remoteServiceProvider"/></property>
         	<property name="serviceInterface"><value>nl.iza.verzekerdenadministratie.remoteservice.RemoteServiceProvider</value></property>
    		<property name="registryPort"><value>$&#123;rmi.port&#125;</value></property>
        </bean>
    Regards,

    Rene Boere
Working...
X