-
Jul 6th, 2006, 09:35 AM
#1
Problem with basic Spring test
Hi!
I am a new user of Spring Framework and I have an error that I don't understand. When the builder try to parse the file spring-config-test-dao-mysql.xml I have these errors:
INFO: Loading XML bean definitions from class path resource [spring-config-test-dao-mysql.xml]
Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'dao' defined in class path resource [spring-config-test-dao-mysql.xml]: Cannot resolve reference to bean 'sqlMapClient' while setting bean property 'sqlMapClient'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sqlMapClient' defined in class path resource [spring-config-test-dao-mysql.xml]: Initialization of bean failed; nested exception is com.ibatis.common.exception.NestedRuntimeException : Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
Caused by: org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
Caused by: org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sqlMapClient' defined in class path resource [spring-config-test-dao-mysql.xml]: Initialization of bean failed; nested exception is com.ibatis.common.exception.NestedRuntimeException : Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
Caused by: org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
Caused by: org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
com.ibatis.common.exception.NestedRuntimeException : Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
Caused by: org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
Caused by: org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigP arser.parse(SqlMapConfigParser.java:81)
at com.ibatis.sqlmap.client.SqlMapClientBuilder.build SqlMapClient(SqlMapClientBuilder.java:62)
at org.springframework.orm.ibatis.SqlMapClientFactory Bean.afterPropertiesSet(SqlMapClientFactoryBean.ja va:258)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1091)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:396)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:186)
at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:106)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1046)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:857)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:378)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
at upgrade_network.tests.MainTestDaoMysql.main(MainTe stDaoMysql.java:14)
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
Caused by: org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
at com.ibatis.common.xml.NodeletParser.parse(NodeletP arser.java:53)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigP arser.parse(SqlMapConfigParser.java:78)
... 14 more
Caused by:
org.xml.sax.SAXParseException: The XML declaration may only appear at the very beginning of the document.
at org.apache.xerces.framework.XMLParser.reportError( XMLParser.java:1196)
at org.apache.xerces.framework.XMLDocumentScanner.rep ortFatalXMLError(XMLDocumentScanner.java:570)
at org.apache.xerces.framework.XMLDocumentScanner.abo rtMarkup(XMLDocumentScanner.java:624)
at org.apache.xerces.framework.XMLDocumentScanner$Pro logDispatcher.dispatch(XMLDocumentScanner.java:810 )
at org.apache.xerces.framework.XMLDocumentScanner.par seSome(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLPar ser.java:1081)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(D ocumentBuilderImpl.java:195)
at com.ibatis.common.xml.NodeletParser.createDocument (NodeletParser.java:150)
at com.ibatis.common.xml.NodeletParser.parse(NodeletP arser.java:50)
at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigP arser.parse(SqlMapConfigParser.java:78)
at com.ibatis.sqlmap.client.SqlMapClientBuilder.build SqlMapClient(SqlMapClientBuilder.java:62)
at org.springframework.orm.ibatis.SqlMapClientFactory Bean.afterPropertiesSet(SqlMapClientFactoryBean.ja va:258)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1091)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:396)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:186)
at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:106)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:1046)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:857)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:378)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
at upgrade_network.tests.MainTestDaoMysql.main(MainTe stDaoMysql.java:14)
For informations I show you the file spring-config-test-dao-mysql.xml :
<?xml version="1.0" encoding="ISO_8859-1"?>
<!DOCTYPE beans SYSTEM "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- la source de donne?ees DBCP -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:8889/elgg_ju</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</property>
</bean>
<!-- SqlMapCllient -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClient FactoryBean">
<property name="dataSource">
<ref local="dataSource"/>
</property>
<property name="configLocation">
<value>classpath:sql-map-config-mysql.xml</value>
</property>
</bean>
<!-- la classes d'acce? a? la couche [dao] -->
<bean id="dao" class="upgrade_network.dao.DaoImplCommon">
<property name="sqlMapClient">
<ref local="sqlMapClient"/>
</property>
</bean>
</beans>
I have followed the tutorial of Serge Tahe and I think I included all necessary library in the classpath:
commons-pool.jar
commons-dbcp.jar
ibatis-common-2.jar
ibatis-sqlmap-2.jar
spring-*.jar
xerces.jar
etc...
I hope that you could help me !
thanks
Julien
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