当前位置:编程学习 > JAVA >>

求助spring异常,org.springframework.beans.factory.BeanCreationException:

我用的版本是
Struts2.3.8 +Spring 3.2+ Hibernate4.1.9 ,出现如下异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactoryMms' defined in ServletContext resource [/WEB-INF/classes/spring/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/objectweb/asm/Type

如何解决,求大侠帮助! --------------------编程问答-------------------- org/objectweb/asm/Type 没找到这个类,看包导了没,找找有这个类没.. --------------------编程问答-------------------- 发配置文件。。
spring的配置、 --------------------编程问答-------------------- 回复2楼:asm-3.3.jar的包我是导入的
--------------------编程问答-------------------- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'queryListAction' defined in file [D:\Tomcat 7.0\webapps\xjcweb\WEB-INF\classes\spring\applicationContext-datasource.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.web.usr.action.QueryListAction]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:955)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:901)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:574)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4797)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1114)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1673)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.web.usr.action.QueryListAction]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:71)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:948)
... 27 more
Caused by: java.lang.NullPointerException
at org.apache.struts2.ServletActionContext.getRequest(ServletActionContext.java:112)
at com.web.usr.action.QueryListAction.<init>(QueryListAction.java:22)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
... 29 more
六月 03, 2013 7:26:15 下午 org.apache.catalina.core.StandardContext listenerStart
SEVERE: 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 'queryListAction' defined in file [D:\Tomcat 7.0\webapps\xjcweb\WEB-INF\classes\spring\applicationContext-datasource.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.web.usr.action.QueryListAction]: Constructor threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:955)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:901)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(Defau --------------------编程问答-------------------- <!-- 服务层的注入 -->
<bean id="userService" class="com.web.usr.service.impl.UserServiceImpl">
<property name="userDAO" ref="userDAO"></property>
</bean>
   <bean id="searchService" class="com.web.sch.service.impl.SearchServiceImpl">
<property name="searchDao" ref="searchDao"></property>
</bean>
<!-- action方法的注入 -->
<bean id="loginAction" class="com.web.usr.action.LoginAction">
<property name="userService" ref="userService"></property>
</bean>
<bean id="registerAction" class="com.web.usr.action.RegisterAction">
<property name="userService" ref="userService"></property>
</bean>

<bean id="queryListAction" class="com.web.usr.action.QueryListAction">
<property name="searchService" ref="searchService"></property>
</bean>  --------------------编程问答--------------------
引用 2 楼 AA5279AA 的回复:
发配置文件。。
spring的配置、

配置呢? --------------------编程问答-------------------- <?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
default-autowire="byName" default-lazy-init="false">

<!-- 数据源定义 -->

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url"
value="jdbc:mysql://192.168.0.119:3306/tx?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull" />
<property name="username" value="root" />
<property name="password" value="1234" />

</bean>

<!-- log4jdbc可以将数据源执行的sql将占位符?替换成字符,并以日志打印出来. log4j配置: log4j.logger.jdbc.sqltiming=INFO 
详情请看: http://code.google.com/p/rapid-framework/wiki/log4jdbc 如oracle示例: 原来的sql: 
select * from user where birth_date = ? and username = ? and age > ? 转换后sql: 
select * from user where birth_date = to_date('2010-08-13','yyyy-mm-dd') 
and username = 'Bonnie' and age > 20 -->
<bean id="log4jdbcInterceptor" class="net.sf.log4jdbc.DataSourceSpyInterceptor" />
<bean id="dataSourceLog4jdbcAutoProxyCreator"
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="interceptorNames">
<list>
<value>log4jdbcInterceptor</value>
</list>
</property>
<property name="beanNames">
<list>
<value>dataSource</value>
</list>
</property>
</bean>

<!-- <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> 
<property name="jndiName"><value>java:comp/env/jdbc/ds</value></property> 
</bean> -->

<!-- 用于测试或demo的hsql的内存dataSource,可以在创建数据库时运行指定的初始化sql语句,如建表,插入测试数据,sql语句之间使用分号";"分隔 -->
<!-- <bean id="dataSource" class="cn.org.rapid_framework.test.hsql.HSQLMemDataSourceFactoryBean"> 
<property name="encoding" value="UTF-8"/> <property name="scriptLocations"> 
<value>classpath*:hsql_test_scripts.sql</value> </property> <property name="sqlScript"> 
<value> create table blog(id int); insert into blog values (1); </value> 
</property> </bean> -->
<!-- 读取ibatis配置文件 -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="configLocation">
<value>classpath:SqlMapConfig.xml</value>
</property>
</bean>

<!-- 实现层的注入 -->
<bean id="userDAO" class="com.web.usr.dao.impl.UserDAOImpl">
<property name="client">
<ref local="sqlMapClient" />
</property>
</bean>
<bean id="searchDao" class="com.web.usr.dao.impl.SearchDaoImpl">
<property name="client">
<ref local="sqlMapClient" />
</property>
</bean>

<!-- 服务层的注入 -->
<bean id="userService" class="com.web.usr.service.impl.UserServiceImpl">
<property name="userDAO" ref="userDAO"></property>
</bean>
<bean id="searchService" class="com.web.usr.service.impl.SearchServiceImpl">
<property name="searchDao" ref="searchDao"></property>
</bean>
<!-- action方法的注入 -->
<bean id="loginAction" class="com.web.usr.action.LoginAction">
<property name="userService" ref="userService"></property>
</bean>
<bean id="registerAction" class="com.web.usr.action.RegisterAction">
<property name="userService" ref="userService"></property>
</bean>
<!-- 用户查询 更新  删除 ACTION方法的注入 -->

<bean id="queryUserAction" class="com.web.usr.action.QueryUserAction">
<property name="userService" ref="userService"></property>
</bean>
<bean id="updateAction" class="com.web.usr.action.UpdateAction">
<property name="userService" ref="userService"></property>
</bean>
<bean id="deleteAction" class="com.web.usr.action.DeleteAction">
<property name="userService" ref="userService"></property>
</bean>
<!-- 工程详细内容查询 ACTION方法的注入 -->
<bean id="queryAction" class="com.web.usr.action.QueryAction">
<property name="searchService" ref="searchService"></property>
</bean>
</beans>
补充:Java ,  Java相关
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,