notnoop / java-apns

Java Apple Push Notification Service Provider
notnoop.github.com/java-apns
BSD 3-Clause "New" or "Revised" License
1.79k stars 657 forks source link

java.lang.VerifyError on APNS.newPayload() #30

Closed WarTech9 closed 13 years ago

WarTech9 commented 13 years ago

I am using java-apns in my push notification server. The process is run as an Apache Commons daemon using jsvc. I have a thread that runs every 'N' seconds and checks for new notifications. If it finds any it attempts to send them out. From the stack trace below, the error happens on line 80 of my NotificationManager class. The code I have on that line is:

String payload = APNS.newPayload().alertBody(notification.getMessage()).
                    badge(0).sound("default").build();

And this raises the exception below:

Exception in thread "Timer-0" java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at com.notnoop.apns.PayloadBuilder.<clinit>(PayloadBuilder.java:47)
at ca.site.mobile.apns.service.NotificationManager.sendNotification(NotificationManager.java:80)
at ca.site.mobile.apns.service.NotificationManager.purgeNotifications(NotificationManager.java:64)
at ca.site.mobile.apns.service.NotificationChecker$1.checkForNotifications(NotificationChecker.java:46)
at ca.site.mobile.apns.service.NotificationChecker$1.run(NotificationChecker.java:41)
at ca.site.mobile.apns.scheduling.Scheduler$SchedulerTimerTask.run(Scheduler.java:18)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)

I've tried this on both Mac OSX and Linux running Java 1.6 with the same result. I am able to run that same line of code in a standalone java application (not using jsvc) without error but when run from within the daemon I get that error. I think it might have to do with running this as part of a daemon. Any ideas? Thanks.

notnoop commented 13 years ago

I assume that you are having a dependency version conflict for the Jackson API, when running with jsvc. However, jsvc seems not to require any dependencies beyond junit.