Author Topic: ERROR [BotsManager] - ChatBotFactory service not found in jar  (Read 4142 times)

Offline Rajnish@49

  • Jr. Member
  • **
  • Posts: 56
  • Karma: -1
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";
    }
}
« Last Edit: June 16, 2020, 08:36:47 PM by Rajnish@49 »

Offline Kubig

  • Hero Member
  • *****
  • Posts: 2739
  • Karma: 44
Re: ERROR [BotsManager] - ChatBotFactory service not found in jar
« Reply #1 on: June 17, 2020, 12:35:57 AM »
Did you add all your referenced libraries?
Genesys certified professional consultant (GVP, SIP, GIR and Troubleshooting)

Offline Rajnish@49

  • Jr. Member
  • **
  • Posts: 56
  • Karma: -1
Re: ERROR [BotsManager] - ChatBotFactory service not found in jar
« Reply #2 on: June 17, 2020, 12:42:20 AM »
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>

Offline Kubig

  • Hero Member
  • *****
  • Posts: 2739
  • Karma: 44
Re: ERROR [BotsManager] - ChatBotFactory service not found in jar
« Reply #3 on: June 17, 2020, 01:13:46 AM »
Quote
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.
Genesys certified professional consultant (GVP, SIP, GIR and Troubleshooting)

Offline Rajnish@49

  • Jr. Member
  • **
  • Posts: 56
  • Karma: -1
Re: ERROR [BotsManager] - ChatBotFactory service not found in jar
« Reply #4 on: June 17, 2020, 04:33:02 AM »
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

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7623
  • Karma: 56330
Re: ERROR [BotsManager] - ChatBotFactory service not found in jar
« Reply #5 on: June 17, 2020, 05:03:53 AM »
Check the references at NetBeans. You must add that jar into the lib

Enviado de meu SM-N9600 usando o Tapatalk


Offline Rajnish@49

  • Jr. Member
  • **
  • Posts: 56
  • Karma: -1
Re: ERROR [BotsManager] - ChatBotFactory service not found in jar
« Reply #6 on: June 30, 2020, 05:24:10 AM »
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>
  </build>


In project Directory I am using file=jar-with-deps-with-exclude.xml
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
  <id>exclude-classes</id>
  <formats>
    <format>jar</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <dependencySets>
    <dependencySet>
      <outputDirectory>/</outputDirectory>
      <useProjectArtifact>false</useProjectArtifact>
      <unpack>true</unpack>
      <scope>runtime</scope>
      <excludes>
        <exclude>org.slf4j:slf4j-api</exclude>
      </excludes>
    </dependencySet>
  </dependencySets>
  <fileSets>
    <fileSet>
      <outputDirectory>/</outputDirectory>
      <directory>${project.build.outputDirectory}</directory>
    </fileSet>
  </fileSets>
</assembly>