java.lang.VerifyError: Cannot inherit from final class when using spring boot data solr

≡放荡痞女 提交于 2020-01-07 07:42:32

问题


I have a rest web service that running with spring boot 1.4.2.RELEASE. I trying to use spring data solr with my project but I am getting a VerifyError.

Caused by: java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_40-ea]
at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ~[na:1.8.0_40-ea]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_40-ea]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) ~[na:1.8.0_40-ea]
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[na:1.8.0_40-ea]
at java.net.URLClassLoader$1.run(URLClassLoader.java:367) ~[na:1.8.0_40-ea]
at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.8.0_40-ea]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_40-ea]
at java.net.URLClassLoader.findClass(URLClassLoader.java:360) ~[na:1.8.0_40-ea]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_40-ea]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) ~[na:1.8.0_40-ea]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_40-ea]
at org.apache.http.impl.client.DefaultHttpClient.createHttpParams(DefaultHttpClient.java:158) ~[httpclient-4.5.2.jar:4.5.2]
at org.apache.http.impl.client.AbstractHttpClient.getParams(AbstractHttpClient.java:467) ~[httpclient-4.5.2.jar:4.5.2]
at org.apache.solr.client.solrj.impl.HttpClientUtil.setFollowRedirects(HttpClientUtil.java:290) ~[solr-solrj-5.5.3.jar:5.5.3 8655b97b27d8da470c8235683af11a8b85a2b10f - anshum - 2016-09-01 13:05:41]
at org.apache.solr.client.solrj.impl.HttpClientConfigurer.configure(HttpClientConfigurer.java:58) ~[solr-solrj-5.5.3.jar:5.5.3 8655b97b27d8da470c8235683af11a8b85a2b10f - anshum - 2016-09-01 13:05:41]
at org.apache.solr.client.solrj.impl.HttpClientUtil.configureClient(HttpClientUtil.java:149) ~[solr-solrj-5.5.3.jar:5.5.3 8655b97b27d8da470c8235683af11a8b85a2b10f - anshum - 2016-09-01 13:05:41]
at org.apache.solr.client.solrj.impl.HttpClientUtil.createClient(HttpClientUtil.java:125) ~[solr-solrj-5.5.3.jar:5.5.3 8655b97b27d8da470c8235683af11a8b85a2b10f - anshum - 2016-09-01 13:05:41]
at org.apache.solr.client.solrj.impl.HttpSolrClient.<init>(HttpSolrClient.java:189) ~[solr-solrj-5.5.3.jar:5.5.3 8655b97b27d8da470c8235683af11a8b85a2b10f - anshum - 2016-09-01 13:05:41]
at org.apache.solr.client.solrj.impl.HttpSolrClient.<init>(HttpSolrClient.java:162) ~[solr-solrj-5.5.3.jar:5.5.3 8655b97b27d8da470c8235683af11a8b85a2b10f - anshum - 2016-09-01 13:05:41]
at com.itgis.kojaam.model.PersistenceContext.solrClient(PersistenceContext.java:157) ~[classes/:na]
at com.itgis.kojaam.model.PersistenceContext$$EnhancerBySpringCGLIB$$fa158d3c.CGLIB$solrClient$1(<generated>) ~[classes/:na]
at com.itgis.kojaam.model.PersistenceContext$$EnhancerBySpringCGLIB$$fa158d3c$$FastClassBySpringCGLIB$$fd7f382d.invoke(<generated>) ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at com.itgis.kojaam.model.PersistenceContext$$EnhancerBySpringCGLIB$$fa158d3c.solrClient(<generated>) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_40-ea]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_40-ea]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_40-ea]
at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_40-ea]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]

I think that this error related to library conflict of solrj with spring but i cant solve this , also i delete cache of maven (.m2 folder) and reimport dependency again but not work and my pom.xml file like below :

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.itgis</groupId>
<artifactId>myapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyApp</name>
<description>My Application</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.2.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>

    <!--Spring Boot-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <!--Spring REST-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web-services</artifactId>
    </dependency>

    <!--Spring Security-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <!--Spring JPA data-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <!--Protocol buffer-->
    <dependency>
        <groupId>com.google.protobuf</groupId>
        <artifactId>protobuf-java</artifactId>
        <version>3.0.0</version>
    </dependency>

    <dependency>
        <groupId>com.googlecode.protobuf-java-format</groupId>
        <artifactId>protobuf-java-format</artifactId>
        <version>1.3</version>
    </dependency>

    <!--MySQL Connector-->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>

    <!--Connection Pool library-->
    <dependency>
        <groupId>com.zaxxer</groupId>
        <artifactId>HikariCP</artifactId>
    </dependency>

    <!-- Oval : Object validationUtil -->
    <dependency>
        <groupId>net.sf.oval</groupId>
        <artifactId>oval</artifactId>
        <version>1.86</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-mongodb</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-solr</artifactId>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

and this is my configuration for solr :

    @Bean
public SolrClient solrClient() {
    return new HttpSolrClient(environment.getRequiredProperty(PROPERTY_NAME_SOLR_SERVER_URL));
}

please help me to solve this error , thanks...


回答1:


Struggled for 2 days with this:

Caused by: java.lang.VerifyError: Cannot inherit from final class
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

I have 5 maven subprojects in my project structure. Two of these sub-projects had a dependency that was present in 2 different jars with different names but with overlapping contents. I decompiled all my dependencies to identify what the duplicated part was and removed the slimmer jar dependency.

My suggestion: This is most likely a duplicate in the classpath. Comb through your dependencies and look for duplicates. By duplicates, I don't mean just the jar names of the dependencies, but the contents and class files in those jars.



来源:https://stackoverflow.com/questions/40829949/java-lang-verifyerror-cannot-inherit-from-final-class-when-using-spring-boot-da

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!