创建名为'sessionFactory'的bean时出错

时间:2010-03-30 02:33:34

标签: java spring

您好我在运行我的应用程序时遇到以下异常 我的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"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">


    <bean id="dataSource"
        class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName"
            value="com.mysql.jdbc.Driver">
        </property>
        <property name="url" value="jdbc:mysql://localhost/SureshDB"></property>
        <property name="username" value="root"></property>
        <property name="password" value="root"></property>
    </bean>
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQLDialect
                </prop>
            </props>
        </property>
        <property name="mappingResources">
            <list>
                <value>com/jsfcompref/register/UserTa.hbm.xml</value></list>
        </property></bean>
    <bean id="UserTaDAO" class="com.jsfcompref.register.UserTaDAO">
        <property name="sessionFactory">
            <ref bean="sessionFactory" />
        </property>
    </bean>

    <bean id="UserTaService" class="com.jsfcompref.register.UserTaServiceImpl">
        <property name="userTaDao">
            <ref bean="UserTaDAO"/>
        </property>
    </bean>

    </beans>
  

使用名称创建bean时出错   'classFactory'在类路径中定义   resource [applicationContext.xml]:   调用init方法失败;   嵌套异常是   java.lang.NoSuchMethodError:   org.objectweb.asm.ClassVisitor.visit(IILjava /郎/字符串; Ljava /郎/字符串; [Ljava /郎/字符串; Ljava /郎/字符串;)V

任何建议都是健全的

1 个答案:

答案 0 :(得分:5)

您的例外

  

嵌套异常是java.lang.NoSuchMethodError:org.objectweb.asm.ClassVisitor.visit

Hibernate取决于asm

转到以下文件夹中的Spring安装目录和包含所有jar

<SPRING_HOME>/lib/asm/
<SPRING_HOME>/lib/dom4j/
<SPRING_HOME>/lib/antlr/
<SPRING_HOME>/lib/jakarta-commons/
<SPRING_HOME>/lib/javassist
<SPRING_HOME>/lib/cglib/
<SPRING_HOME>/lib/hibernate // without hibernate-entitymanager.jar
<SPRING_HOME>/lib/slf4j/
<SPRING_HOME>/lib/j2ee/persistence.jar
<SPRING_HOME>/lib/j2ee/jta.jar

我希望现在运行正常

如果您不想看到新的异常,请不要忘记包含MySQL驱动程序