【问题标题】:java.lang.NoClassDefFoundError: io/netty/handler/ssl/SslContextBuilderjava.lang.NoClassDefFoundError: io/netty/handler/ssl/SslContextBuilder
【发布时间】:2017-12-01 19:05:23
【问题描述】:

我正在尝试实现relayrides/pushy,但出现以下运行时错误:

Jun 28, 2017 2:06:58 PM com.turo.pushy.apns.SslUtil getSslProvider
INFO: Native SSL provider not available; will use JDK SSL provider.
Exception in thread "main" java.lang.NoClassDefFoundError: io/netty/handler/ssl/SslContextBuilder
  at com.turo.pushy.apns.ApnsClientBuilder.build(ApnsClientBuilder.java:396)
  at com.jobs.spring.service.NotificationServiceImpl.sendIOSPushNotification(NotificationServiceImpl.java:122)

  Caused by: java.lang.ClassNotFoundException: io.netty.handler.ssl.SslContextBuilder

pom.xml

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.2</version>
    </dependency>
    <!-- Push Notifications -->
    <dependency>
        <groupId>com.turo</groupId>
        <artifactId>pushy</artifactId>
        <version>0.10</version>
    </dependency>
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-tcnative</artifactId>
        <version>2.0.5.Final</version>
    </dependency>
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-handler</artifactId>
        <version>4.0.27.Final</version>
    </dependency>
    <dependency>
        <groupId>com.ning</groupId>
        <artifactId>async-http-client</artifactId>
        <version>1.9.40</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.1</version>
    </dependency>

java

    final ApnsClient apnsClient = new ApnsClientBuilder()
            .setClientCredentials(new File(PATH_TO_P12_CERT), CERT_PASSWORD )
            .build();

我猜我的 mvn 依赖项不正确。任何帮助表示赞赏。

更新

我将依赖项更新为:

    <dependency>
        <groupId>com.turo</groupId>
        <artifactId>pushy</artifactId>
        <version>0.10</version>
    </dependency>
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-all</artifactId>
        <version>4.1.11.Final</version>
    </dependency>
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-tcnative</artifactId>
        <version>2.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.6</version>
    </dependency>

但现在得到:

Jun 28, 2017 2:40:18 PM com.turo.pushy.apns.SslUtil getSslProvider
INFO: Native SSL provider not available; will use JDK SSL provider.
Exception in thread "main" java.lang.NoSuchMethodError: io.netty.bootstrap.Bootstrap.config()Lio/netty/bootstrap/BootstrapConfig;
  at com.turo.pushy.apns.ApnsClient.<init>(ApnsClient.java:172)
  at com.turo.pushy.apns.ApnsClientBuilder.build(ApnsClientBuilder.java:420)
  at com.jobs.spring.service.NotificationServiceImpl.sendIOSPushNotification(NotificationServiceImpl.java:121)

【问题讨论】:

    标签: java netty maven-dependency


    【解决方案1】:

    在我创建了一个只包含依赖项的测试项目之间,你清理了你的类路径吗

    <dependency>
        <groupId>com.turo</groupId>
        <artifactId>pushy</artifactId>
        <version>0.10</version>
    </dependency>
    

    还有一个简单的主类,只是用你上面使用的片段创建客户端,效果很好

    在我看来,类路径上可能有两个版本的 BootstrapConfig。尝试删除除了 pushy 和 clean/refreshing maven 依赖项之外的所有依赖项。

    【讨论】:

      【解决方案2】:

      似乎您将 netty 4.1 和 4.0 混合在一起。如果你想使用 pushy,你只需要使用 4.1。

      【讨论】:

        猜你喜欢
        • 2017-10-11
        • 1970-01-01
        • 2019-09-09
        • 2018-01-05
        • 1970-01-01
        • 2020-11-20
        • 1970-01-01
        • 1970-01-01
        • 2015-11-26
        相关资源
        最近更新 更多