-1

For core java conversation service example working fine,

For spring mvc it's shows error like,

"Exception in thread "main" java.lang.NoSuchMethodError: com.ibm.watson.developer_cloud.conversation.v1.ConversationService.createServiceCall(Lokhttp3/Request;Lcom/ibm/watson/developer_cloud/http/ResponseConverter;)Lcom/ibm/watson/developer_cloud/http/ServiceCall; at com.ibm.watson.developer_cloud.conversation.v1.ConversationService.message(ConversationService.java:89)"

I am using following example

ConversationService service = new ConversationService(ConversationService.VERSION_DATE_2017_02_03,"username", "password");

Scanner sc = new Scanner(System.in);
String workspaceId = "workspaceId ";
String str = "open",response1;

do {
    System.out.println("Start chat");
    str = sc.nextLine();
    MessageRequest newMessage = new MessageRequest.Builder().inputText(str).build();
    MessageResponse response = service.message(workspaceId, newMessage).execute();
    response1 = response.getText().toString();
    System.out.println(response1.replace("[","").replace("]",""));
    //System.out.println(response1);
} while(!(str.contains("bye")));
Filburt
  • 17,626
  • 12
  • 64
  • 115
madhu
  • 113
  • 1
  • 6

1 Answers1

1

You can see in the Official Documentation JAVA SDK for use IBM Watson API's that they user this example:

Dependency (Maven)

<dependency>
    <groupId>com.ibm.watson.developer_cloud</groupId>
    <artifactId>conversation</artifactId>
    <version>3.8.0</version>
</dependency>

Gradle:

'com.ibm.watson.developer_cloud:conversation:3.8.0'

Code to Use the Conversation service to identify intents, entities, and conduct conversations:

//set version
ConversationService service = new ConversationService(ConversationService.VERSION_DATE_2017_03_02);

//setUsername and you Password inside your Conversation Service (Service Credentials)
service.setUsernameAndPassword("<username>", "<password>");
//send a Message from your code, in this case "Hi"
MessageRequest newMessage = new MessageRequest.Builder().inputText("Hi").build();
//set your workspace_id for use the conversation you wants
MessageResponse response = service.message("<workspace-id>", newMessage).execute();
System.out.println(response);

I'm not expert in Java Language, but, this works fine to me. You can see in the SDK the Conversation Service waiting for the parameters version_date, username, password. But, they use one condition setUsernameAndPassword. And I think this is the problem.

Check the #83 line from the Java SDK for use conversation:

  public ConversationService(final String versionDate, String username, String password) {
    this(versionDate);
    //set username with this
    setUsernameAndPassword(username, password);
  }
Sayuri Mizuguchi
  • 5,250
  • 3
  • 26
  • 53