question

Lawrence Krubner avatar image
Lawrence Krubner asked

attempting to use the Amazon SDK

I know there's already been a request that Amazon make its SDK available via the main Maven repository. I would like to second that request. I am trying to use the Amazon SDK in my Clojure app, and this is not going well. In theory Leinengen (the main Clojure build tool) allows me to use any Java files simply by putting them in src/java and specifying the path in my project file, but in reality I'm seeing the kind of dependencies issues that nobody should really need to deal with in the year 2016. If I : git clone git@github.com:amzn/alexa-skills-kit-java.git and then: cp -r ../../alexa-skills-kit-java/src/com/amazon/* src/java/com/amazon/ I still end up with these kinds of dependency issues: Compiling 47 source files to /Users/lkrubner/projects/salesvoiceapp/salescricket/target/classes /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/Session.java:16: error: package org.apache.commons.lang3 does not exist import org.apache.commons.lang3.Validate; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/slu/Intent.java:17: error: package org.apache.commons.lang3 does not exist import org.apache.commons.lang3.Validate; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/slu/Slot.java:13: error: package org.apache.commons.lang3 does not exist import org.apache.commons.lang3.Validate; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/authentication/ApplicationIdVerifier.java:17: error: package org.slf4j does not exist import org.slf4j.Logger; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/authentication/ApplicationIdVerifier.java:18: error: package org.slf4j does not exist import org.slf4j.LoggerFactory; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/authentication/ApplicationIdVerifier.java:29: error: cannot find symbol private static final Logger log = LoggerFactory.getLogger(ApplicationIdVerifier.class); ^ symbol: class Logger location: class ApplicationIdVerifier /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/IntentRequest.java:15: error: package org.apache.commons.lang3 does not exist import org.apache.commons.lang3.Validate; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/lambda/SpeechletRequestStreamHandler.java:30: error: package com.amazonaws.services.lambda.runtime does not exist import com.amazonaws.services.lambda.runtime.Context; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/lambda/SpeechletRequestStreamHandler.java:31: error: package com.amazonaws.services.lambda.runtime does not exist import com.amazonaws.services.lambda.runtime.RequestStreamHandler; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/lambda/SpeechletRequestStreamHandler.java:50: error: cannot find symbol public abstract class SpeechletRequestStreamHandler implements RequestStreamHandler { ^ symbol: class RequestStreamHandler /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/lambda/SpeechletRequestStreamHandler.java:86: error: cannot find symbol public final void handleRequest(InputStream input, OutputStream output, Context context) ^ symbol: class Context location: class SpeechletRequestStreamHandler /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/SessionStartedRequest.java:15: error: package org.apache.commons.lang3 does not exist import org.apache.commons.lang3.Validate; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/LaunchRequest.java:15: error: package org.apache.commons.lang3 does not exist import org.apache.commons.lang3.Validate; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/SessionEndedRequest.java:15: error: package org.apache.commons.lang3 does not exist import org.apache.commons.lang3.Validate; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/servlet/SpeechletServlet.java:28: error: package org.apache.commons.lang3 does not exist import org.apache.commons.lang3.StringUtils; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/servlet/SpeechletServlet.java:29: error: package org.slf4j does not exist import org.slf4j.Logger; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/servlet/SpeechletServlet.java:30: error: package org.slf4j does not exist import org.slf4j.LoggerFactory; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/servlet/SpeechletServlet.java:59: error: cannot find symbol private static final Logger log = LoggerFactory.getLogger(SpeechletServlet.class); ^ symbol: class Logger location: class SpeechletServlet /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/ApplicationIdSpeechletRequestVerifier.java:17: error: package org.slf4j does not exist import org.slf4j.Logger; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/ApplicationIdSpeechletRequestVerifier.java:18: error: package org.slf4j does not exist import org.slf4j.LoggerFactory; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/TimestampSpeechletRequestVerifier.java:15: error: package org.slf4j does not exist import org.slf4j.Logger; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/TimestampSpeechletRequestVerifier.java:16: error: package org.slf4j does not exist import org.slf4j.LoggerFactory; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/ApplicationIdSpeechletRequestVerifier.java:28: error: cannot find symbol private static final Logger log = LoggerFactory ^ symbol: class Logger location: class ApplicationIdSpeechletRequestVerifier /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/TimestampSpeechletRequestVerifier.java:36: error: cannot find symbol private static final Logger log = LoggerFactory.getLogger(SpeechletRequestHandler.class); ^ symbol: class Logger location: class TimestampSpeechletRequestVerifier /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/CardSpeechletResponseVerifier.java:13: error: package org.apache.commons.lang3 does not exist import org.apache.commons.lang3.StringUtils; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/CardSpeechletResponseVerifier.java:14: error: package org.slf4j does not exist import org.slf4j.Logger; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/CardSpeechletResponseVerifier.java:15: error: package org.slf4j does not exist import org.slf4j.LoggerFactory; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/CardSpeechletResponseVerifier.java:32: error: cannot find symbol private static final Logger log = LoggerFactory.getLogger(CardSpeechletResponseVerifier.class); ^ symbol: class Logger location: class CardSpeechletResponseVerifier /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/OutputSpeechSpeechletResponseVerifier.java:13: error: package org.apache.commons.lang3 does not exist import org.apache.commons.lang3.StringUtils; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/OutputSpeechSpeechletResponseVerifier.java:14: error: package org.slf4j does not exist import org.slf4j.Logger; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/OutputSpeechSpeechletResponseVerifier.java:15: error: package org.slf4j does not exist import org.slf4j.LoggerFactory; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/OutputSpeechSpeechletResponseVerifier.java:33: error: cannot find symbol private static final Logger log = LoggerFactory ^ symbol: class Logger location: class OutputSpeechSpeechletResponseVerifier /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/ResponseSizeSpeechletResponseVerifier.java:15: error: package org.slf4j does not exist import org.slf4j.Logger; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/ResponseSizeSpeechletResponseVerifier.java:16: error: package org.slf4j does not exist import org.slf4j.LoggerFactory; ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/ResponseSizeSpeechletResponseVerifier.java:31: error: cannot find symbol private static final Logger log = LoggerFactory ^ symbol: class Logger location: class ResponseSizeSpeechletResponseVerifier /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/Session.java:267: error: cannot find symbol Validate.notBlank(sessionId, "SessionId must be defined"); ^ symbol: variable Validate location: class Builder /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/slu/Intent.java:143: error: cannot find symbol Validate.notBlank(name, "Intent name must be defined"); ^ symbol: variable Validate location: class Builder /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/slu/Slot.java:133: error: cannot find symbol Validate.notBlank(name, "Slot name must be defined"); ^ symbol: variable Validate location: class Builder /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/authentication/ApplicationIdVerifier.java:29: error: cannot find symbol private static final Logger log = LoggerFactory.getLogger(ApplicationIdVerifier.class); ^ symbol: variable LoggerFactory location: class ApplicationIdVerifier /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/IntentRequest.java:107: error: cannot find symbol Validate.notBlank(requestId, "RequestId must be defined"); ^ symbol: variable Validate location: class Builder /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/lambda/SpeechletRequestStreamHandler.java:85: error: method does not override or implement a method from a supertype @Override ^ /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/SessionStartedRequest.java:80: error: cannot find symbol Validate.notBlank(requestId, "RequestId must be defined"); ^ symbol: variable Validate location: class Builder /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/LaunchRequest.java:80: error: cannot find symbol Validate.notBlank(requestId, "RequestId must be defined"); ^ symbol: variable Validate location: class Builder /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/SessionEndedRequest.java:128: error: cannot find symbol Validate.notBlank(requestId, "RequestId must be defined"); ^ symbol: variable Validate location: class Builder /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/servlet/SpeechletServlet.java:59: error: cannot find symbol private static final Logger log = LoggerFactory.getLogger(SpeechletServlet.class); ^ symbol: variable LoggerFactory location: class SpeechletServlet /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/servlet/SpeechletServlet.java:171: error: cannot find symbol if (!StringUtils.isBlank(commaDelimitedListOfSupportedApplicationIds)) { ^ symbol: variable StringUtils location: class SpeechletServlet /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/servlet/SpeechletServlet.java:191: error: cannot find symbol if (!StringUtils.isBlank(timestampToleranceAsString)) { ^ symbol: variable StringUtils location: class SpeechletServlet /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/ApplicationIdSpeechletRequestVerifier.java:28: error: cannot find symbol private static final Logger log = LoggerFactory ^ symbol: variable LoggerFactory location: class ApplicationIdSpeechletRequestVerifier /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/TimestampSpeechletRequestVerifier.java:36: error: cannot find symbol private static final Logger log = LoggerFactory.getLogger(SpeechletRequestHandler.class); ^ symbol: variable LoggerFactory location: class TimestampSpeechletRequestVerifier /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/CardSpeechletResponseVerifier.java:32: error: cannot find symbol private static final Logger log = LoggerFactory.getLogger(CardSpeechletResponseVerifier.class); ^ symbol: variable LoggerFactory location: class CardSpeechletResponseVerifier /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/CardSpeechletResponseVerifier.java:46: error: cannot find symbol StringUtils.length(simpleCard.getContent()) ^ symbol: variable StringUtils location: class CardSpeechletResponseVerifier /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/CardSpeechletResponseVerifier.java:47: error: cannot find symbol + StringUtils.length(simpleCard.getTitle()); ^ symbol: variable StringUtils location: class CardSpeechletResponseVerifier /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/OutputSpeechSpeechletResponseVerifier.java:33: error: cannot find symbol private static final Logger log = LoggerFactory ^ symbol: variable LoggerFactory location: class OutputSpeechSpeechletResponseVerifier /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/OutputSpeechSpeechletResponseVerifier.java:52: error: cannot find symbol int speechContentLength = StringUtils.length(speechContent); ^ symbol: variable StringUtils location: class OutputSpeechSpeechletResponseVerifier /Users/lkrubner/projects/salesvoiceapp/salescricket/src/java/com/amazon/speech/speechlet/verifier/ResponseSizeSpeechletResponseVerifier.java:31: error: cannot find symbol private static final Logger log = LoggerFactory ^ symbol: variable LoggerFactory location: class ResponseSizeSpeechletResponseVerifier 55 errors Compilation of Java sources(lein javac) failed.
alexa skills kitsubmission testing certification
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Lawrence Krubner avatar image
Lawrence Krubner answered
Nevermind. I just noticed Amazon offers a Jar: https://github.com/amzn/alexa-skills-kit-java/tree/master/repo/alexa-skills-kit/alexa-skills-kit/1.1 I'll just use that. Ignore this post.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Lawrence Krubner avatar image
Lawrence Krubner answered
Damn. I can normally use any jar in any Clojure project, via the awesome "localrepo" library, but even after I import this jar: https://github.com/amzn/alexa-skills-kit-java/tree/master/repo/alexa-skills-kit/alexa-skills-kit/1.1/alexa-skills-kit-1.1.jar and even after this is set up as part of my local Maven repo, inside the ~/.m2 folder, when I try to compile, I still get: Compiling salesvoice.core Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory, compiling:(query.clj:1:1) Have others dealt with this issue, when using an SDK that uses slf4j? Is there an obvious way to configure this? And once again, I would urge Amazon to add its Java SDKs to the main repo for Maven. Message was edited by: Lawrence Krubner
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jjaquinta avatar image
jjaquinta answered
Have you added the other jars that come with the SDK to your project? That's a failed dependency to the Apache commons logging stuff. It's pretty clearly defined in the doc. Are you new to Java?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Lawrence Krubner avatar image
Lawrence Krubner answered
I avoid Java as much as I can. I've been forced to learn the Java eco-system since I do a lot of programming in Groovy and Clojure, and they both run on the JVM. In Clojure I can usually use any Java code I need to, although I rarely deal with Maven directly. I'm guessing in this case I need to include the pom.xml file.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Stefan Negritoiu avatar image
Stefan Negritoiu answered
If you picked up Java only to write the Alexa skill, know there are equivalent ASK libraries for all major languages. See the Community Projects section of the forums.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Lawrence Krubner avatar image
Lawrence Krubner answered
I got this working. I'll post my solution here, for all the other developers out there who like working on the JVM but who don't love Java/Maven. I used the Leinengen "localrepo" plugin to install the Amazon SDK like this: lein localrepo install alexa-skills-kit-1.1.jar alexa-sdk 1.1 and this created a very basic pom.xml file here: ~/.m2/repository/alexa-sdk/alexa-sdk/1.1/alexa-sdk-1.1.pom and this file only consisted of: 4.0.0 alexa-sdk alexa-sdk 1.1 alexa-sdk So I opened this file up in emacs and I put the cursor between these 2 lines: alexa-sdk and then I copy and pasted most of the content of this file: https://github.com/amzn/alexa-skills-kit-java/blob/master/samples/pom.xml I copied and that got me passed the dependency errors.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jjaquinta avatar image
jjaquinta answered
>I avoid Java as much as I can. Pity. It's, pretty much, the best (general) language out there. Microsoft and Apple have been trying to kill it for years, and failed. Which says something. But, anyway, it's becoming less fashionable, and if we start fighting over language advocacy, that'll be the end of this forum. :-) >I rarely deal with Maven directly. Maven is something I avoid as much as possible. At least in a professional context. It's main benefit (which it does very well) is pull in webs of dependencies. If something you are depending on needs something else, or those needs change, it just goes and gets them. That's very handy if you are doing something for personal use. If you are doing something professionally, that you make money one, or you care about your code, it is deadly. If you don't really understand the dependencies of what you are using, then you don't understand the circumstances in which they are licensed. You can (to my knowledge) say that you only want maven to pull down libraries with the Apache license. And, since some licenses (GPL) are "viral" and may cause you to publish code, it isn't a liability you want to take on just because a develop tool wanted the library. But back to your issue. The Amazon SDK has all the jar files you need. There is the primary jar file for their code. And then there is a dependency directory with all the dependent library jar files (and their licenses). Instead of just adding the one jar file to your project, you add all the ones they provide to your project. Amazon docs are pretty clear on setting things up. But I think they do assume you are using the Eclipse Development Environment. If you plan on spending any time at all in Java, I do recommend Eclipse. It, too, is falling out of fashion. And there are a few niche environments that are better for specific problems. But it's the best I've seen and used in general. Certainly if you are doing more in the Amazon ecosystem, because of their support for it, it is the development environment of choice.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Lawrence Krubner avatar image
Lawrence Krubner answered
Thank you for all the comments. I am using Leinengen for this app, which is one of the Clojure build tools. It uses Maven in the background, but I rarely need to think about Maven. In this case I did. I think my trick of including the pom.xml file worked okay, but if I run into more problems, I'll try the other approach, of including all the jars that Amazon has posted. That is a good point about the licenses. Before we take investor money I'll need to do an inventory of all the libraries being used.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Galactoise avatar image
Galactoise answered
Sorry I'm late getting to this and you already seem to have solved it a different way, but the standard approach we've used is just to do a maven install via pom of the sdk into our own local repo and then use maven as normal. It's convenient that Amazon actually provides a pom file with the sdk, but it's also incredibly infuriating to know that they already build the damn thing with Maven, but refuse to push it up to Maven Central. It's such a simple thing for them to do, but it would have a huge payoff in terms of ease of use.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Galactoise avatar image
Galactoise answered
Aaaaand now I have to eat crow, because I should've finished getting caught up on the forum threads before posting. Their stuff was recently added to Maven central: http://search.maven.org/#artifactdetails%7Ccom.amazon.alexa%7Calexa-skills-kit%7C1.1%7Cjar
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.