|
From: <jue...@we...> - 2003-06-13 14:49:29
|
Hi Ken,
The solution is simple: <ref bean=3D"clinic"/> refers to a bean defined =
in the same BeanFactory, i.e. the same XML file. To reference a bean in =
a parent context, use <ref external=3D"clinic"/>. Note that the former =
gets validated by an XML parse while that latter does not. The old =
"beanRef=3Dtrue" style didn't have that distinction, it was introduced =
with the spring-beans DTD.
Thus, simply change your <ref bean=3D"clinic"/> references to <ref =
external=3D"clinic"/>, and everything should work again :-)
Regards,
Ken
-----Original Message-----
From: Ken Krebs [mailto:kk...@kk...]
Sent: Friday, June 13, 2003 4:38 PM
To: j=FCrgen h=F6ller [werk3AT]
Cc: 'spring-dev-list'
Subject: [Springframework-developer] bean ref problem
Juergen,
Having just recompiled Spring, I have a new problem that wasn't there=20
before the renaming of ControllerServlet to DispatcherServlet.
In my applicationContext.xml, I define 4 beans representing the data=20
provider ("dataSource", "incrementer", and "dao") and the main business=20
object, "clinic".
Several of my form beans defined in petclinic-servlet.xml reference the=20
"clinic" bean. Now, on startup, I get a SAXParseException because the=20
"clinic" bean cannot be found. Apparently I need to do something extra=20
now to get "clinic" to be recognized. Before the recent changes, this=20
was not a problem. If I move all 4 beans to petclinic-servlet.xml, it=20
works fine but I really don't want to do this. The log output follows:
=20
2003-06-13 09:21:13,092 INFO [com.interface21.web.context.ContextLoader] =
- <Loading root WebApplicationContext: using context class=20
'com.interface21.web.context.support.XmlWebApplicationContext'>
2003-06-13 09:21:13,102 INFO=20
[com.interface21.web.context.support.XmlWebApplicationContext] - <Using=20
config location '/WEB-INF/applicationContext.xml'>
2003-06-13 09:21:13,152 INFO=20
[com.interface21.beans.factory.xml.XmlBeanFactory] - <Loading=20
XmlBeanFactory from InputStream [java.io.ByteArrayInputStream@110769b]>
2003-06-13 09:21:13,342 INFO=20
[com.interface21.beans.factory.xml.XmlBeanFactory] - <Cached shared=20
instance of Singleton bean 'clinicDAO'>
2003-06-13 09:21:13,392 INFO=20
[com.interface21.beans.CachedIntrospectionResults] - <Getting BeanInfo=20
for class class petclinic.dao.ClinicJdbcDAO>
2003-06-13 09:21:13,422 INFO=20
[com.interface21.beans.factory.xml.XmlBeanFactory] - <Cached shared=20
instance of Singleton bean 'dataSource'>
2003-06-13 09:21:13,422 INFO=20
[com.interface21.beans.CachedIntrospectionResults] - <Getting BeanInfo=20
for class class com.interface21.jndi.JndiObjectFactoryBean>
2003-06-13 09:21:13,532 INFO [petclinic.dao.ClinicJdbcDAO$AllVetsQuery]=20
- <Compiled OK>
2003-06-13 09:21:13,532 INFO [petclinic.dao.ClinicJdbcDAO$TypesQuery] -=20
<Compiled OK>
2003-06-13 09:21:13,532 INFO=20
[petclinic.dao.ClinicJdbcDAO$SpecialtiesQuery] - <Compiled OK>
2003-06-13 09:21:13,542 INFO=20
[petclinic.dao.ClinicJdbcDAO$OwnersByNameQuery] - <Compiled OK>
2003-06-13 09:21:13,542 INFO [petclinic.dao.ClinicJdbcDAO$OwnerQuery] -=20
<Compiled OK>
2003-06-13 09:21:13,542 INFO=20
[petclinic.dao.ClinicJdbcDAO$PetsByOwnerQuery] - <Compiled OK>
2003-06-13 09:21:13,542 INFO [petclinic.dao.ClinicJdbcDAO$VisitsQuery] - =
<Compiled OK>
2003-06-13 09:21:13,542 INFO=20
[petclinic.dao.ClinicJdbcDAO$VetSpecialtiesQuery] - <Compiled OK>
2003-06-13 09:21:13,552 INFO [petclinic.dao.ClinicJdbcDAO$OwnerInsert] - =
<Compiled OK>
2003-06-13 09:21:13,552 INFO [petclinic.dao.ClinicJdbcDAO$PetInsert] -=20
<Compiled OK>
2003-06-13 09:21:13,552 INFO [petclinic.dao.ClinicJdbcDAO$VisitInsert] - =
<Compiled OK>
2003-06-13 09:21:13,552 INFO [petclinic.dao.ClinicJdbcDAO$OwnerUpdate] - =
<Compiled OK>
2003-06-13 09:21:13,552 INFO=20
[com.interface21.beans.factory.xml.XmlBeanFactory] - <Cached shared=20
instance of Singleton bean 'messageSource'>
2003-06-13 09:21:13,552 INFO=20
[com.interface21.beans.CachedIntrospectionResults] - <Getting BeanInfo=20
for class class =
com.interface21.context.support.ResourceBundleMessageSource>
2003-06-13 09:21:13,572 INFO=20
[com.interface21.beans.factory.xml.XmlBeanFactory] - <Cached shared=20
instance of Singleton bean 'clinic'>
2003-06-13 09:21:13,572 INFO=20
[com.interface21.beans.CachedIntrospectionResults] - <Getting BeanInfo=20
for class class petclinic.ClinicImpl>
2003-06-13 09:21:13,613 INFO [com.interface21.jdbc.core.JdbcTemplate] -=20
<Executing SQL query using PreparedStatement:=20
[PreparedStatementCreatorFactory.PreparedStatementCreatorImpl:=20
sql=3D{SELECT id,first_name,last_name FROM vets ORDER BY=20
last_name,first_name}: params=3D{}]>
2003-06-13 09:21:13,643 INFO [com.interface21.jdbc.core.JdbcTemplate] -=20
<Executing SQL query using PreparedStatement:=20
[PreparedStatementCreatorFactory.PreparedStatementCreatorImpl:=20
sql=3D{SELECT id,name FROM specialties}: params=3D{}]>
2003-06-13 09:21:13,643 INFO [com.interface21.jdbc.core.JdbcTemplate] -=20
<Executing SQL query using PreparedStatement:=20
[PreparedStatementCreatorFactory.PreparedStatementCreatorImpl:=20
sql=3D{SELECT specialty_id FROM vet_specialties WHERE vet_id=3D?}: =
params=3D{1}]>
2003-06-13 09:21:13,643 INFO [com.interface21.jdbc.core.JdbcTemplate] -=20
<Executing SQL query using PreparedStatement:=20
[PreparedStatementCreatorFactory.PreparedStatementCreatorImpl:=20
sql=3D{SELECT specialty_id FROM vet_specialties WHERE vet_id=3D?}: =
params=3D{3}]>
2003-06-13 09:21:13,653 INFO [com.interface21.jdbc.core.JdbcTemplate] -=20
<Executing SQL query using PreparedStatement:=20
[PreparedStatementCreatorFactory.PreparedStatementCreatorImpl:=20
sql=3D{SELECT specialty_id FROM vet_specialties WHERE vet_id=3D?}: =
params=3D{6}]>
2003-06-13 09:21:13,653 INFO [com.interface21.jdbc.core.JdbcTemplate] -=20
<Executing SQL query using PreparedStatement:=20
[PreparedStatementCreatorFactory.PreparedStatementCreatorImpl:=20
sql=3D{SELECT specialty_id FROM vet_specialties WHERE vet_id=3D?}: =
params=3D{2}]>
2003-06-13 09:21:13,653 INFO [com.interface21.jdbc.core.JdbcTemplate] -=20
<Executing SQL query using PreparedStatement:=20
[PreparedStatementCreatorFactory.PreparedStatementCreatorImpl:=20
sql=3D{SELECT specialty_id FROM vet_specialties WHERE vet_id=3D?}: =
params=3D{4}]>
2003-06-13 09:21:13,653 INFO [com.interface21.jdbc.core.JdbcTemplate] -=20
<Executing SQL query using PreparedStatement:=20
[PreparedStatementCreatorFactory.PreparedStatementCreatorImpl:=20
sql=3D{SELECT specialty_id FROM vet_specialties WHERE vet_id=3D?}: =
params=3D{5}]>
2003-06-13 09:21:13,663 INFO [com.interface21.jdbc.core.JdbcTemplate] -=20
<Executing SQL query using PreparedStatement:=20
[PreparedStatementCreatorFactory.PreparedStatementCreatorImpl:=20
sql=3D{SELECT id,name FROM types ORDER BY name}: params=3D{}]>
2003-06-13 09:21:13,663 INFO=20
[com.interface21.web.context.support.XmlWebApplicationContext] -=20
<BeanFactory for application context is [class=20
com.interface21.beans.factory.xml.XmlBeanFactory: defined beans=20
[clinicDAO,dataSource,messageSource,clinic,incrementer]]>
2003-06-13 09:21:13,663 INFO=20
[com.interface21.web.context.support.XmlWebApplicationContext] - <5=20
beans defined in ApplicationContext: Root WebApplicationContext>
2003-06-13 09:21:13,663 INFO=20
[com.interface21.web.context.support.XmlWebApplicationContext] - <No=20
options bean ("contextOptions") found: using default>
2003-06-13 09:21:13,673 INFO=20
[com.interface21.web.context.support.XmlWebApplicationContext] -=20
<Refreshing listeners>
2003-06-13 09:21:13,673 INFO=20
[com.interface21.web.context.support.XmlWebApplicationContext] -=20
<Configuring singleton beans in context>
2003-06-13 09:21:13,673 INFO=20
[com.interface21.beans.CachedIntrospectionResults] - <Getting BeanInfo=20
for class class =
com.interface21.jdbc.core.support.HsqlMaxValueIncrementer>
2003-06-13 09:21:13,703 INFO=20
[com.interface21.web.context.support.WebApplicationContextUtils] -=20
<Configuring config objects>
2003-06-13 09:21:13,703 INFO=20
[com.interface21.web.context.support.WebApplicationContextUtils] -=20
<Loader initialized on server name Apache Tomcat/4.1.18;=20
WebApplicationContext object is available in ServletContext with name=20
'interface com.interface21.web.context.WebApplicationContext.ROOT'>
2003-06-13 09:21:13,733 INFO=20
[com.interface21.web.servlet.DispatcherServlet] - <Servlet with name=20
'petclinic' entering init...>
2003-06-13 09:21:13,743 INFO=20
[com.interface21.beans.CachedIntrospectionResults] - <Getting BeanInfo=20
for class class com.interface21.web.servlet.DispatcherServlet>
2003-06-13 09:21:13,763 INFO=20
[com.interface21.web.servlet.DispatcherServlet] - <Framework servlet=20
'petclinic' init>
2003-06-13 09:21:13,763 INFO=20
[com.interface21.web.context.support.XmlWebApplicationContext] - <Using=20
config location '/WEB-INF/petclinic-servlet.xml'>
2003-06-13 09:21:13,763 INFO=20
[com.interface21.beans.factory.xml.XmlBeanFactory] - <Loading=20
XmlBeanFactory from InputStream [java.io.ByteArrayInputStream@1b77832]>
2003-06-13 09:21:13,773 ERROR=20
[com.interface21.beans.factory.xml.XmlBeanFactory] -=20
<org.xml.sax.SAXParseException: An element with the identifier "clinic"=20
must appear in the document.>
2003-06-13 09:21:13,793 ERROR=20
[com.interface21.web.servlet.DispatcherServlet] - <Servlet with name=20
'petclinic' : initialization error>
org.xml.sax.SAXParseException: An element with the identifier "clinic"=20
must appear in the document.
at org.apache.xerces.parsers.DOMParser.parse(DOMParser.java:267)
at=20
org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java=
:201)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:122)
at=20
com.interface21.beans.factory.xml.XmlBeanFactory.loadBeanDefinitions(XmlB=
eanFactory.java:198)
at=20
com.interface21.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.ja=
va:149)
at=20
com.interface21.context.support.AbstractXmlApplicationContext.refreshBean=
Factory(AbstractXmlApplicationContext.java:40)
at=20
com.interface21.context.support.AbstractApplicationContext.refresh(Abstra=
ctApplicationContext.java:208)
at=20
com.interface21.web.context.support.XmlWebApplicationContext.setServletCo=
ntext(XmlWebApplicationContext.java:121)
at=20
com.interface21.web.servlet.FrameworkServlet.createWebApplicationContext(=
FrameworkServlet.java:160)
at=20
com.interface21.web.servlet.FrameworkServlet.initServletBean(FrameworkSer=
vlet.java:143)
at=20
com.interface21.web.servlet.HttpServletBean.init(HttpServletBean.java:93)=
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at=20
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java=
:934)
at=20
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:821)
at=20
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.ja=
va:3420)
at=20
org.apache.catalina.core.StandardContext.start(StandardContext.java:3608)=
at=20
org.apache.catalina.core.StandardHostDeployer.start(StandardHostDeployer.=
java:458)
at =
org.apache.catalina.core.StandardHost.start(StandardHost.java:872)
at=20
org.apache.catalina.servlets.ManagerServlet.start(ManagerServlet.java:101=
4)
at=20
org.apache.catalina.servlets.HTMLManagerServlet.start(HTMLManagerServlet.=
java:379)
at=20
org.apache.catalina.servlets.HTMLManagerServlet.doGet(HTMLManagerServlet.=
java:149)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at=20
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicat=
ionFilterChain.java:247)
at=20
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilte=
rChain.java:193)
at=20
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve=
.java:260)
at=20
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.in=
vokeNext(StandardPipeline.java:643)
at=20
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:48=
0)
at =
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at=20
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve=
.java:191)
at=20
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.in=
vokeNext(StandardPipeline.java:643)
at=20
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorB=
ase.java:550)
at=20
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.in=
vokeNext(StandardPipeline.java:641)
at=20
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:48=
0)
at =
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at=20
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415=
)
at=20
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:=
180)
at=20
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.in=
vokeNext(StandardPipeline.java:643)
at=20
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherVal=
ve.java:170)
at=20
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.in=
vokeNext(StandardPipeline.java:641)
at=20
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:=
172)
at=20
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.in=
vokeNext(StandardPipeline.java:641)
at=20
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:48=
0)
at =
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at=20
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.j=
ava:174)
at=20
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.in=
vokeNext(StandardPipeline.java:643)
at=20
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:48=
0)
at =
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at=20
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at=20
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432=
)
at=20
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processCo=
nnection(Http11Protocol.java:386)
at=20
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534=
)
at=20
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.=
java:530)
at java.lang.Thread.run(Thread.java:536)
I have attached the xml config files. Please advise.
Regards,
Ken
|