Skip to main content
October 1, 2011
Answered

Please help, time sensitive... Class path

  • October 1, 2011
  • 2 replies
  • 1715 views

I'm trying to set up apple's push notification on my new CF server. I have a set of files that I need to use for this to work. However, I cannot get Coldfusion to "pick" them up and use the classes. I've tried for 6 hours to add a class path. My code to use the class looks like this: com.notnoop.apns. My error is that it cannot find the classpath. I've tried putting the com folder into the (cf install directory)/lib and tried manually adding the class path but no luck. Help please.

<!-- alert user -->

<cffunction name="alertUser" access="remote" returntype="string" output="no">

<cfargument name="send_token" type="string" required="yes">

   

    <cfset returnString = "Notification Sent">

    <cfset APNS = createObject( "java", "com.notnoop.apns.APNS" )>

<cfset APNSService = createObject( "java", "com.notnoop.apns.APNS" ).newService()

    .withCert("/secretLink", "******")

    .withSandboxDestination()

    .build() />

   

    <cfset payload = createObject( "java", "com.notnoop.apns.APNS" ).newPayload()

    .badge(1)

    .alertBody("Alert")

    .actionKey("View")

    .sound("PushNotification.caf")

    .build()/>

   

    <cfset token = '#send_token#'>

    <cfset APNSNotification = createObject ("java", "com.notnoop.apns.SimpleApnsNotification").init(javacast("string",token),javacast("string",payload)) />

    <cfset APNSService.push(APNSNotification)>

    <cfreturn returnString >

</cffunction>

<!-- -->

<!-- -->

<!-- -->

    This topic has been closed for replies.
    Correct answer 12Robots

    After just re-reading your question I think I have figured it out. This sentence:

    " I've tried putting the com folder into the (cf install directory)/lib and tried manually adding the class path but no luck. Help please."

    Indicates to me that you downloaded the source code, but did not compile it.

    Java is not like ColdFusion. You cannot just put source code into a directory and expect it to run. You *must* compile it first.

    The link I included in the other post has a precompiled version of the library with the needed dependencies. Put *that* into your /lib dir and restart CF.  Delete that com folder so that it does not cause any trouble while you're at it.

    2 replies

    12Robots
    12RobotsCorrect answer
    Participating Frequently
    October 1, 2011

    After just re-reading your question I think I have figured it out. This sentence:

    " I've tried putting the com folder into the (cf install directory)/lib and tried manually adding the class path but no luck. Help please."

    Indicates to me that you downloaded the source code, but did not compile it.

    Java is not like ColdFusion. You cannot just put source code into a directory and expect it to run. You *must* compile it first.

    The link I included in the other post has a precompiled version of the library with the needed dependencies. Put *that* into your /lib dir and restart CF.  Delete that com folder so that it does not cause any trouble while you're at it.

    October 1, 2011

    Does the entire zip stay zipped up and added to the directory? I'm really confused as to what actually goes into the lib folder.

    12Robots
    Participating Frequently
    October 1, 2011

    *Just* the .jar file that I just linked for you, as is. That's the only thing that needs to go in the lib folder.  No .zip files are needed and you don't need to unzip anything.

    12Robots
    Participating Frequently
    October 1, 2011

    It seems to be working fine for me after putting it into my {CF}/lib dir and restarting ColdFusion.

    Let me ask you a few questions (sorry if any of them insult your intelligence)

    1. Did you download the source code? If so, did you compile it?

    2. Did you download a .jar?

    3. Did you get the jar with the dependencies? (https://github.com/downloads/notnoop/java-apns/apns-0.1.5-jar-with-dependencies.jar)

    4. Did you remember to restart ColdFusion?

    5. Are you running ColdFusion in standard or multiserver mode?

    6. What is the exact error message?

    Inspiring
    August 27, 2012

    Is there any similar push notification solution but this time for the Android?

    Something similar to this tutorial but using the new Android GCM:

    http://www.raymondcamden.com/index.cfm/2010/9/13/Guest-Post-Apple-Push-Notifications-From-ColdFusion-in-Ten-Minutes-or-Less

    Thanks in advance

    Talal