alexa-samples / alexa-smarthome

Resources for Alexa Smart Home developers.
https://alexa.design/smarthome
Other
680 stars 336 forks source link

java.lang.NullPointerException #106

Closed cfmui closed 10 months ago

cfmui commented 5 years ago

Now I am developing a java lambda function and testing on the function, but there is an issue: the test case start session or close session works fine, but the discovery directive doesn't work, and the exception information is (I am using the AWS LWA authentication, and the ask-sdk version is : 2.5.2): java.lang.NullPointerException: java.lang.NullPointerException java.lang.NullPointerException at com.amazon.ask.Skill.invoke(Skill.java:74) at com.amazon.ask.Skill.invoke(Skill.java:64) at com.amazon.ask.SkillStreamHandler.handleRequest(SkillStreamHandler.java:66).

and also when the discovery directive comes from my skill, it print NullPointerException as above,here are my lambda test samples: <<=======start session(function test OK)====>> { "version": "1.0", "session": { "new": true, "sessionId": "amzn1.echo-api.session.123456789012", "application": { "applicationId": "amzn1.ask.skill.0ave7bda-681c-4518-7732-13kds1bc1842" }, "user": { "userId": "amzn1.ask.account.testUser" }, "attributes": {} }, "context": { "AudioPlayer": { "playerActivity": "IDLE" }, "System": { "application": { "applicationId": "amzn1.ask.skill.0ave7bda-681c-4518-7732-13kds1bc1842" }, "user": { "userId": "amzn1.ask.account.testUser" }, "device": { "supportedInterfaces": { "AudioPlayer": {} } } } }, "request": { "type": "LaunchRequest", "requestId": "caba13a7-ff7c-11e8-8bc3-df2204af35ce", "timestamp": "2016-10-27T18:21:44Z", "locale": "en-US" } }

<<=======discovery directive(function test NullPointerException====>> { "directive": { "header": { "namespace": "Alexa.Discovery", "name": "Discover", "payloadVersion": "3", "messageId": "1bd5d003-31b9-476f-ad03-71d471922820" }, "payload": { "scope": { "type": "BearerToken", "token": "some-access-token" } } } }

*****And here is my smart home stream handler:

public SmartHomeStreamHandler() { super(getSkill()); log.info("===SmartHomeStreamHandler inited.."); System.out.println("===SmartHomeStreamHandler inited.."); }

private static Skill getSkill() {
    System.out.println("skill addRequestHandlers start...");
    StandardSkillBuilder skb = Skills.standard()
            .withSkillId("amzn1.ask.skill.0ave7bda-681c-4518-7732-13kds1bc1842")
            .withAutoCreateTable(true)
            .addRequestHandlers(
            new CancelandStopIntentHandler(), 
            new SwitchIntentHandler(),
            new HelpIntentHandler(), 
            new LaunchRequestHandler(), 
            new SessionEndedRequestHandler()); 

    System.out.println("skill build start...");
    Skill skill = skb.build();
    System.out.println("skill build end!skill="+skill);

    return skill;
}
aszk commented 10 months ago

This Issues is for alexa-smarthome(Python). If you still have the same issue, please contact us through https://alexa.design/contactus (However we don't provide general coding guidance.)