0

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?

Greg Kopff
  • 15,945
  • 12
  • 55
  • 78
Deepu
  • 2,590
  • 19
  • 52
  • 74

2 Answers2

1

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

DannyGolhar
  • 196
  • 1
  • 10
0

Include the bouncycastle library in your project.

Peter DeWeese
  • 18,141
  • 8
  • 79
  • 101
Pushan
  • 480
  • 1
  • 7
  • 13