VerifyError:无法从最终类继承

时间:2013-06-19 18:18:50

标签: java

尝试启动独立应用程序时,我看到以下错误:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'restTemplate' defined in class path resource [abc/def/ghi/my-context.xml]: Cannot resolve reference to bean 'requestFactory' while setting bean property 'requestFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestFactory' defined in class path resource [abc/def/ghi/my-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.client.HttpComponentsClientHttpRequestFactory]: Constructor threw exception; nested exception is java.lang.VerifyError: Cannot inherit from final class
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1391) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1132) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    ... 57 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestFactory' defined in class path resource [abc/def/ghi/my-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.client.HttpComponentsClientHttpRequestFactory]: Constructor threw exception; nested exception is java.lang.VerifyError: Cannot inherit from final class
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1011) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:957) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:490) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    ... 67 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.http.client.HttpComponentsClientHttpRequestFactory]: Constructor threw exception; nested exception is java.lang.VerifyError: Cannot inherit from final class
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1004) ~[spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    ... 75 common frames omitted
Caused by: java.lang.VerifyError: Cannot inherit from final class
    at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.6.0_29]
    at java.lang.ClassLoader.defineClassCond(Unknown Source) ~[na:1.6.0_29]
    at java.lang.ClassLoader.defineClass(Unknown Source) ~[na:1.6.0_29]
    at java.security.SecureClassLoader.defineClass(Unknown Source) ~[na:1.6.0_29]
    at java.net.URLClassLoader.defineClass(Unknown Source) ~[na:1.6.0_29]
    at java.net.URLClassLoader.access$000(Unknown Source) ~[na:1.6.0_29]
    at java.net.URLClassLoader$1.run(Unknown Source) ~[na:1.6.0_29]

我已经检查了我的类路径,并且只有一个HttpComponentsClientHttpRequestFactory类的实例,位于spring-web-3.2.1.jar文件中。

当我查看这个类的源代码时,没有提及它扩展任何最终的类或方法。

我对发生的事情感到有些困惑。

有人可以提供一些指示吗?

1 个答案:

答案 0 :(得分:11)

确保用于构建的类路径与用于测试的类路径相同。 VerifyError s的最常见原因是您构建的类与您要测试的类之间存在不一致。也就是说,它的核心是由版本问题驱动的。