ERROR [BotsManager] - ChatBotFactory service not found in jar

Hello All,

I am creating a ChatBot using NetBeans 11.1. I am getting this error in DMS while loading of Bot.
ERROR [BotsManager] - ChatBotFactory service not found in jar AmazonLexRestAccess_V1-1-jar-with-dependencies.jar
ERROR [BotsManager] - Failed to load bot plugin from: AmazonLexRestAccess_V1-1-jar-with-dependencies.jar

Below is the code:-

AmazonLexRestAccess_V1.java

public class AmazonLexRestAccess_V1 implements ChatBot {
private ChatBotPlatform cbpInstance;
private Logger logger; // bot-session aware logger
private GenesysChatSession session;

@Override
public void setCbpInstance(ChatBotPlatform cbpInstance) {
    this.cbpInstance = cbpInstance;
    this.logger = cbpInstance.getLogger();
}

@Override
public void onCommandStart(GenesysChatSession session, int eventJoinedId, EspRequestParameters espParameters) {
    // TODO to be implemented
    
    this.session = session;
    cbpInstance.sendMessage("Thank you for contact Thermo Fisher scientific!! How may i help you today?");
}

@Override
public void onCommandStop(StopReason reason, ChatEventInfo eventInfo, EspRequestParameters espParameters) {
    // TODO to be implemented
}

@Override
public void onSessionActivity(ChatEventInfo eventInfo) {
    // TODO to be implemented
            ChatUserInfo originator = session.getParticipant(eventInfo.getUserId());
    if (eventInfo.getEventType() == EventType.MESSAGE && originator.getUserType() != UserType.SYSTEM && originator.getUserType() != UserType.EXTERNAL) 
    {
        if (eventInfo.getMessageText().matches("stop(:(keep_alive|force_close|close_if_no_agents))?")) 
        {
            Action action = Action.KEEP_ALIVE;
            String[] tokens = eventInfo.getMessageText().split(":");
            if (tokens.length > 1) 
            {
                action = Action.valueOf(tokens[1].toUpperCase());
            }
            
            // The bot decides to stop execution.
            // The bot will be removed from chat session and discarded in BGS.
            // If running in waiting mode, the interaction will be released in workflow.
            // If the bot need to communicate something to workflow, it could invoke updateUserdata at this moment.
            logger.info("Leaving chat session with after-action: " + action.name());
            cbpInstance.leaveSession(action);
        } 
        else 
        {
           logger.info("Message Typed"+eventInfo.getMessageText());
            cbpInstance.sendMessage(eventInfo.getMessageText());
            
            
            
            
            AWSCredentials awsCreds=new BasicAWSCredentials("AccessKey","SecretKey");

            //AmazonLexModelBuilding buildClient=AmazonLexModelBuildingClientBuilder        
            AmazonLexRuntime client= AmazonLexRuntimeClientBuilder.standard().withRegion(Regions.US_EAST_1).withCredentials(new AWSStaticCredentialsProvider(awsCreds)).build();
            
            cbpInstance.sendMessage("Creds sent");
            PostTextRequest postRequest=new PostTextRequest();
            postRequest.setBotAlias("BookATrip_VFirst");
            postRequest.setBotName("BookATrip_VFirst");
            postRequest.setUserId("BotAccessRestAPI");
            postRequest.setInputText(eventInfo.getMessageText());
            
            cbpInstance.sendMessage("RequestMessage sent");
            
            logger.info("Message Executed Till Build PostRequest");
            
            
            PostTextResult textResult=client.postText(postRequest);
            
            cbpInstance.sendMessage(textResult.getMessage());
            


            logger.info("Echoing back message: " + eventInfo.getMessageText());
            cbpInstance.sendMessage(eventInfo.getMessageText());
            cbpInstance.sendMessage(eventInfo.getMessageText());
            
        }
    }
}

@Override
public void onCommandUpdate(EspRequestParameters espParameters) {
    // TODO to be implemented
}

}

AmazonLexRestAccess_V1Factory

public class AmazonLexRestAccess_V1Factory implements ChatBotFactory {
private static final Logger LOG = LoggerFactory.getLogger(AmazonLexRestAccess_V1Factory.class);

public void initialize(KeyValueMap configuration) {
    // TODO to be implemented
}

public void configurationUpdated(KeyValueMap configuration) {
    // TODO to be implemented
}

public void shutdown() {
    // TODO to be implemented
}

public ChatBot createChatBot(KeyValueMap espParameters, ChatInteractionInfo interactionInfo, BotCreationAttributes botCreationAttributes) {
    return new AmazonLexRestAccess_V1();
}

@Override
public String getBotId() {
    return "AmazonLexRestAccess_V1";
}

}

Did you add all your referenced libraries?

Thanks Kubig…

I am very new to netBeans. so apologies…

While i Clean & Build. Only one Jar file is getting generated. And place the same in bots-repo.
Could you please help where would need to add those libraries?

I have added reference in my code and pom.xml as well.

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.lexruntime.AmazonLexRuntime;
import com.amazonaws.services.lexruntime.AmazonLexRuntimeClientBuilder;
import com.amazonaws.services.lexruntime.model.PostTextRequest;
import com.amazonaws.services.lexruntime.model.PostTextResult;

    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-core</artifactId>
        <version>1.11.96</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-lex</artifactId>
        <version>1.11.96</version>
        <type>jar</type>
    </dependency>
If your bot needs to use 3rd party libraries, you have the option to use maven-assembly-plugin and these libraries will be included into the resulting JAR file.

I am using maven-assembly-plugin to generate one jar file with all dependencies. DMS>>BGS throws error
2020-06-16T19:29:04,324 Std 45302 (CBP.platform) ERROR [BotsManager] - ChatBotFactory service not found in jar: LexV2-1.0-SNAPSHOT-jar-with-dependencies.jar
2020-06-16T19:29:04,324 Std 45302 (CBP.platform) ERROR [BotsManager] - Failed to load bot plugin from: LexV2-1.0-SNAPSHOT-jar-with-dependencies.jar

Check the references at NetBeans. You must add that jar into the lib

Enviado de meu SM-N9600 usando o Tapatalk

Finally I was able to figure out the problem with Help of Genesys. We would need to generate Jar files as build with dependencies and using below build properties in pom.xml and used ChatBot API of DMS version=9.1.003.12

<build>
<plugins>
  <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.3</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <descriptors>
        <descriptor>jar-with-deps-with-exclude.xml</descriptor>
      </descriptors>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
      <encoding>UTF-8</encoding>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>2.4.3</version>
    <configuration>
      <encoding>UTF-8</encoding>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.0.2</version>
    <configuration>
      <archive>
        <manifest>
          <addDefaultImplementationEntries>false</addDefaultImplementationEntries>
        </manifest>
      </archive>
    </configuration>
  </plugin>
</plugins>

In project Directory I am using file=jar-with-deps-with-exclude.xml

<?xml version="1.0" encoding="UTF-8"?> exclude-classes jar false / false true runtime org.slf4j:slf4j-api / ${project.build.outputDirectory}