lsd747490952
lsd747490952
2012-06-26 10:50

spring3.1.1+ibatis3.1.1+struts2.2.3框架搭建报错

已采纳

我的 applicationContext.xml

 

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:p="http://www.springframework.org/schema/p"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xmlns:context="http://www.springframework.org/schema/context"
 xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-3.1.xsd
   http://www.springframework.org/schema/tx
   http://www.springframework.org/schema/tx/spring-tx-3.1.xsd"
   default-autowire="byName">
 
 <!--配置文件导入 -->
 <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="location">
   <value>classpath:jdbc.properties</value>
  </property>
 </bean>

 <!--  数据源 -->
 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
  <property name="driverClassName" value="${mysql.driver}"></property>
  <property name="url" value="${mysql.url}"></property>
  <property name="username" value="${mysql.user}"></property>
  <property name="password" value="${mysql.password}"></property>
  <property name="maxActive" value="${mysql.maxActive}"></property>
  <property name="maxIdle" value="${mysql.maxIdle}"></property>
  <property name="maxWait" value="${mysql.maxWait}"></property>
 </bean>
 
 <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
  <property name="configLocation" value="classpath:sqlmapConfig.xml" />
     <property name="dataSource" ref="dataSource" />   
 </bean>

 


 
 <bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
  <property name="sqlMapClient" ref="sqlMapClient" />
 </bean>
   
</beans>

 

 

 

 

这是启动项目报的错:

 

2012-6-26 10:41:14 org.apache.catalina.core.AprLifecycleListener init
信息: Loaded APR based Apache Tomcat Native library 1.1.20.
2012-6-26 10:41:14 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2012-6-26 10:41:16 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
2012-6-26 10:41:16 org.apache.coyote.http11.Http11NioProtocol init
信息: Initializing Coyote HTTP/1.1 on http-8085
2012-6-26 10:41:16 org.apache.coyote.ajp.AjpAprProtocol init
信息: Initializing Coyote AJP/1.3 on ajp-8088
2012-6-26 10:41:16 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 2056 ms
2012-6-26 10:41:16 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2012-6-26 10:41:16 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.26
2012-6-26 10:41:16 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor host-manager.xml
2012-6-26 10:41:16 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor manager.xml
2012-6-26 10:41:16 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2012-6-26 10:41:16 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory examples
2012-6-26 10:41:17 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2012-6-26 10:41:17 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2012-6-26 10:41:17 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory mySSI
2012-6-26 10:41:17 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
2012-6-26 10:41:19 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlMapClient' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [sqlmapConfig.xml]; nested exception is com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: Element type "sqlMap" must be declared.
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
 at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
 at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041)
 at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964)
 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
 at org.apache.catalina.core.StandardService.start(StandardService.java:519)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [sqlmapConfig.xml]; nested exception is com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: Element type "sqlMap" must be declared.
 at org.springframework.orm.ibatis.SqlMapClientFactoryBean.buildSqlMapClient(SqlMapClientFactoryBean.java:341)
 at org.springframework.orm.ibatis.SqlMapClientFactoryBean.afterPropertiesSet(SqlMapClientFactoryBean.java:291)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
 ... 36 more
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: org.xml.sax.SAXParseException: Element type "sqlMap" must be declared.
 at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:62)
 at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:106)
 at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:95)
 at org.springframework.orm.ibatis.SqlMapClientFactoryBean.buildSqlMapClient(SqlMapClientFactoryBean.java:338)
 ... 39 more
Caused by: org.xml.sax.SAXParseException: Element type "sqlMap" must be declared.
 at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
 at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
 at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
 at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
 at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:1929)
 at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:785)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2756)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
 at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
 at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
 at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
 at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:232)
 at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
 at com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java:189)
 at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:59)
 ... 42 more
2012-6-26 10:41:19 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2012-6-26 10:41:19 org.apache.catalina.core.StandardContext start
严重: Context [/mySSI] startup failed due to previous errors
2012-6-26 10:41:19 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2012-6-26 10:41:19 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: A web application registered the JBDC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

 

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

5条回答

  • aa1aa3 爱上一条鱼 9年前

    [code="java"]



    [/code]
    这个类里sqlMapClientTemplate有setSqlMapClient这个方法么?java代码里调用下sqlMapClientTemplate.getSqlMapClient()或者setSqlMapClient看看

    错误信息是说SqlMapClientTemplate里属性sqlMapClient的set方法不对啊

    点赞 评论 复制链接分享
  • mayufenga1 helloword321 9年前

    ibatis的xml文件解析不正确,

    点赞 评论 复制链接分享
  • aa1aa3 爱上一条鱼 9年前

    头部的 http://mybatis.org/dtd/mybatis-map-3-config.dtd 没找到啊

    不是应该是xxxxx PUBLIC "-//ibatis.apache.org//DTD Config 3.0//EN"

    "http://ibatis.apache.org/dtd/ibatis-3-config.dtd"

    点赞 评论 复制链接分享
  • aa1aa3 爱上一条鱼 9年前

    [code="java"] Error creating bean with name 'sqlMapClient' defined in class path resource [applicationContext.xml][/code] --》 sqlMapClient这个类类初始化挂了么。。。
    [code="java"]
    NestedIOException: Failed to parse config resource: class path resource [sqlmapConfig.xml];[/code] --》 class path resource [sqlmapConfig.xml]这xml初始化挂了

    [code="java"] Element type "sqlMap" must be declared.[/code] --》 sqlMap必须声明

    sqlmapConfig.xml头上加上这个试试

    [code="java"]<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">[/code]

    点赞 评论 复制链接分享
  • works001 works001 9年前

    试下:
    把ibatis头部

    [code="java"]<!DOCTYPE sqlMapConfig
    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
    "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">[/code]

    改为

    [code="java"]<!DOCTYPE sqlMapConfig
    PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
    "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">[/code]

    点赞 评论 复制链接分享

相关推荐