Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VerifyError: Cannot inherit from final class

Tags:

java

I am seeing the following error when attempting to launch my standalone application:

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]

I have checked my classpath and there is only one instance of the class HttpComponentsClientHttpRequestFactory, residing in the spring-web-3.2.1.jar file.

When I look at the source for this class, there is no mention of it extending any final class or methods.

I am a little confused as to what is happening.

Can anyone offer some pointers please?

like image 890
DJ180 Avatar asked Dec 15 '22 09:12

DJ180


1 Answers

Make sure that the classpath you are using for building is the same as that which you are using for testing. The most common cause of VerifyErrors is inconsistencies between the classes you built against, and the classes that you are testing against. That is, at its core, driven by a version issue.

like image 51
jason Avatar answered Dec 28 '22 23:12

jason