|
From: Alef A. \(JTeam\) <al...@jt...> - 2003-09-24 11:36:50
|
I've had another look at it and __moved__ the dataControllerSupport bean
to the applicationContext, while the formContrller still resides in the
web-app-ctx. This fixes the problem, however, I still think,
resolveReferences, calling getBeanInternal, should also call
setApplicationContext() when creating a shared instance!
Alef
-----Oorspronkelijk bericht-----
Van: spr...@li...
[mailto:spr...@li...] Namens
Alef Arendsen (JTeam)
Verzonden: Wednesday, September 24, 2003 1:05 PM
Aan: spr...@li...
Onderwerp: [Springframework-developer] setApplicationContext() not
called on Singletons???
Hi all,
I've been spending like an hour on it, but can't find it:
I've got a bean (dataControllerSupport) defined which is referenced from
another bean (accountFormController), via <ref bean>. When the second
bean is loaded, it received the bean it's depending on. After that,
afterPropertiesSet() is called (on accountFormController), in which I'm
using the dataControllerSupport bean to resolve some things for me. The
dataControllerSupport bean needs the applicationcontext and therefore,
is ApplicationContext Aware. Hwoever, it does NOT have the application
context set!!! I've been investigating a while and really think
somewhere there's a flaw (using latest CVS code).
You can find the context (parts of it) below. Also, there some output...
The two beans...
<bean id="dataControllerSupport"
class="jteam.web.controller.DataControllerSupport">
<property name="addExtension">
<value>add</value>
</property>
<property name="editExtension">
<value>edit</value>
</property>
<property name="detailsViewPrefix">
<value>details.</value>
</property>
<property name="listViewPrefix">
<value>list.</value>
</property>
<property name="formViewPrefix">
<value>form.</value>
</property>
<property name="recordHelperClass">
<value>jteam.jbosssupport.data.RecordHelper</value>
</property>
<property name="propertyEditorsFactory">
<ref bean="propertyEditorsFactory"/>
</property>
</bean>
<bean id="accountFormController"
class="jteam.web.controller.DataFormController">
<property name="dataControllerSupport">
<ref bean="dataControllerSupport"/>
</property>
<property name="objectType">
<value>Account</value>
</property>
<property name="sessionForm">
<value>true</value>
</property>
<property name="bindOnNewForm">
<value>true</value>
</property>
<property name="dataHelper">
<ref external="accountHelper"/>
</property>
<property name="validator"><ref
bean="recordValidator"></ref></property>
<property name="referenceData">
<map>
<entry key="billingAddress.country">
<ref external="countries"/>
</entry>
<entry key="companyAddress.country">
<ref external="countries"/>
</entry>
</map>
</property>
</bean>
The output I'm receiving when the dataControllerSupport is instantiated
(it's a Thread.dumpStack()). I've put some output at the places where
the applicationcontext is __supposed__ to be set, but it's not
outputting anything. Also, in the AbstractBeanFactory class, when
resolving references, I can't find any calls to setApplicationContext()
being done, however, afterPropertiesSet() on the depending bean _IS_
called, in which I'm relying on setApplicationContext() on the second
bean being called!!!
Anybody???
[XmlWebApplicationContext] 42 beans defined in ApplicationContext
[WebApplicationContext for namespace 'jbosssupport-servlet']
[XmlWebApplicationContext] ******* Retrieving bean contextOptions
[XmlWebApplicationContext] ******* Retrieving bean contextOptions
[XmlWebApplicationContext] No options bean ("contextOptions") found:
using default [XmlWebApplicationContext] ******* Retrieving bean
messageSource [XmlWebApplicationContext] ******* Retrieving bean
messageSource [XmlWebApplicationContext] ******* Going to see if I need
to set the context on messageSource [XmlWebApplicationContext] *******
No, NOT DOING IT! [XmlWebApplicationContext] ******* Going to see if I
need to set the context on messageSource [XmlWebApplicationContext]
******* No, NOT DOING IT! [XmlWebApplicationContext] ******* Retrieving
bean themeSource [XmlWebApplicationContext] ******* Retrieving bean
themeSource [UiApplicationContextUtils] No ThemeSource found for
[WebApplicationContext for namespace 'jbosssupport-servlet']: using
ResourceBundleThemeSour [XmlWebApplicationContext] Refreshing listeners
[XmlWebApplicationContext] Configuring singleton beans in context
[XmlWebApplicationContext] ******* Retrieving bean
contractViewController [XmlBeanFactory] Creating shared instance of
singleton bean 'contractViewController' [XmlBeanFactory] Creating shared
instance of singleton bean 'dataControllerSupport'
[DataControllerSupport] DataControllerSupport instantantiated [STDERR]
java.lang.Exception: Stack trace
[STDERR] at java.lang.Thread.dumpStack(Thread.java:1071)
[STDERR] at
jteam.web.controller.DataControllerSupport.<init>(DataControllerSupport.
java:83)
[STDERR] at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[STDERR] at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorA
ccessorImpl.java:39)
[STDERR] at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCons
tructorAccessorImpl.java:27)
[STDERR] at
java.lang.reflect.Constructor.newInstance(Constructor.java:274)
[STDERR] at java.lang.Class.newInstance0(Class.java:306)
[STDERR] at java.lang.Class.newInstance(Class.java:259)
[STDERR] at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:26)
[STDERR] at
org.springframework.beans.BeanWrapperImpl.<init>(BeanWrapperImpl.java:16
5)
[STDERR] at
org.springframework.beans.factory.support.AbstractBeanFactory.createBean
(AbstractBeanFactory.java:295)
[STDERR] at
org.springframework.beans.factory.support.AbstractBeanFactory.getSharedI
nstance(AbstractBeanFactory.java:233)
[STDERR] at
org.springframework.beans.factory.support.AbstractBeanFactory.getBeanInt
ernal(AbstractBeanFactory.java:162)
[STDERR] at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveRef
erence(AbstractBeanFactory.java:447)
[STDERR] at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveVal
ueIfNecessary(AbstractBeanFactory.java:403)
[STDERR] at
org.springframework.beans.factory.support.AbstractBeanFactory.applyPrope
rtyValues(AbstractBeanFactory.java:367)
[STDERR] at
org.springframework.beans.factory.support.AbstractBeanFactory.createBean
(AbstractBeanFactory.java:319)
[STDERR] at
org.springframework.beans.factory.support.AbstractBeanFactory.getSharedI
nstance(AbstractBeanFactory.java:233)
[STDERR] at
org.springframework.beans.factory.support.AbstractBeanFactory.getBeanInt
ernal(AbstractBeanFactory.java:162)
[STDERR] at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ab
stractBeanFactory.java:140)
[STDERR] at
org.springframework.context.support.AbstractApplicationContext.getBean(A
bstractApplicationContext.java:453)
[STDERR] at
org.springframework.context.support.AbstractApplicationContext.preInstan
tiateSingletons(AbstractApplicationContext.java:303)
[STDERR] at
org.springframework.context.support.AbstractApplicationContext.refresh(A
bstractApplicationContext.java:229)
[STDERR] at
org.springframework.web.context.support.XmlWebApplicationContext.setServ
letContext(XmlWebApplicationContext.java:121)
[STDERR] at
org.springframework.web.servlet.FrameworkServlet.createWebApplicationCon
text(FrameworkServlet.java:167)
[STDERR] at
org.springframework.web.servlet.FrameworkServlet.initServletBean(Framewo
rkServlet.java:146)
[STDERR] at
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.jav
a:82)
[STDERR] at
javax.servlet.GenericServlet.init(GenericServlet.java:256)
[STDERR] at
org.mortbay.jetty.servlet.ServletHolder.start(ServletHolder.java:219)
[STDERR] at
org.mortbay.jetty.servlet.ServletHandler.initializeServlets(ServletHandl
er.java:436)
[STDERR] at
org.mortbay.jetty.servlet.WebApplicationHandler.initializeServlets(WebAp
plicationHandler.java:150)
[STDERR] at
org.mortbay.jetty.servlet.WebApplicationContext.start(WebApplicationCont
ext.java:440)
[STDERR] at
org.mortbay.j2ee.J2EEWebApplicationContext.start(J2EEWebApplicationConte
xt.java:85)
[STDERR] at
org.jboss.jetty.JBossWebApplicationContext.start(JBossWebApplicationCont
ext.java:89)
[STDERR] at org.jboss.jetty.Jetty.deploy(Jetty.java:331)
[STDERR] at
org.jboss.jetty.JettyService.performDeploy(JettyService.java:242)
[STDERR] at
org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:399)
[STDERR] at
org.jboss.deployment.MainDeployer.start(MainDeployer.java:822)
[STDERR] at
org.jboss.deployment.MainDeployer.start(MainDeployer.java:814)
[STDERR] at
org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:630)
[STDERR] at
org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:603)
[STDERR] at sun.reflect.GeneratedMethodAccessor31.invoke(Unknown
Source)
[STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
[STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
[STDERR] at
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDi
spatcher.java:284)
[STDERR] at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
[STDERR] at
org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
[STDERR] at $Proxy7.deploy(Unknown Source)
[STDERR] at
org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentSc
anner.java:302)
[STDERR] at
org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScan
ner.java:476)
[STDERR] at
org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doS
can(AbstractDeploymentScanner.java:200)
[STDERR] at
org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(Abst
ractDeploymentScanner.java:273)
[STDERR] at
org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
[STDERR] at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown
Source)
[STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
[STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
[STDERR] at
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDi
spatcher.java:284)
[STDERR] at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
[STDERR] at
org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController
.java:966)
[STDERR] at $Proxy0.start(Unknown Source)
[STDERR] at
org.jboss.system.ServiceController.start(ServiceController.java:392)
[STDERR] at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown
Source)
[STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
[STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
[STDERR] at
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDi
spatcher.java:284)
[STDERR] at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
[STDERR] at
org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
[STDERR] at $Proxy5.start(Unknown Source)
[STDERR] at
org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
[STDERR] at
org.jboss.deployment.MainDeployer.start(MainDeployer.java:822)
[STDERR] at
org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:630)
[STDERR] at
org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:603)
[STDERR] at
org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:587)
[STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
[STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
[STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
[STDERR] at java.lang.reflect.Method.invoke(Method.java:324)
[STDERR] at
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDi
spatcher.java:284)
[STDERR] at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
[STDERR] at
org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
[STDERR] at $Proxy6.deploy(Unknown Source)
[STDERR] at
org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:365)
[STDERR] at
org.jboss.system.server.ServerImpl.start(ServerImpl.java:272)
[STDERR] at org.jboss.Main.boot(Main.java:150)
[STDERR] at org.jboss.Main$1.run(Main.java:388)
[STDERR] at java.lang.Thread.run(Thread.java:536)
[XmlBeanFactory] Creating shared instance of singleton bean
'propertyEditorsFactory' [XmlWebApplicationContext] ******* Going to see
if I need to set the context on contractViewController
[XmlWebApplicationContext] ******* Yes, doing it! [RecordController]
Setting application context ApplicationContext:
displayName=[WebApplicationContext for namespace
'jbosssupport-servlet']; cla
==
JTeam B.V.
Donker Curtiusstraat 7-412
1051 JL Amsterdam
T: +31 20 486 20 36
M: +31 6 24 11 1996
F: +31 84 837 00 00
E: al...@jt...
W: www.jteam.nl
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf _______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|