Search code examples
javaiospush-notificationapple-push-notificationsbouncycastle

Can't get JavaPNS to work for Push notifications


Okay, so I'm working on a java server for an Apps backend, it must be able to issue iOS push notifications as part of a larger code-base, so I used the JavaPNS library (v2.1.1), which was used(and worked) previously on the tomcat version of the server. I'm developing locally using Eclipse on Arch Linux.

I'm trying the simplest test possible for it:

try{ 
   Push.alert("Hello", "cert.p12", "password", false, "<my iPods UDID>");
}catch(Exception e){
  e.printStackTrace();
}

The result exception is:

 Exception in thread "main" java.lang.NoClassDefFoundError:org/bouncycastle/jce/provider/BouncyCastleProvider
at javapns.notification.PushNotificationManager.initializeConnection(PushNotificationManager.java:107)
at javapns.Push.sendPayload(Push.java:171)
at javapns.Push.alert(Push.java:47)
at testIOS.main(testIOS.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)
... 4 more

the cert file is in the local directory(there were no complaints about it loading), the password and the UDID are both correct. I've tried a few things(in vain probably), such as installing the unlimited policy JCE from oracle: http://www.bouncycastle.org/wiki/display/JA1/Provider+Installation

But I really have no clue what's wrong, it just seems to be unable to find that class/library, but I really don't know how to fix it. Thanks in advance for any tips.


Solution

  • Do you've bcprov-jdk15-146.jar in your lib ? If not, download jar from this link and place it in your lib.

    Bouncy Castle