Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ApacheHttpClient5Transport requires apache commons logging dependency (but not provided if RHEC excluded) #1002

Closed
rursprung opened this issue May 27, 2024 · 0 comments · Fixed by #1003
Assignees
Labels
bug Something isn't working

Comments

@rursprung
Copy link
Contributor

What is the bug?

if you depend on opensearch-java but exclude the opensearch-rest-client (RHEC) then it fails in the runtime with the following error:

java.lang.NoClassDefFoundError: Could not initialize class org.opensearch.client.transport.httpclient5.ApacheHttpClient5Transport

	at org.opensearch.client.transport.httpclient5.ApacheHttpClient5TransportBuilder.build(ApacheHttpClient5TransportBuilder.java:279)
	at liquibase.ext.opensearch.database.OpenSearchConnection.connect(OpenSearchConnection.java:146)
	at liquibase.ext.opensearch.database.OpenSearchConnection.open(OpenSearchConnection.java:64)
	at liquibase.database.ConnectionServiceFactory.create(ConnectionServiceFactory.java:32)
	at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:238)
	at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:188)
	at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:153)
	at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:142)
	at liquibase.ext.opensearch.AbstractOpenSearchLiquibaseIT.beforeEach(AbstractOpenSearchLiquibaseIT.java:42)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory [in thread "main"]
	at org.opensearch.client.transport.httpclient5.ApacheHttpClient5Transport.<clinit>(ApacheHttpClient5Transport.java:98)
	... 12 more

How can one reproduce the bug?

in maven:

        <dependency>
            <groupId>org.opensearch.client</groupId>
            <artifactId>opensearch-java</artifactId>
            <version>2.10.3</version>
            <exclusions>
                <exclusion>
                    <groupId>org.opensearch.client</groupId>
                    <artifactId>opensearch-rest-client</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

as a workaround the following dependency can be added:

        <dependency>
            <!-- transitive dependency needed by ApacheHttpClient5Transport -->
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.3.2</version>
        </dependency>

What is the expected behavior?

the required dependencies are provided by opensearch-java, consumers do not need to know about such internals.

What is your host/environment?

tested with opensearch-java 2.10.3.

Do you have any screenshots?

n/a

Do you have any additional context?

@reta is already informed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants