`

MyEclipse 开发 SSH 应用中的两个常见错误的解决方法

阅读更多
关于MyEclipse 6.0.0 GA开发SSH应用的
Error Creating SessionFactory java.lang.SecurityException: class"org.apache.commons.collections.SequencedHashMap"'异常的解决方案

昨天有读者提到用 MyEclipse 6.0.0 开发 Struts + Hibernate应用的时候,单独测试Hibernate的类没有问题,但是当Web层和Struts整合后,就抛出如下异常:
        %%%%Error Creating SessionFactory %%%%  java.lang.SecurityException: class"org.apache.commons.collections.SequencedHashMap"'s signer informationdoes not match signer information of other classes in the same package
        因为我用的6.0.1,所以怎么也没出现这个异常。后来Google搜到很多人遇到了这个故障,猜测是commons-collections.jar的问题,可能和MyEclipse 6.0.0自带的包有问题导致。例如下面的是一个解决方案:http://ttitfly.iteye.com/blog/131955
        
        解决方案:
        1)下载 MyEclipse 6.0.1 来开发;
        2)或者去http://commons.apache.org/collections/ 下载一个新的包,把原来的commons-collections-xxx.jar给删了,然后用新的包替换。注意:一定要到应用的发布目录去做这个工作,而且替换后不能重新发布应用,然后立即重启Tomcat再测试。
        
        如果再报下面的错误:
ERROR [org.hibernate.proxy.BasicLazyInitializer] - CGLIB Enhancement failed: dao.User 
java.lang.NoSuchMethodError:org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
at net.sf.cglib.core.ClassEmitter.begin_class(ClassEmitter.java:77) 

则是:
Spring 和 Hibernate 共用的一些 jar 文件发生了版本冲突, 删除 WEB-INF/lib/asm-2.2.3.jar即可



MyEclipse 开发 SSH 整合时 java.lang.NoSuchMethodError: org.objectweb.asm.ClassVisitor.visit 解决方案

这篇文章解决了问题, 核心提示:
        2007-08-08 发现用 MyEclipse 5.5 做 Struts 1.2 + Spring 2.0 + Hibernate 3.1 整合时启动过程中报如下的错误:
                       
2007-08-08 15:36:17,406 ERROR [org.hibernate.proxy.BasicLazyInitializer] - CGLIB Enhancement failed: dao.User
java.lang.NoSuchMethodError:org.objectweb.asm.ClassVisitor.visit(IILjava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)V
at net.sf.cglib.core.ClassEmitter.begin_class(ClassEmitter.java:77)
        Spring 和 Hibernate 共用的一些 jar 文件发生了版本冲突, 删除 WEB-INF/lib/asm-2.2.3.jar 然后重启 Tomcat.
        asm-2.2.3.jar
       asm.jar
       asm-attrs.jar
      asm-commons-2.2.3.jar
      asm-util-2.2.3.jar
                       
       
        原文参考: http://heweiya.iteye.com/blog/101575
                       
下面是一个完整的出错信息:
      
 2007-10-7 10:44:42 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listenerinstance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Errorcreating bean with name 'entityManagerFactory' defined inServletContext resource [/WEB-INF/classes/applicationContext.xml]:Invocation of init method failed; nested exception isjava.lang.ExceptionInInitializerError
Caused by: java.lang.ExceptionInInitializerError
    at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)
    at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
    at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)
    at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)
    at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
    at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
    at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
    at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
    at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
    at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
atorg.springframework.orm.jpa.LocalEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalEntityManagerFactoryBean.java:91)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:251)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1202)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:428)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
atorg.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:284)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.SecurityException: class"org.objectweb.asm.CodeVisitor"'s signer information does not matchsigner information of other classes in the same package
    at java.lang.ClassLoader.checkCerts(Unknown Source)
    at java.lang.ClassLoader.preDefineClass(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1817)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1325)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:165)
    at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
    at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
    at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
    at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
    at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
    ... 54 more
2007-10-7 10:44:42 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2007-10-7 10:44:42 org.apache.catalina.core.StandardContext start
严重: Context [/d1] startup failed due to previous errors
2007-10-7 10:44:42 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2007-10-7 10:44:42 org.apache.catalina.loader.WebappClassLoader loadClass
信息: Illegal access: this web application instance has been stoppedalready. Could not load java.net.BindException. The eventual followingstack trace is caused by an error thrown for debugging purposes as wellas to attempt to terminate the thread which caused the illegal access,and has no functional impact.
java.lang.IllegalStateException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1244)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at com.mysql.jdbc.CommunicationsException.<init>(CommunicationsException.java:155)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2652)
    at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:1345)
    at com.mysql.jdbc.Connection.realClose(Connection.java:4731)
    at com.mysql.jdbc.Connection.cleanup(Connection.java:2034)
    at com.mysql.jdbc.Connection.finalize(Connection.java:3244)
    at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
    at java.lang.ref.Finalizer.runFinalizer(Unknown Source)
    at java.lang.ref.Finalizer.access$100(Unknown Source)
    at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)
2007-10-7 10:44:42 org.apache.catalina.loader.WebappClassLoader loadClass
信息: Illegal access: this web application instance has been stoppedalready. Could not load com.mysql.jdbc.Messages. The eventual followingstack trace is caused by an error thrown for debugging purposes as wellas to attempt to terminate the thread which caused the illegal access,and has no functional impact.
java.lang.IllegalStateException
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1244)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at com.mysql.jdbc.CommunicationsException.<init>(CommunicationsException.java:174)
    at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2652)
    at com.mysql.jdbc.MysqlIO.quit(MysqlIO.java:1345)
    at com.mysql.jdbc.Connection.realClose(Connection.java:4731)
    at com.mysql.jdbc.Connection.cleanup(Connection.java:2034)
    at com.mysql.jdbc.Connection.finalize(Connection.java:3244)
    at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
    at java.lang.ref.Finalizer.runFinalizer(Unknown Source)
    at java.lang.ref.Finalizer.access$100(Unknown Source)
    at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source) 
分享到:
评论

相关推荐

    SSH_常见错误与解决方案

    ### SSH常见错误与解决方案 ...通过上述步骤,你可以有效解决MyEclipse在配置SSH框架过程中遇到的常见错误,确保项目能够顺利运行。在处理此类问题时,保持耐心,细致检查每个依赖关系,是成功的关键。

    将MyEclipse项目导入eclipse

    - 若上述方法都无法解决问题,可以查看Eclipse的“Problems”视图中的错误信息,以便更准确地定位问题所在。 通过以上步骤,您可以成功地将MyEclipse项目导入到Eclipse中,并解决导入后可能遇到的各种问题。需要...

    手把手教你实现第一个SSH项目

    SSH 是一种常见的Java Web 开发框架组合,用于构建企业级应用。下面将详细解释每个步骤涉及的知识点: 1. **Struts**: - **ActionForm**:在Struts中,ActionForm是用于在Action类和JSP页面之间传递数据的类。在...

    MyEclipse 使用指南

    ### MyEclipse 使用指南知识点详解 ...以上内容总结了《MyEclipse 使用指南》中提到的主要知识点和技术细节,旨在帮助开发者掌握MyEclipse的核心功能,并能运用到实际项目开发中去。希望这些信息对您有所帮助。

    SSH整合框架

    这种组合在Java Web开发中非常常见,因为它们各自解决了Web应用开发中的不同问题: - **Struts**:负责MVC(Model-View-Controller)架构的实现,主要处理控制器部分,管理业务逻辑与用户交互。 - **Spring**:提供...

    SSH框架配置步骤

    本文旨在详细介绍如何配置SSH(Struts、Spring、Hibernate)三大框架,并确保这些框架能够协同工作,从而为Web应用开发提供强有力的支持。通过逐步指导的方式,帮助读者理解每个配置步骤背后的原理与实践。 #### 二...

    struts-hibernate-sprint开发详解 乱码问题 连接池

    在Java Web开发中,Struts、Hibernate和Spring的整合是一个常见的技术栈,称为SSH框架。本文将详细解析如何使用SSH框架进行开发,并解决乱码和连接池的问题。 首先,配置数据库是开发的第一步。在MyEclipse中,可以...

    Java项目使用小知识

    SSH(Spring、Struts、Hibernate)是一个常见的Java企业级应用开发框架组合。当出现"Http 404 Servlet action is not available"这样的错误时,通常表示Spring无法找到对应的Action。这可能是由于配置文件(如`...

    j2ee SSH 整合笔记,献于新手。。

    ### J2EE SSH整合知识点详解 #### 一、概述 SSH框架是指Spring、Struts以及Hibernate这三个开源...通过以上详细的介绍,希望初学者能够对如何整合SSH框架有一个较为全面的认识,并能够顺利地在自己的项目中应用起来。

Global site tag (gtag.js) - Google Analytics