Getting error while sending Push Notification to iPhone using Java-PNS?

我们两清 提交于 2019-12-25 05:16:31

问题


I am using javaPNS_2.2.jar file to send push notification message to iPhone device.

My Code is:

PushNotificationPayload payload = PushNotificationPayload.complex();

/* Customize the payload */ 
payload.addAlert("Hello World!");
payload.addCustomDictionary("mykey1", "My Value 1");
payload.addCustomDictionary("mykey2", 2);

/* Push your custom payload */
String keystore = "C:/1.0Eywa_Baba/PushNotificationKey.p12";
String password = "Eywa@12";
boolean production = false;
String devices = "C81DD339-F5C1-529F-BEC4-6C8622BA0BFD";
List<PushedNotification> notifications = Push.payload(payload, 
                                                      keystore, 
                                                      password, 
                                                      production, 
                                                      devices);

However, I am getting the error:

log4j:WARN No appenders could be found for logger (javapns.notification.Payload).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/jce/provider/BouncyCastleProvider
  at javapns.notification.PushNotificationManager.initializeConnection(PushNotificationManager.java:105)
  at javapns.Push.sendPayload(Push.java:171)
  at javapns.Push.payload(Push.java:149) 
  at com.example.SendMSG.send(SendMSG.java:35)
  at com.example.APNDemo1.main(APNDemo1.java:20)
Caused by: java.lang.ClassNotFoundException: org.bouncycastle.jce.provider.BouncyCastleProvider
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)

What is causing this exception?


回答1:


Include the bcprov-jdk15-140 jar in classpath of your project.




回答2:


Include the bouncycastle library in your project.



来源:https://stackoverflow.com/questions/11012191/getting-error-while-sending-push-notification-to-iphone-using-java-pns

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!