notnoop/java-apns — Issue #57: NoClassDefFoundError - com.notnoop.apns.internal.Utilities
Author: ti-dev
Created: 2011-10-26 19:23:43+00:00
State: open

Hello!

I use java-apns version 0.1.6 (via maven) and everything works in my local installations.
In one server environment, I get an error trying to push a message.

In ApnsServiceBuilder.java, there are these lines of code (v 0.1.6.):

public ApnsServiceBuilder withCert(String fileName, String password) throws RuntimeIOException, InvalidSSLConfig {
FileInputStream stream = null;
try {
stream = new FileInputStream(fileName);
return withCert(stream, password);
} catch (FileNotFoundException e) {
throw new RuntimeIOException(e);
} finally {
Utilities.close(stream);
}
}

In the line `Utilities.close(stream);` the error is thrown, telling me that the class could not be initialized.
So what can be the problem? I did not modify the APNS code and it works on every machine (I used java-apns several times), except on one server.

The stacktrace:

java.lang.NoClassDefFoundError: Could not initialize class com.notnoop.apns.internal.Utilities
at com.notnoop.apns.ApnsServiceBuilder.withCert(ApnsServiceBuilder.java:118)
at com.company.project.apns.service.impl.ApplePushService.(ApplePushService.java:183)
...
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:861)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerList.handle(HandlerList.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:828)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)

What is the problem? Anyone with an idea?