gpt4 book ai didi

hibernate - java.lang.VerifyError : class net. sf.cglib.core.DebuggingClassWriter

转载 作者:IT老高 更新时间:2023-10-28 13:54:14 25 4
gpt4 key购买 nike

我正在尝试对源自教程的一些非常简单的 Hibernate 代码进行原型(prototype)设计,但遇到了一个我在 cglib2 中无法深入理解的错误(完整的堆栈跟踪在本文末尾)。我可能正在尝试根据我的简单 main() 和 bean XML(如下)创建“productBoProxy”。

我尝试了许多不同版本的 cglib 都无济于事。我非常感谢任何可以帮助我找到解决此问题的正确途径的人。

App.java:

ApplicationContext appContext
= new ClassPathXmlApplicationContext( "resources/config/BeanLocations.xml" );
...
productBo = ( ProductBo ) appContext.getBean( "productBoProxy" );
productBo.save( product, 100 );

Product.xml:

...
<!-- This is a proxy factory bean; see App.java -->
<bean id="productBoProxy"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target" ref="productBo" />
<property name="interceptorNames">
<list>
<value>transactionInterceptor</value>
</list>
</property>
</bean>
...

堆栈跟踪:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: \
Error creating bean with name 'productBoProxy': \
FactoryBean threw exception on object creation; nested exception is java.lang.VerifyError: \
class net.sf.cglib.core.DebuggingClassWriter overrides final method visit. \
(IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1441)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1093)
at com.mkyong.App.main(App.java:41)
Caused by: java.lang.VerifyError: class net.sf.cglib.core.DebuggingClassWriter \
overrides final method visit.(IILjava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)V
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at net.sf.cglib.core.AbstractClassGenerator.<init>(AbstractClassGenerator.java:38)
at net.sf.cglib.core.KeyFactory$Generator.<init>(KeyFactory.java:127)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:112)
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)
at org.springframework.aop.framework.Cglib2AopProxy.createEnhancer(Cglib2AopProxy.java:229)
at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:171)
at org.springframework.aop.framework.ProxyFactoryBean.getProxy(ProxyFactoryBean.java:362)
at org.springframework.aop.framework.ProxyFactoryBean.getSingletonInstance(ProxyFactoryBean.java:316)
at org.springframework.aop.framework.ProxyFactoryBean.getObject(ProxyFactoryBean.java:242)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 6 more

最佳答案

您的 cglib 和 ASM 版本不匹配。 Stacktrace 告诉“net.sf.cglib.core.DebuggingClassWriter 覆盖 final方法访问”,换句话说扩展了 org.objectweb.asm.ClassWriter 的 net.sf.cglib.core.DebuggingClassWriter 试图覆盖 final 方法访问,这当然会失败。

例如 maven dependendy for cglib 2.2.2拉 asm 3.3.1,所以这是一个值得尝试的组合。

关于hibernate - java.lang.VerifyError : class net. sf.cglib.core.DebuggingClassWriter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9366403/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com