Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.36k stars 2k forks source link

[BUG]Jboss: A request was made to load the default HttpClient provider but one could not be found on the classpath #40152

Closed abhishekotalwar closed 6 months ago

abhishekotalwar commented 6 months ago

Describe the bug In the jboss we configured the datasources with EntraId authentication(passwordless) and to use this we used AzurePostgresqlAuthenticationPlugin.

In order to use AzurePostgresqlAuthenticationPlugin we have create respective modules in jboss so that all required .jars available at classpath. The Jboss able to connect to DB but below error in jboss log irritate us,.

I tried to set below system property in jboss but got still same error, < property name="com.azure.core.http.HttpClientProvider" value="com.azure.core.http.netty.NettyAsyncHttpClientProvider" />

We cannot use solution provided here https://github.com/Azure/azure-sdk-for-java/issues/23557#issuecomment-898584360

Exception or Stack Trace ERROR [com.azure.core.implementation.util.Providers] (JCA PoolFiller) A request was made to load the default HttpClient provider but one could not be found on the classpath. If you are using a dependency manager, consider including a dependency on azure-core-http-netty or azure-core-http-okhttp. Depending on your existing dependencies, you have the choice of Netty or OkHttp implementations. Additionally, refer to https://aka.ms/azsdk/java/docs/custom-httpclient to learn about writing your own implementation.

To Reproduce Add datasource in jboss and use AzurePostgresqlAuthenticationPlugin

Code Snippet `

jdbc:postgresql://psql-test-base.postgres.database.azure.com:5432/testdb?sslmode=require&authenticationPluginClassName=com.azure.identity.extensions.jdbc.postgresql.AzurePostgresqlAuthenticationPlugin
                <driver>postgresql</driver>
                <pool>
                    <min-pool-size>5</min-pool-size>
                    <initial-pool-size>5</initial-pool-size>
                    <max-pool-size>150</max-pool-size>
                    <flush-strategy>FailingConnectionOnly</flush-strategy>
                </pool>
                <security>
                    <user-name></user-name>
                </security>
                <validation>
                    <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
                    <validate-on-match>true</validate-on-match>
                    <background-validation>false</background-validation>
                    <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>
                </validation>
                <timeout>
                    <set-tx-query-timeout>false</set-tx-query-timeout>
                    <blocking-timeout-millis>30000</blocking-timeout-millis>
                    <idle-timeout-minutes>15</idle-timeout-minutes>
                    <query-timeout>0</query-timeout>
                    <use-try-lock>0</use-try-lock>
                    <allocation-retry>0</allocation-retry>
                    <allocation-retry-wait-millis>0</allocation-retry-wait-millis>
                </timeout>
                <statement>
                    <track-statements>false</track-statements>
                </statement>
            </datasource>`

Setup (please complete the following information): dependency information

[INFO] +- com.azure:azure-identity-extensions:jar:1.0.0:compile [INFO] +- com.azure:azure-identity:jar:1.12.1:compile [INFO] | +- com.azure:azure-core:jar:1.49.0:compile [INFO] | | +- com.azure:azure-xml:jar:1.0.0:compile [INFO] | | - io.projectreactor:reactor-core:jar:3.5.6:compile [INFO] | +- com.azure:azure-core-http-netty:jar:1.15.0:compile [INFO] | | +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.92.Final:compile [INFO] | | +- io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.92.Final:compile [INFO] | | +- io.netty:netty-tcnative-boringssl-static:jar:2.0.60.Final:compile [INFO] | | | +- io.netty:netty-tcnative-classes:jar:2.0.60.Final:compile [INFO] | | | +- io.netty:netty-tcnative-boringssl-static:jar:linux-x86_64:2.0.60.Final:compile [INFO] | | | +- io.netty:netty-tcnative-boringssl-static:jar:linux-aarch_64:2.0.60.Final:compile [INFO] | | | +- io.netty:netty-tcnative-boringssl-static:jar:osx-x86_64:2.0.60.Final:compile [INFO] | | | +- io.netty:netty-tcnative-boringssl-static:jar:osx-aarch_64:2.0.60.Final:compile [INFO] | | | - io.netty:netty-tcnative-boringssl-static:jar:windows-x86_64:2.0.60.Final:compile [INFO] | | - io.projectreactor.netty:reactor-netty-http:jar:1.1.7:compile [INFO] | | +- io.netty:netty-resolver-dns:jar:4.1.92.Final:compile [INFO] | | | - io.netty:netty-codec-dns:jar:4.1.92.Final:compile [INFO] | | +- io.netty:netty-resolver-dns-native-macos:jar:osx-x86_64:4.1.92.Final:compile [INFO] | | | - io.netty:netty-resolver-dns-classes-macos:jar:4.1.92.Final:compile [INFO] | | - io.projectreactor.netty:reactor-netty-core:jar:1.1.7:compile [INFO] | +- com.azure:azure-json:jar:1.1.0:compile [INFO] | +- com.microsoft.azure:msal4j:jar:1.15.0:compile [INFO] | +- com.microsoft.azure:msal4j-persistence-extension:jar:1.3.0:compile [INFO] | | - net.java.dev.jna:jna:jar:5.13.0:compile [INFO] | - net.java.dev.jna:jna-platform:jar:5.6.0:compile [INFO] +- io.netty:netty-handler:jar:4.1.108.Final:compile [INFO] | +- io.netty:netty-resolver:jar:4.1.92.Final:compile [INFO] | - io.netty:netty-transport:jar:4.1.92.Final:compile [INFO] +- io.netty:netty-handler-proxy:jar:4.1.108.Final:compile [INFO] | - io.netty:netty-codec-socks:jar:4.1.92.Final:compile [INFO] +- io.netty:netty-buffer:jar:4.1.108.Final:compile [INFO] +- io.netty:netty-codec:jar:4.1.108.Final:compile [INFO] +- io.netty:netty-codec-http:jar:4.1.108.Final:compile [INFO] +- io.netty:netty-codec-http2:jar:4.1.108.Final:compile [INFO] +- io.netty:netty-transport-native-unix-common:jar:4.1.108.Final:compile [INFO] +- io.netty:netty-transport-native-epoll:jar:4.1.108.Final:compile [INFO] | - io.netty:netty-transport-classes-epoll:jar:4.1.92.Final:compile [INFO] +- io.netty:netty-transport-native-kqueue:jar:4.1.108.Final:compile [INFO] | - io.netty:netty-transport-classes-kqueue:jar:4.1.92.Final:compile [INFO] - io.netty:netty-common:jar:4.1.108.Final:compile

abhishekotalwar commented 6 months ago

Solved this issue.

The module with all appropriate depency kept at path of jboss \modules\system\layers\base then jboss has loaded module correctly and is able to read the /META-INF/services from azure-core-http-netty .jar