I think, I have a spring configuration problem. I use eclipse with the spring tool plug-in enabled for my project. I used to have one configuration file for my business logic beans and for the test environment. Then, I decided to split the configuration file in two files, one for the test environment and one for the business logic beans, do that the second one would be the base for the actuall application.
The configuration file is system-test-config.xml
org.datanucleus.jdo.JDOPersistenceManagerFactory
jdbc:hsqldb:mem:dbname
sa
org.hsqldb.jdbcDriver
true
PROPAGATION_REQUIRED,readOnly
PROPAGATION_REQUIRED,readOnly
PROPAGATION_REQUIRED,readOnly
PROPAGATION_REQUIRED
PROPAGATION_REQUIRED
and the application file is application-config.xml
With this configurations files it should be working, shouldn't it? The test config xml imports the application configuration, so it should recognize the
sampleDAOImpl bean defined in it. But it doesn't.
Eclipse (through the sprint tool) shows me an error:
cvc-id.1: There is no ID/IDREF binding for IDREF 'sampleDAOImpl'.and the execution of the test has as result the following exception:
Caused by: org.xml.sax.SAXParseException: cvc-id.1: There is no ID/IDREF binding for IDREF 'sampleDAOImpl'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleEndElement(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
... 26 more
Solution:After searching a little bit in google, I found
this. It seams that there is a difference between local declared beans and not local beans. The bean sampleDAOImpl is defined in a separate xml file, so I should reference to it not as a local bean, using the ref attribute of the property tag. That's all!