当前位置: 代码迷 >> Java Web开发 >> 新人小菜 ssh框架出错org.springframework.beans.factory.BeanCreationException
  详细解决方案

新人小菜 ssh框架出错org.springframework.beans.factory.BeanCreationException

热度:503   发布时间:2016-04-13 22:16:03.0
新人小菜求助 ssh框架出错org.springframework.beans.factory.BeanCreationException:在线等
如果我给的出错信息不齐的话,说一下,我会发上来,多谢各位大神


出错信息
严重: 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 'mallUserDAOImpl' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
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$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
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.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3827)


我的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:ctx="http://www.springframework.org/schema/context"
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/context
        http://www.springframework.org/schema/context/spring-context-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
">
<ctx:component-scan base-package="net.dfrz.sh1409" />
<ctx:property-placeholder location="classpath:jdbc.properties" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
<!--prop key="hibernate.hbm2ddl.auto">update</prop -->
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">false</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>net/dfrz/sh1409/domain/Malluser.hbm.xml</value>
</list>
</property>
</bean>
<bean id="hibTxManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:annotation-driven transaction-manager="hibTxManager" />
<!-- 配置一个hibernateTemplate -->
<bean id="hibernateDaoSupport"
class="org.springframework.orm.hibernate3.support.HibernateDaoSupport"
abstract="true">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="mallUserDAOImpl" class="net.dfrz.sh1409.dao.impl.MallUserDAOImpl"
parent="hibernateDaoSupport" />
</beans>


malluserdaoimpl

package net.dfrz.sh1409.dao.impl;
import java.util.HashMap;
import java.util.List;

import net.dfrz.sh1409.dao.MallUserDAO;
import net.dfrz.sh1409.domain.Malluser;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Component;
@Component("mallUserDAOImpl")
public class MallUserDAOImpl extends HibernateDaoSupport implements MallUserDAO {

@Override  
 public HashMap<String,String> save(Malluser user,String pwd2,String code) {  
int i;
String errname=null;
String errpwd=null;
String errphone=null;
String errcode=null;
HashMap<String,String> err =  new HashMap<String, String>();
if(user.getUname().matches("^[A-Za-z0-9]{6,12}$"))
i=0;
else 
{
errname="账号长度为6-12位,英文开头,支持英文、数字";
err.put("errname", errname);
}
if(user.getPwd().matches("^{6,20}$"))
if(user.getPwd().equals(pwd2))
i=0;
else 
{
errpwd="密码不一致";
err.put("errpwd", errpwd);
}
else 
{
errpwd="密码长度应为6-20;";
err.put("errpwd", errpwd);
}
if(user.getPhone().matches("^((\\(\\d{3}\\))|(\\d{3}\\-))?13\\d{9}$"))
i=0;
else 
{
errphone="手机格式错误";
err.put("errphone", errphone);
}
if(code.equals("12345"))
i=0;
else 
{
errcode="短信验证码错误";
err.put("errcode", errcode);
}
if(errname!=null||errpwd!=null||errphone!=null||errcode!=null)
{
this.getHibernateTemplate().save(user);  
}
else 
     return err;
return null;
 }  
// 删除记录(按照实体删除)  
    @Override  
    public void delete(Malluser entity) {  
        // TODO Auto-generated method stub  
        this.getHibernateTemplate().delete(entity);  
  
    }  
  
    // 删除记录(按id删除),不成功  
    //  
    @Override  
    public void deleteById(int id) {  
        // TODO Auto-generated method stub  
        // this.getHibernateTemplate().delete(entity);  
    }  
  
    // 查询所有的记录  
    @Override  
    public List<Malluser> selectAll() {  
        // TODO Auto-generated method stub  
        List<Malluser> entities = this.getHibernateTemplate().find(  
                "from Customer");  
        return entities;  
    }  
  
//  按照id查找记录  
    @Override  
    public Malluser selectById(int id) {  
        List<Malluser> entities=this.getHibernateTemplate().find("from Customer where id="+id);  
        if(entities.size()>0){  
         Malluser entity=entities.get(0);  
            return entity;  
        }  
        return null;  
    } 
  
//  更新的方法  
    @Override  
    public void update(Malluser entity) {  
        // TODO Auto-generated method stub  
        this.getHibernateTemplate().update(entity);  
    }  
    }  



------解决思路----------------------
你asm的jar包版本应该是低了,换个高版本的试试
  相关解决方案