java.lang.NoClassDefFoundError : Could not initialize class org. apache.http.conn.ssl.SSLConnectionSocketFactory

标签 java ssl noclassdeffounderror

我面临以下问题:

java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.conn.ssl.SSLConnectionSocketFactory

我正在使用 httpclient 4.5 jar。你能告诉我如何解决吗?

SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, new String[] {"TLSv1" }, null,
                       SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);

我的 pom.xml 包含以下依赖项 -

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5</version>
    <scope>provided</scope>
</dependency>

最佳答案

我们遇到了同样的问题 java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.conn.ssl.SSLConnectionSocketFactory 并且在 Maven 中有适当的依赖。

在我们的案例中,问题的原因是 tika-app,当我们将其更改为 tica-core 时,问题就解决了。下面注释的部分我们替换为上面的部分:

    <dependency>
        <groupId>org.apache.tika</groupId>
        <artifactId>tika-core</artifactId>
        <version>1.19.1</version>
    </dependency>

    <!--<dependency>
        <groupId>org.apache.tika</groupId>
        <artifactId>tika-app</artifactId>
        <version>1.16</version>
    </dependency>-->

关于java.lang.NoClassDefFoundError : Could not initialize class org. apache.http.conn.ssl.SSLConnectionSocketFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43447847/

相关文章:

java - 解析从命令行作为参数传递给 Java 的文件

java - 为什么没有使用 Spring Data JPA 设置版本属性?

ssl - 表彰机器名称和 IP 地址的自签名证书

testing - 在 Go 中模拟 HTTPS 响应

java - 在 JFrame 中将 JBusyComponent 与 JTable 一起使用

JavaFX:从运行时加载的模态获取数据

java - Spring 响应式(Reactive)应用程序上请求/响应主体的副本?

ssl - 记录基于 SSO 的应用程序的 SSL 的 JMeter2.11 问题

java - 使用 maven 执行 mahout 程序 (JAR) 时出现 NoClassDefFoundError

找不到 Java 类 SingularMatrixException