title: Apple Push Notification Service using Javapns
body: <p>I'm using the following code to send notification to the Apple Notification Server.</p>
  
  <pre><code>import javapns.Push;
  import javapns.communication.exceptions.CommunicationException;
  import javapns.communication.exceptions.KeystoreException;
  
  public class APN 
  {
     public static void main(String[] args) {
          try {
              Push.alert("Hello World!", "keystore.p12", "mypassword", false, "myDeviceIdentifier");
          } 
          catch (CommunicationException e) {
             e.printStackTrace();
          } 
          catch (KeystoreException e) {
              e.printStackTrace();
          }
     }
  }
  </code></pre>
  
  <p>I've included all the jars specified at the documentation of <code>Javapns</code>.<br>
  However when I execute this code, it is throwing following exception.</p>
  
  <pre><code>log4j:WARN No appenders could be found for logger (javapns.notification.Payload).
  log4j:WARN Please initialize the log4j system properly.
  log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
  javapns.communication.exceptions.CommunicationException: Communication exception:
  java.net.ConnectException: Operation timed out
  at javapns.communication.ConnectionToAppleServer.getSSLSocket(ConnectionToAppleServer.java:158)
  at javapns.notification.PushNotificationManager.initializeConnection(PushNotificationManager.java:106)
  at javapns.Push.sendPayload(Push.java:171)
  at javapns.Push.alert(Push.java:47)
  at com.mydomain.myapp.APN.main(APN.java:12)
  Caused by: java.net.ConnectException: Operation timed out
  at java.net.PlainSocketImpl.socketConnect(Native Method)
  at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
  at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
  at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
  at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
  at java.net.Socket.connect(Socket.java:529)
  at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:570)
  at com.sun.net.ssl.internal.ssl.SSLSocketImpl.&lt;init&gt;(SSLSocketImpl.java:371)
  at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:71)
  at javapns.communication.ConnectionToAppleServer.getSSLSocket(ConnectionToAppleServer.java:155)
  ... 4 more
  </code></pre>
  
  <p>I've created the .p12 certificate and I've got the device identifier of 64 words length.</p>
  
  <p>Please, suggest me the solution.<Br>
  Any help will be appreciated.</p>