Google Apps Engine上的Spring + Hibernate错误(java.lang.NoClassDefFoundError:org / objectweb / asm / ClassWriter)

时间:2012-12-14 04:33:02

标签: spring hibernate google-app-engine

我使用spring + spring security + hibernate在netbeans中开发应用程序并在tomcat中运行。我试图将这个项目移动到谷歌应用引擎,所以我决定将它移动到日食,因为我认为考虑到eclipse有GAE的插件更容易。

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V
    Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V

这是我的调度员servlet

    <?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-3.0.xsd">

        <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />

        <bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
            <property name="driverClassName" value="org.springframework.jdbc.datasource.DriverManagerDataSource"/>
            <property name="url" value="jdbc:google:rdbms://instancename/databasename"/>

        </bean>



        <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
            <property name="dataSource" ref="myDataSource" />
            <property name="annotatedClasses">
                <list>
                    <value>com.pulsa.bean.User</value>
                    <value>com.pulsa.bean.Customer</value>
                    <value>com.pulsa.bean.TableID</value>
                    <value>com.pulsa.bean.Balance</value>
                    <value>com.pulsa.bean.Capital</value>
                    <value>com.pulsa.bean.Contact</value>
                    <value>com.pulsa.bean.Product</value>
                    <value>com.pulsa.bean.Provider</value>
                    <value>com.pulsa.bean.Supplier</value>
                    <value>com.pulsa.bean.Transactions</value>
                </list>
            </property> 
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
                    <prop key="hibernate.show_sql">true</prop>
                    <prop key="hibernate.hbm2ddl.auto">create</prop>
                </props>
            </property>  
        </bean>

        <bean id="myUserDAO" class="com.dao.UserDAOImpl">
            <property name="sessionFactory" ref="mySessionFactory"/>
        </bean>

        <bean id="myTableIDDAO" class="com.dao.TableIDDAOImpl">
            <property name="sessionFactory" ref="mySessionFactory"/>
        </bean>


        <bean class="com.util.SessionHelper" >
            <property name="userDAO" ref="myUserDAO" />
        </bean>

        <bean id="myBalanceDAO" class="com.dao.BalanceDAOImpl">
            <property name="sessionFactory" ref="mySessionFactory"/>
        </bean>

        <bean id="myCapitalDAO" class="com.dao.CapitalDAOImpl">
            <property name="sessionFactory" ref="mySessionFactory"/>
            <property name="balanceDAO" ref="myBalanceDAO" />
        </bean>

        <bean id="myContactDAO" class="com.dao.ContactDAOImpl">
            <property name="sessionFactory" ref="mySessionFactory"/>
        </bean>

        <bean id="myProductDAO" class="com.dao.ProductDAOImpl">
            <property name="sessionFactory" ref="mySessionFactory"/>
        </bean>

        <bean id="myProviderDAO" class="com.dao.ProviderDAOImpl">
            <property name="sessionFactory" ref="mySessionFactory"/>
        </bean>

        <bean id="mySupplierDAO" class="com.dao.SupplierDAOImpl">
            <property name="sessionFactory" ref="mySessionFactory"/>
        </bean>

        <bean id="myTransactionDAO" class="com.dao.TransactionDAOImpl">
            <property name="sessionFactory" ref="mySessionFactory"/>
        </bean>

        <bean id="myCustomerDAO" class="com.dao.CustomerDAOImpl">
            <property name="sessionFactory" ref="mySessionFactory"/>
        </bean>

        <bean id="pageMaster" class="com.pulsa.bean.Page"></bean>

        <bean id="pageTransaction" class="com.pulsa.bean.TransactionPage"></bean>

        <bean name="/user/*.htm" class="com.controller.UserController" >
            <property name="userDAO" ref="myUserDAO" />
            <property name="page">
                <ref local="pageMaster"/>
            </property>
        </bean>

        <bean name="/supplier/*.htm" class="com.controller.SupplierController" >
            <property name="supplierDAO" ref="mySupplierDAO" />
            <property name="page">
                <ref local="pageMaster"/>
            </property>
        </bean>

        <bean name="/common/*.htm" class="com.controller.LoginController" >
            <property name="userDAO" ref="myUserDAO" />
        </bean>

        <bean name="/customer/*.htm" class="com.controller.CustomerController" >
            <property name="customerDAO" ref="myCustomerDAO" />
            <property name="userDAO" ref="myUserDAO" />
            <property name="contactDAO" ref="myContactDAO" />
            <property name="providerDAO" ref="myProviderDAO" />
            <property name="page">
                <ref local="pageMaster"/>
            </property>
        </bean>

        <bean name="/transaction/*.htm" class="com.controller.TransactionController" >
            <property name="transactionDAO" ref="myTransactionDAO" />
            <property name="productDAO" ref="myProductDAO" />
            <property name="customerDAO" ref="myCustomerDAO" />
            <property name="contactDAO" ref="myContactDAO" />
            <property name="tableIDDAO" ref="myTableIDDAO" />
            <property name="balanceDAO" ref="myBalanceDAO" />
            <property name="page">
                <ref local="pageTransaction"/>
            </property>
        </bean>

        <bean name="/product/*.htm" class="com.controller.ProductController" >
            <property name="productDAO" ref="myProductDAO" />
            <property name="userDAO" ref="myUserDAO" />
            <property name="supplierDAO" ref="mySupplierDAO" />
            <property name="providerDAO" ref="myProviderDAO" />
            <property name="page">
                <ref local="pageMaster"/>
            </property>
        </bean>

        <bean name="/balance/*.htm" class="com.controller.BalanceController" >
            <property name="balanceDAO" ref="myBalanceDAO" />
            <property name="capitalDAO" ref="myCapitalDAO" />
            <property name="transactionDAO" ref="myTransactionDAO" />
            <property name="userDAO" ref="myUserDAO" />
            <property name="supplierDAO" ref="mySupplierDAO" />
            <property name="page">
                <ref local="pageMaster"/>
            </property>
        </bean>

        <bean name="/capital/*.htm" class="com.controller.CapitalController" >
            <property name="balanceDAO" ref="myBalanceDAO" />
            <property name="capitalDAO" ref="myCapitalDAO" />
            <property name="transactionDAO" ref="myTransactionDAO" />
            <property name="userDAO" ref="myUserDAO" />
            <property name="supplierDAO" ref="mySupplierDAO" />
            <property name="tableIDDAO" ref="myTableIDDAO" />
            <property name="page">
                <ref local="pageMaster"/>
            </property>
        </bean>

        <bean name="/json/*.htm" class="com.controller.JSONController" >
            <property name="customerDAO" ref="myCustomerDAO" />
            <property name="productDAO" ref="myProductDAO" />
        </bean>

    </beans>

这是我的课程路径

    /webpulsa/war/WEB-INF/lib/aopalliance-1.0.jar
    /webpulsa/war/WEB-INF/lib/commons-logging-1.1.1.jar
    /webpulsa/war/WEB-INF/lib/spring-aop-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-asm-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-beans-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-context-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-context-support-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-core-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-expression-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-webmvc-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/antlr-2.7.6.jar
    /webpulsa/war/WEB-INF/lib/commons-collections-2.1.1.jar
    /webpulsa/war/WEB-INF/lib/dom4j-1.6.1.jar
    /webpulsa/war/WEB-INF/lib/ehcache-1.2.3.jar
    /webpulsa/war/WEB-INF/lib/hibernate-annotations.jar
    /webpulsa/war/WEB-INF/lib/hibernate-entitymanager.jar
    /webpulsa/war/WEB-INF/lib/hibernate-tools.jar
    /webpulsa/war/WEB-INF/lib/hibernate3.jar
    /webpulsa/war/WEB-INF/lib/jdbc2_0-stdext.jar
    /webpulsa/war/WEB-INF/lib/jackson-annotations-2.0.1.jar
    /webpulsa/war/WEB-INF/lib/jackson-core-2.0.1.jar
    /webpulsa/war/WEB-INF/lib/jackson-databind-2.0.1.jar
    /webpulsa/war/WEB-INF/lib/json-lib-2.2.2-jdk15.jar
    /webpulsa/war/WEB-INF/lib/spring-security-acl-3.1.0.RC2-sources.jar
    /webpulsa/war/WEB-INF/lib/spring-security-acl-3.1.0.RC2.jar
    /webpulsa/war/WEB-INF/lib/spring-security-aspects-3.1.0.RC2-sources.jar
    /webpulsa/war/WEB-INF/lib/spring-security-aspects-3.1.0.RC2.jar
    /webpulsa/war/WEB-INF/lib/spring-security-cas-3.1.0.RC2-sources.jar
    /webpulsa/war/WEB-INF/lib/spring-security-cas-3.1.0.RC2.jar
    /webpulsa/war/WEB-INF/lib/spring-security-config-3.1.0.RC2-sources.jar
    /webpulsa/war/WEB-INF/lib/spring-security-config-3.1.0.RC2.jar
    /webpulsa/war/WEB-INF/lib/spring-security-core-3.1.0.RC2-sources.jar
    /webpulsa/war/WEB-INF/lib/spring-security-core-3.1.0.RC2.jar
    /webpulsa/war/WEB-INF/lib/spring-security-ldap-3.1.0.RC2-sources.jar
    /webpulsa/war/WEB-INF/lib/spring-security-ldap-3.1.0.RC2.jar
    /webpulsa/war/WEB-INF/lib/spring-security-openid-3.1.0.RC2-sources.jar
    /webpulsa/war/WEB-INF/lib/spring-security-openid-3.1.0.RC2.jar
    /webpulsa/war/WEB-INF/lib/spring-security-taglibs-3.1.0.RC2-sources.jar
    /webpulsa/war/WEB-INF/lib/spring-security-taglibs-3.1.0.RC2.jar
    /webpulsa/war/WEB-INF/lib/spring-security-web-3.1.0.RC2-sources.jar
    /webpulsa/war/WEB-INF/lib/spring-security-web-3.1.0.RC2.jar
    /webpulsa/war/WEB-INF/lib/spring-orm-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-aspects-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-jdbc-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-jms-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-oxm-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-struts-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-test-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-tx-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/spring-webmvc-portlet-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/mysql-connector-java-5.1.17-bin.jar
    /webpulsa/war/WEB-INF/lib/spring-web-3.1.1.RELEASE.jar
    /webpulsa/war/WEB-INF/lib/hibernate-commons-annotations.jar
    /webpulsa/war/WEB-INF/lib/javassist.jar
    /webpulsa/war/WEB-INF/lib/cglib-2.2.jar
    /webpulsa/war/WEB-INF/lib/asm-attrs.jar
    /webpulsa/war/WEB-INF/lib/asm.jar

我的项目有什么问题吗?我也把这个lib放在我的App Engine lib / impl中,而且还没有工作......

ps:可能与Error : java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(I)V有关,但我仍然无法修复我的项目..请帮助..提前感谢。

1 个答案:

答案 0 :(得分:0)

java.lang.NoSuchMethodError(在您的情况下(java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V))表示类(ClassWriter)存在,但方法(在您的情况下:带有布尔参数的构造函数)不存在。< / p>

如果存在不兼容的库,则通常会发生此类错误:一个库需要lib B的x版本,但是你的版本是lib B.这两个版本不兼容。

如果您的项目是使用Netbeans运行的,而不是使用Eclipse运行,那么我猜您在将项目从一个IDE移动到另一个IDE时修改了库。

在你的情况下,来自DebuggingClassWriter的类cgilib-2.2.jar在其构造函数中调用来自ClassWriter的超类asm.jar的构造函数(带有一个布尔参数)(很遗憾,你没有指定了您使用的asm.jar的版本。 但我可以告诉你,例如asm-3.1.jar包含你需要的构造函数。

顺便说一句:我将cglib-nodep-2.2.jarasm-3.1.jar一起使用,并且有效