Worklight Event Source, what security test

2019-06-13 20:18发布

问题:

Worklight 6.1, testing in WL Studio on a Mac.

As a follow-up to this question concerning doing background work in a Worklight Server, the accepted answer to which is to use an Event Source.

WL.Server.createEventSource(
   {
       name: "housekeepingEventSource",
       poll: {
           interval: 5,
           onPoll: workToBeDone
       },
       securityTest: "eventTest"
   }
);

The issue concerns which security test to use. Whatever I try I get this error:

Adapter deployment failed: Wrapped java.lang.ClassCastException: org.mozilla.javascript.gen._ (... elisions ...) _chmSecurityService_impl_js_83 cannot be cast to java.lang.String (/integration.js#258)

Referencing this question

I've used this security test:

<mobileSecurityTest name="eventTest"> 
        <testUser realm="wl_anonymousUserRealm"/>
        <testDeviceId provisioningType="none"/>
</mobileSecurityTest>

Hints please ...

回答1:

This was a typo in the poll definition. Sequence was that when security test was incorrectly specified the adapter didn't deploy with other error messages. Once I had a valid security test then the poll was activated, and as it wa`s defective we got the above error.

   poll: {
       interval: 5,
       onPoll: workToBeDone
   },

is wrong, as I should have used a String literal

   poll: {
       interval: 5,
       onPoll: 'workToBeDone'
   },

which if one reads the error message carefully is exactly what it's telling me ...