0

I'm building an application to send push notifications to Apple devices from ColdFusion 8 using notnoop's java-apns library, and when calling a method in the library, I'm receiving "method not found" exception, even though the method is clearly defined in the library (line 161). I am able to send push notifications successfully, just this one method is not working. What is possibly wrong here???

Code:

<cfscript>
    LOCAL.APNSService =
        CreateObject("java", "com.notnoop.apns.APNS").newService()
            .withCert(
                "MyCert.p12",
                "MyPassword"
                )
            .withProductionDestination()
            .build();

    LOCAL.APNSService.start();
    LOCAL.InactiveDevices = LOCAL.APNSService.getInactiveDevices();

    LOCAL.payload =
        CreateObject("java", "com.notnoop.apns.APNS").newPayload()
            .badge(1)
            .alertBody("Hello, world.")
            .sound("PushNotification.caf")
            .build();

    LOCAL.APNSNotification =
        CreateObject("java", "com.notnoop.apns.SimpleApnsNotification")
            .init(
                JavaCast("string", LOCAL.MyDeviceToken),
                JavaCast("string", LOCAL.payload)
                );
    LOCAL.APNSService.push(LOCAL.APNSNotification);

    LOCAL.APNSService.stop();
</cfscript>

Exception:

The getInactiveDevices method was not found.

Stack Trace:

coldfusion.runtime.java.MethodSelectionException: The getInactiveDevices method was not found.
at coldfusion.runtime.java.ObjectHandler.findMethodUsingCFMLRules(ObjectHandler.java:322)
at coldfusion.runtime.StructBean.invoke(StructBean.java:527)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2300)
7
  • Shot in the dark.. I remember reading something about a conflict in certain versions of CF, due to the usage of slf4j . Check the CF \lib directory. Does it include a version of the slf4j jar? If yes, that could be the problem. Use a zip tool to open the apns jar and remove the entire org.slf4j.* package. Then restart CF.
    – Leigh
    Sep 18, 2014 at 17:08
  • @Leigh I checked the CF_ROOT\lib directory, and there is no slf4j.jar, nor is there one in the JRE libe directory. Sep 18, 2014 at 21:11
  • Hm.. it may have been a CF9+ issue. It was a long shot anyway. Unfortunately I do not have access to CF8 right now. For grins, try creating an instance of one of the classes just be certain ie createObject("java", "org.slf4j.LoggerFactory"). If it throws a class not found error, then you are right.
    – Leigh
    Sep 18, 2014 at 21:17
  • <cfset LOCAL.Object = createObject("java", "org.slf4j.LoggerFactory") /> does not throw an error. Sep 18, 2014 at 21:20
  • Ugh.. silly me. That is not a good test. It would work anyway since you already have the agns jar with dependencies (includes slf4j) in your class path. I assume you dumped the actual object ie LOCAL.APNSService and verified the method is there? Is there anything else listed in the stack trace OR CF error logs? Sometimes the cause is further down in the chained message.
    – Leigh
    Sep 18, 2014 at 21:42

1 Answer 1

1

Benn Linger created this workaround: http://www.bennlinger.com/uploads/get_inactive_devices.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.