I am working on a web-app using the Play Framework. I am trying to pass a variable through a dynamic URI. I am following the example shown here. However, I am getting this error:
not enough arguments for method showClients: (clientId: Long)play.mvc.Result. Unspecified value parameter clientId.
routes file:
GET /clients/{clientId} controllers.Application.showClients
Controller Code:
public static Result showClients(Long clientId) {
Client c = clientFinder.byId(clientId);
return ok(client.render(c));
}
URL
http://localhost:9000/clients/1
Does anyone see a problem with my code? After googling around, I have found similar questions, but no one with the exact same problem, so I am thinking it is something simple. Thanks for the help.
Whoops...It looks like I was looking at documentation for a previous version of Play. The current documentation here shows that my routes file should look like this:
GET /clients/:clientId controllers.Application.showClients(clientId : Long)
Thanks to anyone who looked into finding an answer to the question.
Related
I'm following the examples here -> https://github.com/apache/camel-k-examples. Working on 05-knative-source-jira
When running this integration, I'm able to read and log new jira issues just fine, I fall down when I try to use info from the ticket, or respond to the ticket with the jira addComment producer.
I've tried just putting a static ticket number in for the IssueKey option, but I get build errors and can't even get the producer to run.
I've tried tinkering with the URI...
Ex: Changing URI to -> .to("jira://addComment?IssueKey=EQ-7") returns below on build
No signature of method: org.apache.camel.builder.ValueBuilder.to() is applicable for argument types: (String) values: [jira://addComment&IssueKey=EQ-7]
I've tried this with both ? and &, as well as adding properties to the URI with similar results.
I feel like I'm missing something pretty fundamental, so any docs pointers would be well appreciated.
Full integration here
// camel-k: language=groovy
from('knative:channel/jira')
.unmarshal()
.json()
.log('Recieved: ${body}')
.to('direct:ticket')
from("direct:ticket")
.setBody().simple("testing")
.to("jira://addComment?IssueKey=EQ-7")
I ended up sorting through enough docs to find the answer. I'll share details just for others who might find this (or if I google it again).
The key was to
a) Set the required headers for the issue key. Seting headers examples
b) Ensure that my properties are set correctly. I used a configmap to set my properties, and then referenced them as shown below in the URI. I believe this should also be possible through DSL but URI was easiest for me to just get working.
Functional Integration below.
from("direct:ticket")
.setHeader("IssueKey").simple('${body["key"]}')
.setBody().simple("We've recieved the ticket -- we'll update you soon!")
.to("jira://addComment?jiraUrl={{url}}&consumerKey={{consumer_key}}&accessToken={{access_token}}&privateKey={{private_key}}&verificationCode={{verification_code}}")
I'm trying to get a basic Custom Vision image classifier working by following the tutorial in the Azure documentation found here: https://learn.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/quickstarts/image-classification?pivots=programming-language-java
I have followed this tutorial word for word and have spent a couple days trying to work this out. The issue I am having is when running the code I am getting the following stack trace:
Parameter this.client.endpoint() is required and cannot be null.
java.lang.IllegalArgumentException: Parameter this.client.endpoint() is required and cannot be null.
at com.microsoft.azure.cognitiveservices.vision.customvision.training.implementation.TrainingsImpl.createProjectWithServiceResponseAsync(TrainingsImpl.java:2313)
at com.microsoft.azure.cognitiveservices.vision.customvision.training.implementation.TrainingsImpl$TrainingsCreateProjectParameters.execute(TrainingsImpl.java:2401)
at com.microsoft.azure.cognitiveservices.vision.customvision.samples.CustomVisionSamples.ImageClassification_Sample(CustomVisionSamples.java:67)
at com.microsoft.azure.cognitiveservices.vision.customvision.samples.CustomVisionSamples.runSample(CustomVisionSamples.java:46)
at com.microsoft.azure.cognitiveservices.vision.customvision.samples.CustomVisionSamples.main(CustomVisionSamples.java:374)
The endpoint is defined here and passed as a parameter
final String Endpoint = System.getenv("AZURE_CUSTOMVISION_ENDPOINT");
CustomVisionTrainingClient trainClient = CustomVisionTrainingManager.authenticate("https://{Endpoint}/customvision/v3.0/training/", CustomVisionTrainingClientKey).withEndpoint(Endpoint);
CustomVisionPredictionClient predictClient = CustomVisionPredictionManager.authenticate("https://{Endpoint}/customvision/v3.0/prediction/", predictionApiKey).withEndpoint(Endpoint);
While the tutorial doesn't explicitly state to do so I have tried to set the system environment variable AZURE_CUSTOMVISION_ENDPOINT manually with PowerShell and it doesn't work with or without this set.
Am I missing something? Any help would be greatly appreciated!
Fixed my own issue. The environment variables had not set correctly and were null pointers. I replaced the System.getenv call to the string in plain text and this is working correctly.
I have an SOAP 1.1 Service developed with Spring Boot in Java which responses without any problems to any of my requests and deliver a valid SOAP-response.
Now the problem is as soon as I add this service as Service Reference to any .NET/C# project the reference gets created and I can send requests but the response (Which get definitely sent from my SOAP-Service) cant be mapped back and the object in my .NET application is always null.
I already found out what the problem might be but I don't know exactly how (of if it is even possible like this) to change my xsd/wsdl to generate all the sources correctly.
First of all here is my .xsd from my Java Spring Boot project for the generation of the WSDL & Service Reference:
Here is the code from the generated Service Reference from Visual Studio in a C# project:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute([NAMESPACE]/processing", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("processingResponse", Namespace="http://[NAMESPACE]/base", IsNullable=true)]
public processingResponse processing([System.Xml.Serialization.XmlElementAttribute(Namespace="http://[NAMESPACE]/base", IsNullable=true)] processingRequest processingRequest) {
object[] results = this.Invoke("processing", new object[] {
processingRequest});
return ((processingResponse)(results[0]));
}
I found out if I change the following line
[return: System.Xml.Serialization.XmlElementAttribute("processingResponse", Namespace="http://[NAMESPACE]", IsNullable=true)]
and add "Form=System.Xml.Schema.XmlSchemaForm.Unqualified":
[return: System.Xml.Serialization.XmlElementAttribute("processingResponse", Namespace="http://[NAMESPACE]", IsNullable=true, Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
The response gets mapped correctly to my Object and it seem to work like this without any problems at the moment.
The problem is that I want to change my .xsd to generate these sources correctly from the start - I already tried to add Form=Unqualified to the "AppDataDataResult" element inside the "processingResponse" complexType but it doesnt work.
Adding this property directly to the processingResponse Element isn't working either cause it's not possible cause the <xs:element/> is one level beneath the schema definition/tag.
I havent found any concrete solution to this problem cause it seems to be very specific with the Spring Boot Framework Java, and the generation of the wsdl.
I hope someone can help me with this problem cause it doesnt seem to be a big one (Its "only" a attribute which needs to get added during the generation of the sources) but I cant seem to find a solution to this. Thanks in advance for the help!
I found the Problem and it was a really simple fix for this Issue - In my Spring Boot Project I was returning JAXBElements and a Parameter for the response is the "QName" which indicates the Object of the Response. The Problem here was that the SOAP-Response did not have the relevant Namespace to identify the Object during the generation of Sources in .NET. So I added the correct Namespace-URI to the QName-Object and now the objects gets resolved and returns the correct responses:
final QName qname = new QName(NAMESPACE_URI, "processingResponse");
return new JAXBElement<>(qname, ProcessingResponse.class, processingResponse);
In the end it was a pretty stupid/simple problem but I tried everything else but havent tried to most obvious/easiest.
I'm attempting to do a reverse lookup on a route I've created.
The route is defined as such in my routes file:
POST /login controllers.Web.Application.authenticate
However, when I try to do a reverse on it in a form I made, I can't seem to find it. I'm attempting to do a reverse like this:
#helper.form(action = routes.login())) {
rest of the form here...
}
However, the login appears in red in intellij and when attempting to run the program, I get the following error:
play.sbt.PlayExceptions$CompilationException: Compilation error[value login is not a member of object controllers.routes]
I've attempted recompiling the project multiple times and looking around the docs, but it's just not working... Any ideas?
So, an interesting thing happened recently and I found a way to point to the original structure properly. To do so, rather than writing:
routes.Web.Application.authenticate()
As Tyler suggested, I was supposed to write:
Web.routes.Application.authenticate()
Which is totally counter-intuitive and all, but that allows me to use the original package structure.
Edit:
As we discovered in the comments, the reverse router doesn't seem to like sub packages. You should remove the Web part of your package, and move everything up a level, then change the code to be this:
#helper.form(action = routes.Application.authenticate())) {
rest of the form here...
}
Original answer:
You need to refer to the controller function, and not the name of the route, so it should look something like this:
#helper.form(action = routes.Web.Application.authenticate())) {
rest of the form here...
}
I'm developing a skill in Amazon Alexa. I'm trying to test the same using echosim.io but the problem is as below.
My Skill name is MyBot and the same is invocation name.
In echosim.io, When I say Alexa Launch MyBot, it gives the welcome response (The help response that I've coded in). When I say help, it gives me the help response that I've entered.
I've 4 intents say
FaqIntentOne
FIntentOne
FaqIntentTwo
FIntentTwo
And my Sample utterances are as below.
FaqIntentOne what is first answer
FIntentOne give me first answer
FaqIntentTwo what is second answer
FIntentTwo give me second answer
When I run these, Alexa doesn't give me a response.
I've the correct methods and the correct response set there. please let me know why it is not working for the utterances other than the built in ones.
when test in Alexa's test interface in developer.amazon.com, it is giving me the correct response.
This is quite confusing.
Below is how it looks in my code.
if ("FaqIntentOne".equals(intentName) || "FIntentOne".equals(intentName)) {
return getFirstHelp(intent, session);
}
else if ("FaqIntentTwo".equals(intentName) || "FIntentTwo".equals(intentName)) {
return getSecondHelp(intent, session);
}
Thanks
Though Amazon has referred people to echosim, it is not 'official' (it was developed by a 3rd party), so if it works in Amazon's test environment and not in echosim then it is possible that the issue is with echosim.
Otherwise I think you are going to need to look more closely at what is happening in your code, ie. debug it or put in some print statements and compare what happens when invoked in those 2 ways.
If you are running in Lambda - seems to be the most common - then you will need to take a look at CloudWatch logs.