求解决org.springframework.beans.factory.BeanCreationException

问题描述

dwr和spring整合时出的问题,请问有谁知道这是怎么回事呢? 具体代码如下: dwr.xml <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.org/dwr/dwr20.dtd"><dwr><allow><!-- 用户信息 --><convert converter="beanmatch="com.tw.pojo.UserBean"></convert><!-- 组织信息 --><convert converter="bean"match="com.tw.pojo.OrgBean"></convert><!-- 用户DWR调用定义 --><create creator="spring" javascript="DWRUserDao"> <param name="beanName" value="userDao"/> </create><!-- 组织DWR调用定义 --><create creator="spring" javascript="DWROrgDao"> <param name="beanName" value="orgDao"/> </create></allow></dwr>UserDaoImpl.javapublic List getUserListInfo(String orgid) {Map map = new HashMap();map.put("orgid", orgid);try {List list = (List) this.getSqlMapClientTemplate().queryForList("getUserListInfo", map);if (list != null) {return list;}} catch (Exception e) {log.error("获取指定组织的所有直用户getUserListInfo:", e);e.printStackTrace();}return null;}applicationContext.xml <!-- 数据库公共DAO --><bean id="baseDao" class="com.tw.framework.base.db.BaseDaoOracle"scope="prototype"></bean><!-- 用户角色信息 --><bean id="userDao" class="com.tw.dao.impl.UserDaoImpl" scope="prototype"><property name="baseDao" ref="baseDao" /></bean><!-- 组织信息 --><bean id="orgDao" class="com.tw.dao.impl.OrgDaoImpl" scope="prototype"><property name="baseDao" ref="baseDao" /></bean>jsp代码<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/DWRUserDao.js'></script><script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/DWROrgDao.js'></script><script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script><script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'></script><script language="javascript">//初始化页面中各控制的值javascript:dwr.engine.setAsync(false);function loadControls(){loadSelectAreaList();}//Load所有公司信息,并将之设置到公司列表控制function loadSelectAreaList(){document.all.ddlArea.length = 1;//设置公司列表控制 DWROrgDao.getCompanyList(true,function(list){ for(var i=0;i<list.length;i++) { var li = document.createElement("OPTION"); li.text = list[i].orgName; li.value = list[i].parentOrgId; document.all.ddlArea.options.add(li); } });}</script>可是运行的时候控制台报错org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: sqlMapClient is requiredat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)at java.security.AccessController.doPrivileged(Native Method)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:283)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)at org.directwebremoting.spring.SpringCreator.getInstance(SpringCreator.java:144)at org.directwebremoting.spring.SpringCreator.getType(SpringCreator.java:106)at org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:118)at org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:100)at org.directwebremoting.impl.DwrXmlConfigurator.loadCreate(DwrXmlConfigurator.java:274)at org.directwebremoting.impl.DwrXmlConfigurator.loadAllows(DwrXmlConfigurator.java:224)at org.directwebremoting.impl.DwrXmlConfigurator.configure(DwrXmlConfigurator.java:170)at org.directwebremoting.impl.ContainerUtil.configureFromDefaultDwrXml(ContainerUtil.java:264)at org.directwebremoting.impl.ContainerUtil.configureContainerFully(ContainerUtil.java:421)at org.directwebremoting.servlet.DwrServlet.init(DwrServlet.java:79)at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)at java.lang.Thread.run(Thread.java:619)Caused by: java.lang.IllegalArgumentException: sqlMapClient is requiredat org.springframework.orm.ibatis.SqlMapClientTemplate.afterPropertiesSet(SqlMapClientTemplate.java:144)at org.springframework.orm.ibatis.support.SqlMapClientDaoSupport.checkDaoConfig(SqlMapClientDaoSupport.java:104)at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)... 30 more2011-08-12 09:34:34 org.directwebremoting.util.CommonsLoggingOutput.error(CommonsLoggingOutput.java:83) [ERROR] Error loading class for creator 'SpringCreator[DWROrgDao]'.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orgDao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: sqlMapClient is requiredat org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)at java.security.AccessController.doPrivileged(Native Method)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:283)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:880)at org.directwebremoting.spring.SpringCreator.getInstance(SpringCreator.java:144)at org.directwebremoting.spring.SpringCreator.getType(SpringCreator.java:106)at org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:118)at org.directwebremoting.impl.DefaultCreatorManager.addCreator(DefaultCreatorManager.java:100)at org.directwebremoting.impl.DwrXmlConfigurator.loadCreate(DwrXmlConfigurator.java:274)at org.directwebremoting.impl.DwrXmlConfigurator.loadAllows(DwrXmlConfigurator.java:224)at org.directwebremoting.impl.DwrXmlConfigurator.configure(DwrXmlConfigurator.java:170)at org.directwebremoting.impl.ContainerUtil.configureFromDefaultDwrXml(ContainerUtil.java:264)at org.directwebremoting.impl.ContainerUtil.configureContainerFully(ContainerUtil.java:421)at org.directwebremoting.servlet.DwrServlet.init(DwrServlet.java:79)at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)at java.lang.Thread.run(Thread.java:619)Caused by: java.lang.IllegalArgumentException: sqlMapClient is requiredat org.springframework.orm.ibatis.SqlMapClientTemplate.afterPropertiesSet(SqlMapClientTemplate.java:144)at org.springframework.orm.ibatis.support.SqlMapClientDaoSupport.checkDaoConfig(SqlMapClientDaoSupport.java:104)at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)... 30 more 问题补充:cloverprince 写道

解决方案

直接在SqlMapClientFactoryBean类的方法:protected SqlMapClient buildSqlMapClient(Resource[] configLocations, Resource[] mappingLocations, Properties properties)throws IOException {设置断点调试一下,看看到底传入的“configLocations”哪里不对。
解决方案二:
我把自己的配置改了,放到web-inf下,都是可以的啊:web.xml<context-param><param-name>contextConfigLocation</param-name><param-value>/WEB-INF/applicationContext.xml</param-value></context-param>applicationContext.xml<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource"/><property name="configLocation" value="/WEB-INF/mybatis-config.xml"/></bean>日志出来正常:2011-08-12 13:07:58,593 WEB-MES [main] DEBUG o.m.s.SqlSessionFactoryBean - Parsed configuration file: 'ServletContext resource [/WEB-INF/mybatis-config.xml]'检查一下你文件的位置!
解决方案三:
这样, <property name="configLocation" value="/WEB-INF/sqlMapConfig.xml" /> “WEB-INF”前面加个斜杠。
解决方案四:
sqlMapConfig.xml和spring配置在同一目录的话,直接把 <property name="configLocation" value="WEB-INF/sqlMapConfig.xml" /> 改成: <property name="configLocation" value="sqlMapConfig.xml" /> 再试试。
解决方案五:
引用这个是公司的项目,不能这样子改配置的,有其他的办法米? 你spring的配置文件放在哪里?
解决方案六:
这孩子,一碰到问题就问
解决方案七:
<property name="configLocation" value="WEB-INF/sqlMapConfig.xml" /> 这个设置的地址不对,这样不是绝对路径,spring找不到。你把sqlMapConfig.xml放到classes里面去,然后把这个改成:<property name="configLocation" value="classpath:sqlMapConfig.xml" />
解决方案八:
引用我用的是ibatis 你这个是mybatis的配置,有区别吗?ibatis需要怎么配置呢? 我有用到 原理的是一样的。如果是ibatis你要注入的是:org.springframework.orm.ibatis.SqlMapClientFactoryBean把我上面的SqlSessionFactoryBean替换就好了。
解决方案九:
你的DAO为什么没有注入sqlSessionFactory呢?我一般都是这样的:<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource"/><property name="configLocation" value="classpath:mybatis-config.xml"/></bean><bean id="baseMybatisDao" class="com.realtech.mes.dao.BaseMybatisDAO"> <property name="sqlSessionFactory" ref="sqlSessionFactory"/> </bean>
解决方案十:
就是它说的意思,你这个userDao需要一个sqlMapClient(应该是通过属性设置)。你没有设置。于是在调用初始化函数的时候出错了。

时间: 2024-09-12 08:26:52

求解决org.springframework.beans.factory.BeanCreationException的相关文章

跪求大神帮解决org.springframework.beans.factory.BeanCreationException: Error creating b

问题描述 org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0':Initializationofbeanfailed;nestedexceptionisorg.springframework.beans.factory.Be

急死人了,SSH整合报错,高手进来帮忙解决啊,org.springframework.beans.factory.BeanCreationException

问题描述 2010-11-13 12:37:39 org.apache.catalina.core.AprLifecycleListener init信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:InstalledMyEclipsebin;D:In

org.springframework.beans.factory.BeanCreationException: Error creating bean wit

问题描述 org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'txEasyjwebProcessorAdvice':Cannotresolvereferencetobean'transactionManager'whilesettingbeanproperty'transactionManager';nestedexceptionisorg.springframework.beans.

ssh整合出错:org.springframework.beans.factory.BeanCreationException: Error creating

问题描述 applicationContent.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:context="http://w

javase-关于Myeclipse的错误org.springframework.beans.factory.BeanCreationException

问题描述 关于Myeclipse的错误org.springframework.beans.factory.BeanCreationException 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreati

spring hibernate-org.springframework.beans.factory.BeanCreationException

问题描述 org.springframework.beans.factory.BeanCreationException applicationContext.xml文件 <?xml version=""1.0"" encoding=""UTF-8""?> xmlns=""http://www.springframework.org/schema/beans"" xmlns:

springmvc-org.springframework.beans.factory.BeanCreationException:

问题描述 org.springframework.beans.factory.BeanCreationException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in class path resource [application.xml]: Error setting property values; nested

求解:org.springframework.beans.factory.BeanCreationException

问题描述 配置文件<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframew

ibatis和Spring整合抛org.springframework.beans.factory.BeanCreationException

问题描述 『spring2.5和Ibatis2整合』spring配置文件如下:<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:p="http://