java.lang.VerifyError:使用spring boot data solr时无法从final类继承

时间:2016-11-27 14:21:11

标签: spring-boot solrj spring-rest verifyerror spring-data-solr

我有一个使用spring boot 1.4.2.RELEASE运行的休息Web服务。我试图在我的项目中使用spring data solr,但我得到了一个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]

我认为这个错误与solrj与spring的库冲突有关,但是我无法解决这个问题,我也删除了maven(.m2文件夹)的缓存并再次重新导入依赖但不工作和我的pom.xml文件如下: / p>

<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>

这是我对solr的配置:

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

请帮我解决这个错误,谢谢...

1 个答案:

答案 0 :(得分:4)

用这个来挣扎2天:

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)

我的项目结构中有5个maven子项目。这些子项目中的两个具有依赖性,该依赖性存在于具有不同名称但具有重叠内容的2个不同罐中。我反编译了所有依赖项,以确定重复部分是什么,并删除了较薄的jar依赖。

我的建议:这很可能是类路径中的重复。梳理您的依赖项并查找重复项。通过重复,我不是指依赖项的jar名称,而是那些jar中的内容和类文件。