Can't get JavaPNS to work for Push notifications - java

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.

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

Related

JNI Error with Java1.8.0_112 and Apache POI

I have just installed Java1.8.0_112, both jdk and jre 64bit on my Windows 7 machine.
I am attempting to run one of my programs via a .bat file and am getting the following error:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/ss/use
rmodel/Workbook
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.Workbook
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)
... 7 more
I have uninstalled and reinstalled the jre and I have restarted my machine. I have made sure I am pointing to all the libraries needed.
What really baffles me is that this error is showing about the POI workbook, but I have all the apache libraries I need and their appropriate dependencies so I'm not sure why this is an issue. Like I said, runs like a charm in Netbeans on the jdk, but completely implodes when I run it on my desktop via .bat
The program runs just fine in the Netbeans8 environment, which is using the jdk of 1.8.0_112 and the JDK8 binary.
My .bat file is as follows, I've added line breaks for readability:
C:\jre1.8.0_112\bin\java -cp
"T:\Netbeans Projects\MatchReport\build\classes;
S:\ADSJava\Jars\lib\poi-3.15.jar;
S:\ADSJava\Jars\lib\poi-ooxml-3.15.jar;
S:\ADSJava\Jars\lib\poi-ooxml-schemas-3.15.jar;
C:\Users\Jessica\Desktop\lib\xmlbeans-2.6.0.jar;
S:\ADSJava\Jars\lib\dom4j-1.6.1.jar;
S:\ADSJava\Jars\lib\commons-io-2.5.jar;
S:\ADSJava\Jars\lib\junit-4.12.jar;
S:\ADSJava\Jars\lib\commons-codes-1.10.jar;
S:\ADSJava\Jars\lib\commons-collections4-4.1.jar;
C:\Users\Jessica\Desktop\lib\DataServer.jar;
C:\Users\Jessica\Desktop\lib\ucanaccess-3.0.4.jar;
C:\Users\Jessica\Desktop\lib\jackcess-2.1.3.jar;
C:\Users\Jessica\Desktop\lib\xbeans.jar;
C:\Users\Jessica\Desktop\lib\commons-logging-1.0.4.jar;
C:\Users\Jessica\Desktop\lib\hsqldb.jar;
C:\Users\Jessica\Desktop\lib\commons-lang-2.4.jar"
ads.ADSMatchReport2
"Toyota Of Turnersville Control.txt" 2>&1> MatchReportResults.txt
Any help or guidance would be greatly appreciated, thank you!
Found the solution. The .bat file did not like me having libraries on mixed drives. Moving all the libraries to either my C: or the network S: drive solved the issue.
For whatever reason Netbeans was able to handle libraries in multiple locations but the .bat file does not.

Why do I get "A Java Exception has occurred" after I export my application to Jar?

Well, I exported my application into JAR with eclipse, but now whenever I try running it I get the: "A Java Exception has occurred". When I try to run it through command line it says:
C:\Users\Arturas>java -jar D:\Dropbox\EclipseWorkspace\Exports\Dantracio_skaiciu
oklis3.jar
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widge
ts/Composite
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Composite
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)
... 6 more
C:\Users\Arturas>
Any solutions to this? I just hate java for this... It never works on desktops when you want it to... sorry I'm really stressed out from this, I'm overreacting...
Any ideas what could cause this? I doesn't work on other computers as well. Right now it's using Java 1.7. And the application runs perfectly on Eclipse.
You need to get your dependencies. Looks like you are depending on swt, which is not part of the core java language. You'll need to get all the third party jars that you depend on and include them in your classpath. It runs perfectly on eclipse because eclipse takes care of setting up the classpath for you.
You can set the classpath in your manifest file as described in the documentation, or you could include a script to start your application that will use the -cp command when running the jar, or you can use something that will package everything into one monster jar like the solutions to this question.

Error launching Luke(Java App) from WinXP

I downloaded luke-1.0.1.jar (Luke 1.0.1 binary without any dependencies) from http://code.google.com/p/luke/downloads/list.
And I have WinXP, with latest Java 6 downloaded from Oracle/Sun web site.
I run the command line: "java -jar luke-1.0.1.jar" and try to launch Luke, but I got following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/analysis/Analyzer
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.analysis.Analyzer
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)
Could not find the main class: org.getopt.luke.Luke. Program will exit.
Any clue, what shall I do? I totally have no knowledge of Java.
Thanks
Hardy
So Java complains that it cant find a dependency. Which is little surprise since you downloaded a binary without dependencies.
Download the binary with all the dependencies (try the "featured" one) and you should be good.
Use luke-all.jar instead,
http://code.google.com/p/luke/downloads/detail?name=lukeall-1.0.1.jar&can=2&q=
Luke is a tool for examining lucene indices. You need to combine it with Lucene. You can either download Lucene and add appropriare JAR files to the classpath, or download a fatter Luke binary that includes Lucene.

Java Applet failure

I am running a Java web applet on one of my servers. For some reason a particular user cannot access it (an error text appears in place of the applet that reads "Error. Click for details"; it is not text I placed between the tags, i.e., his JRE is installed and appears to at the very least be installed correctly but for some reason it is not working on my applet.
I think it has something to do with his particular "flavor" of JRE - this so-called "HotSpot" version. (see this: http://www.experts-exchange.com/Programming/Languages/Java/Q_24405442.html if you have an EE account, I can't remember mine offhand). I am not too familiar with Java itself or it's varieties - I am merely the implementer of the applet in the page (I did not write it).
The applet works fine for me, and every single other user to date. Also, it should not be referring to file as listed below in his error such as "http://mywebsite.com/java/JavaVersionDisplayApplet/class.class". The file is located at "http://mywebsite.com/java/JavaVersionDisplay.class". According to the applet programmer, his error points to a file that is not even specified anywhere in his code.
The users' error reads:
Java Plug-in 1.6.0_13
Using JRE version 1.6.0_13 Java HotSpot(TM) Client VM
User home directory = C:Documents and Settingsjohn
load: class JavaVersionDisplayApplet.class not found.
java.lang.ClassNotFoundException: JavaVersionDisplayApplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://mywebsite.com/java/JavaVersionDisplayApplet/class.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Exception: java.lang.ClassNotFoundException: JavaVersionDisplayApplet.class
load: class JavaVersionDisplayApplet.class not found.
java.lang.ClassNotFoundException: JavaVersionDisplayApplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://mywebsite.com/java/JavaVersionDisplayApplet/class.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Exception: java.lang.ClassNotFoundException: JavaVersionDisplayApplet.class
I'd start by packaging the application as a jarfile instead of as a set of classfiles. It seems like JavaVersionDisplayApplet.class is being interpreted as a fully-qualified class name...that is, the JVM thinks "JavaVersionDisplayApplet" is a package name and "class" is the class name.
Can you post the contents of the APPLET tag that you're using in the HTML?
A couple of things you might want to look at:
Is he using Chrome? It seems that Chrome and Java don't play well together quite yet.
Is he using a Proxy server? The "connection failed" error may indicate that he is using a Proxy that is allowing the browser through, but not the JRE.
This is the culprit:
Caused by: java.io.IOException: open HTTP connection failed:http://mywebsite.com/java/JavaVersionDisplayApplet/class.class
The JVM is started, but it cannot connect to the server hosting the applet. Does the user connect to mywebsite.com or another name?

Applet loading problem with Win2003 Terminal Server

Applet loading seem to fail with JAVA 1.6 to error java.lang.ClassNotFoundException:
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
I believe this is related to limited security of user accounts under Win2003. Any ideas? The site is trusted. It works with ADMINISTRATOR user.
DiskQUOTA was full.

Categories

Resources