-
Apr 10th, 2009, 07:12 AM
#1
Singletons being destroyed immediately after creation while running JUnit tests
I find the following in my logs while running JUnit tests via maven.
-------------------------------------------------
2009-04-10 02:21:24,250 INFO [org.springframework.context.support.ClassPathXmlAp plicationContext] - Refreshing org.springframework.context.support.ClassPathXmlAp plicationContext@453807: display name [org.springframework.context.support.ClassPathXmlAp plicationContext@453807]; startup date [Fri Apr 10 02:21:24 PDT 2009]; root of context hierarchy
2009-04-10 02:21:24,359 INFO [org.springframework.beans.factory.xml.XmlBeanDefin itionReader] - Loading XML bean definitions from class path resource [1.xml]
2009-04-10 02:21:25,109 INFO [org.springframework.context.support.ClassPathXmlAp plicationContext] - Bean factory for application context [org.springframework.context.support.ClassPathXmlAp plicationContext@453807]: org.springframework.beans.factory.support.DefaultL istableBeanFactory@a00185
2009-04-10 02:21:25,375 INFO [org.springframework.beans.factory.config.PropertyP laceholderConfigurer] - Loading properties file from class path resource [jdbc.properties]
2009-04-10 02:21:26,187 INFO [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@a00185: defining beans [org.springframework.aop.config.internalAutoProxyCr eator,org.springframework.transaction.interceptor. TransactionAttributeSourceAdvisor#0,daoAspect,prop ertyConfigurer,txManager,dataSource,messageSource]; root of factory hierarchy
2009-04-10 02:21:29,906 INFO [org.springframework.beans.factory.support.DefaultL istableBeanFactory] - Destroying singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@a00185: defining beans [org.springframework.aop.config.internalAutoProxyCr eator,org.springframework.transaction.interceptor. TransactionAttributeSourceAdvisor#0,daoAspect,prop ertyConfigurer,txManager,dataSource,messageSource]; root of factory hierarchy
-------------------------------------------------
After this, the JUnit tests run and throw NPEs as the singletons are already destroyed. I am a newbie to Spring and am not sure why the beans are being destroyed. I am using Spring 2.5.3. Any ideas?
1.xml looks like :
-------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="messageSource"
class="org.springframework.context.support.Reloada bleResourceBundleMessageSource" lazy-init="false">
<property name="cacheSeconds" value="1" />
<property name="useCodeAsDefaultMessage" value="false" />
<property name="fallbackToSystemLocale" value="false" />
<property name="basenames">
<list>
<value>state-bundle</value>
</list>
</property>
</bean>
</beans>
-------------------------------------------------
-
Apr 13th, 2009, 01:04 AM
#2
Anybody has any solution to this?
-
Apr 13th, 2009, 03:05 AM
#3
Is that really all your config?? Maybe post the web.xml and other spring related configs.
-
Apr 13th, 2009, 04:20 AM
#4
What parts of the web.xml or other config files would be of interest? Please let me know and i'd post those parts.
-
Apr 14th, 2009, 12:51 AM
#5
This started happening after I replaced Apache XMLBeans with Java's JAXB 2.0. (JAXB produces concrete classes while XMLBeans produces interfaces and implementations in a impl package).
-
Apr 14th, 2009, 04:04 AM
#6
Well, since I don't have any idea where the problem might lie it's pretty hard to tell which part of the config might be responsible. But since the affected class is part of Spring MVC I'd say post everything Spring MVC related. I looked through my own config for my current project but since I'm working with webflow I don't have much MVC config so I can't really tell you what parts are important.
As for JAXB, are you using the JAXB package from the Spring dist or a standalone? Maybe there are some tweaks in the Spring dist...
Sorry for the meek support, I haven't had too much experience myself.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules