问题描述
我正在尝试对一些源自教程的非常简单的Hibernate代码进行原型构建,并得到一个我不明白的cglib2深处的错误(完整的堆栈跟踪在本文后面)。我可能会尝试通过简单的 main()和bean XML(下面)创建'productBoProxy'。
版本的cglib无济于事。我非常感谢任何能够帮助我找到解决这个问题的正确途径的人。
$ b App.java :
ApplicationContext appContext
= new ClassPathXmlApplicationContext(resources / config / BeanLocations.xml);
...
productBo =(ProductBo)appContext.getBean(productBoProxy);
productBo.save(product,100);
Product.xml :
...
< bean id =productBoProxy
class =org.springframework.aop.framework.ProxyFactoryBean>
< property name =targetref =productBo/>
< property name =interceptorNames>
< list>
< value> transactionInterceptor< / value>
< / list>
< / property>
< / bean>
...
堆栈跟踪:
线程main中的异常org.springframework.beans.factory.BeanCreationException:\
创建名为'productBoProxy'的bean时出错:\
FactoryBean在创建对象时抛出异常;嵌套异常是java.lang.VerifyError:\
class net.sf.cglib.core.DebuggingClassWriter会覆盖最终方法访问。 \
(IILjava / lang / String; Ljava / lang / String; Ljava / lang / String; [Ljava / lang / String;)V
在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)
在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248)
在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 )
导致:java.lang.VerifyError:class net.sf.cglib.core.DebuggingClassWriter \
覆盖最终方法visi (IOLjava / lang / String; Ljava / lang / String; Ljava / lang / String; [Ljava / lang / String;)V
at java.lang.ClassLoader.defineClass1(Native Method)
在java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
。在需要java.lang.ClassLoader.defineClass(ClassLoader.java:615)
在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)在java.security.AccessController.doPrivileged(本机方法)
在java.net.URLClassLoader.findClass
(URLClassLoader.java:190)
在java.lang.ClassLoader.loadClass(ClassLoader.java:306)
在sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:301)
在java.lang.ClassLoader.loadClass( ClassLoader.java:247)
at net.sf.cglib.core.AbstractClassGenerator。< init>(AbstractClassGenerator.java:38)
at net.sf.cglib.core.Ke < init>(KeyFactory.java:127)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:112)
at net.sf.cglib.core .KeyFactory.create(KeyFactory.java:108)$ net $ b $ net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at net.sf.cglib.proxy.Enhancer。< ; clinit>(Enhancer.java:69)
。在org.springframework.aop.framework.Cglib2AopProxy.createEnhancer(Cglib2AopProxy.java:229)
。在org.springframework.aop.framework.Cglib2AopProxy.getProxy( Cglib2AopProxy.java:171)在org.springframework.aop.framework.ProxyFactoryBean.getProxy(ProxyFactoryBean.java:362
)
在org.springframework.aop.framework.ProxyFactoryBean.getSingletonInstance(ProxyFactoryBean.java: 316)
在org.springframework.aop.framework.ProxyFactoryBean.getObject(ProxyFactoryBean.java:242)
在org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 6 more
你有不匹配的cglib和ASM版本。 Stacktrace告诉net.sf.cglib.core.DebuggingClassWriter重写最终方法访问,换句话说
net.sf.cglib.core.DebuggingClassWriter,它扩展了org.objectweb.asm.ClassWriter尝试覆盖最终方法访问,这当然会失败。
例如拉3.3.1,所以这是一个值得尝试的组合。
I'm trying to prototype some pretty simple Hibernate code originating from a tutorial and am getting an error I don't understand deep in cglib2 (the full stack trace is at the end of this post). I am probably trying to create 'productBoProxy' per my simple main() and bean XML (below).
I've tried many different versions of cglib to no avail. I'm very grateful to anyone who can help me find the right path to solving this.
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>
...
Stack trace:
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
You have mismatching versions of cglib and ASM. Stacktrace tells "net.sf.cglib.core.DebuggingClassWriter overrides final method visit", in other wordsnet.sf.cglib.core.DebuggingClassWriter which extends org.objectweb.asm.ClassWriter tries to override final method visit, which of course fails.
For example maven dependendy for cglib 2.2.2 pulls asm 3.3.1, so this is one combination worth of trying.
这篇关于java.lang.VerifyError:类net.sf.cglib.core.DebuggingClassWriter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!