6

I am facing the following issue :

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

I am using httpclient 4.5 jar. Could you please let me know how to resolve it?

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

my pom.xml contains the following dependency -

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5</version>
    <scope>provided</scope>
</dependency>
1
  • The class is actually there in the JAR file. You have mentioned your dependency as 'provided', ensure the JAR is available in the CLASSPATH at runtime. Commented May 23, 2022 at 6:05

1 Answer 1

0

We had the same problem with java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.conn.ssl.SSLConnectionSocketFactory and there was appropriate dependency in Maven.

The reason of the problem in our case was tika-app, when we changed it to tica-core the problem was solved. The part commented below we replaced with the part above:

    <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>-->
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.