Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError: org.bouncycastle.jce.provider.WrapCipherSpi #44

Closed
GoogleCodeExporter opened this issue Feb 16, 2016 · 4 comments

Comments

@GoogleCodeExporter
Copy link

Hi guys,

when I try to run the code closely modeled after the sample use code snippet 
that's posted on the wiki I get the following error: 
java.lang.NoClassDefFoundError: org.bouncycastle.jce.provider.WrapCipherSpi

It sounds like I'm not linking the bouncy house library properly, but I'm not 
very sure what I'm doing wrong. Anyone have any idea what I'm doing wrong. The 
code is posted below.

Thank you.

vova

import javapns.back.PushNotificationManager;
import javapns.data.PayLoad;
import javapns.data.Device;
import javapns.back.SSLConnectionHelper;

class send_apns{
    // APN Server Host & Port
    private static final String HOST = "gateway.sandbox.push.apple.com";
    private static final int PORT = 2195;

    // Badge
    private static final int BADGE = 66; 

    // iPhone's UDID (64-char device token)
    private static String iPhoneId = "22017e6cad7..........4097b6d";
    private static String certificate = "/root/cgi/APNS/push_certificate.p12";
    private static String passwd = "*****";

    public static void main(String []args){
        try{
            // set up a simple payload
            PayLoad aPayload = new PayLoad();
            aPayload.addBadge(BADGE);
            System.out.println("Payload setup successfull.");

            System.out.println(aPayload);

            // get PushNotification Instance
            PushNotificationManager pushManager = PushNotificationManager.getInstance();

            // Link iPhone's UDID (64-char device token) to a stringName
            pushManager.addDevice("iPhone", iPhoneId);
            System.out.println("iPhone UDID taken.");

            System.out.println("Token: " + pushManager.getDevice("iPhone").getToken());

            // Get iPhone client
            Device client = pushManager.getDevice("iPhone");
            System.out.println("Client setup successfull.");


            // Initialize connection            pushManager.initializeConnection(HOST, PORT, certificate, passwd, SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);            pushManager.sendNotification(client, aPayload);
            System.out.println("Message sent!");

            System.out.println("# of attempts: " + pushManager.getRetryAttempts());
            pushManager.stopConnection();

            System.out.println("done");
        }       
        catch(Exception e){
            e.printStackTrace();
        }       
    }       
}


Original issue reported on code.google.com by vladimir...@gmail.com on 12 Mar 2011 at 10:30

@GoogleCodeExporter
Copy link
Author

Nevermind, figured it out. I hadn't set up my jars properly.

Original comment by vladimir...@gmail.com on 14 Mar 2011 at 6:06

@GoogleCodeExporter
Copy link
Author

Hi, I have the same issue.
What was your solution ?

Original comment by francois...@gmail.com on 30 Mar 2011 at 5:33

@GoogleCodeExporter
Copy link
Author

My problem was that I didn't set up my jars correctly. Here's the relevant part 
of my working build file :

<project name="APNS_Sending" basedir=".">
    <property name="src" location="src"/>
    <property name="build" location="build"/>
    <property name="classes.dir" location="${build}/classes"/>
    <property name="libs.dir" value="${src}/libs"/>
    <property name="jar.dir" value="${build}/jar"/>
    <property name="jar.name" value="apns.jar"/>
    <property name="main-class" value="send_apns"/>    

    <path id="build.classpath">
        <fileset dir="${libs.dir}" includes="**/*.jar"/> 
    </path>

    <target name="compile">
        <mkdir dir="${classes.dir}"/>
        <javac srcdir="${src}" destdir="${classes.dir}">
            <classpath refid="build.classpath"/>
        </javac>
    </target>

    <target name="jar" depends="compile">
        <mkdir dir="${jar.dir}"/>
        <jar jarfile="${jar.dir}/external-libs.jar">
            <zipgroupfileset dir="${libs.dir}" includes="**/*.jar"/>
        </jar>
        <jar destfile="${jar.dir}/${jar.name}" basedir="${classes.dir}">
            <manifest>
                <attribute name="Main-Class" value="${main-class}"/>
            </manifest>
            <zipfileset src="${jar.dir}/external-libs.jar" excludes="META-INF/**/*"/>
        </jar>
    </target>
</project>

My libs directory includes all of the dependency jars that aren't already part 
of the standard java installation:

-rw-r--r-- 1 vova dev 1876535 Mar 12 12:29 bcprov-jdk16-146.jar
-rw-r--r-- 1 vova dev  159509 Mar 12 12:27 commons-io-2.0.1.jar
-rw-r--r-- 1 vova dev  284220 Mar 11 01:55 commons-lang-2.6.jar
-rw-r--r-- 1 vova dev   11249 Mar 13 21:36 jargs.jar
-rw-r--r-- 1 vova dev   52644 Mar 10 19:08 javapns-jdk15-165.jar
-rw-r--r-- 1 vova dev  481534 Mar 11 01:57 log4j-1.2.16.jar

I hope that helps.

vova

Original comment by vladimir...@gmail.com on 30 Mar 2011 at 5:41

@GoogleCodeExporter
Copy link
Author

Original comment by idbill.p...@gmail.com on 6 Apr 2011 at 9:36

  • Changed state: Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant