Azure / azure-notificationhubs-java-backend

Azure Notification Hubs SDK for Java
https://docs.microsoft.com/en-us/azure/notification-hubs/
Apache License 2.0
35 stars 49 forks source link

extra dependency needed: org.apache.httpcomponents.client5 httpclient5 #136

Closed serban-cordis closed 1 year ago

serban-cordis commented 2 years ago

Hi,

I am using a simple CLI project, no other dependencies besides:

        <dependency>
            <groupId>com.windowsazure</groupId>
            <artifactId>Notification-Hubs-java-sdk</artifactId>
            <version>1.0.3</version>
        </dependency>

    public static void main(String[] args) throws NotificationHubsException {
        NotificationHubClient client = new NotificationHub(HUB_CONNECTION_STRING, HUB_NAME);
    }

I am getting a class definition not found: Exception in thread "httpclient-dispatch-1" java.lang.NoClassDefFoundError: org/apache/hc/core5/http2/impl/nio/ClientHttpProtocolNegotiator at org.apache.hc.client5.http.impl.async.HttpAsyncClientEventHandlerFactory.createHandler(HttpAsyncClientEventHandlerFactory.java:257)

When i checked, org.apache.hc.core5.http2.impl.nio.ClientHttpProtocolNegotiator cannot be found in org.apache.httpcomponents.client5:httpclient5:5.1.3 jar

To fix this i have to add and extra:

        <dependency>
            <groupId>org.apache.httpcomponents.client5</groupId>
            <artifactId>httpclient5</artifactId>
            <version>5.2-beta1</version>
        </dependency>

This dependency contains the missing class.

Why is this not included directly in the notification-hubs-java-sdk artifact? I am using 1.0.3, the latest version on maven repo.

Should a new release with the upgraded http be required in order for this to work directly without any extra artifacts?

Please advise.

Thank you, Serban

jeroenvandevelde commented 1 year ago

The latest stable version of org.apache.httpcomponents (5.2, 5.2.1) doesn't contain the class org.apache.hc.core5.http2.impl.nio.ClientHttpProtocolNegotiator.

So with Notification-Hubs-java-sdk 1.0.3, you should stay on version 5.2-alpha2 of org.apache.httpcomponents. You can use httpcore5 or httpclient5:

<dependency>
          <groupId>org.apache.httpcomponents.core5</groupId>
          <artifactId>httpcore5</artifactId>
         <version>5.2-alpha2</version>
</dependency>
<dependency>
            <groupId>org.apache.httpcomponents.client5</groupId>
            <artifactId>httpclient5</artifactId>
            <version>5.2-alpha2</version>
</dependency>
aziztitu commented 1 year ago

160 should fix this issue