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
and this is the exception that is logged.Code:String[] paths = { "applicationContext-unittest-resources.xml", "applicationContext-hibernate.xml", "applicationContext-service.xml" }; ctx = new ClassPathXmlApplicationContext(paths); }
this are the parts of the applicationcontext that are used for this situation.Code:[junit] java.lang.ExceptionInInitializerError [junit] at java.lang.Class.forName0(Native Method) [junit] at java.lang.Class.forName(Class.java:141) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUnitTestRunner.java:204) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUnitTestRunner.java:177) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:651) [junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:537) [junit] Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'org.springframework.remoting. rmi.RmiServiceExporter' defined in class path resource [applicationContext-service.xml]: Could not resolve placeholder 'rmi.port' [junit] at org.springframework.beans.factory.config.PropertyPlaceholderConfigurer.processProperties(PropertyPlaceholderConfigurer.java:230) [junit] at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:184) [junit] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:361) [junit] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:299) [junit] at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:80) [junit] at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65) [junit] at nl.iza.verzekerdenadministratie.model.PolisTest.<clinit>(PolisTest.java:51) [junit] ... 6 more [junit] Exception in thread "main" [junit] Tests FAILED
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.
Regards,Code:<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath: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>${rmi.port}</value></property> </bean>
Rene Boere


Reply With Quote