Home Forums Kamanja Forums Problems & Solutions Exception while adding a model

This topic contains 1 reply, has 1 voice, and was last updated by  mohammed alhourani 8 months, 3 weeks ago.

  • Author
    Posts
  • #26327 Reply

    mohammed alhourani

    <pre style=”background-color: #ffffff; color: #000000; font-family: ‘DejaVu Sans Mono’; font-size: 9.0pt;”>I’ve configured the cluster and added input and output messages successfully, I used these commands:
    bash $KAMANJA_HOME/bin/kamanja $KAMANJA_HOME/config/MetadataAPIConfig.properties upload cluster config $KAMANJA_HOME/config/ClusterConfig.json
    bash $KAMANJA_HOME/bin/kamanja $KAMANJA_HOME/config/MetadataAPIConfig.properties add message /home/osboxes/Source/javamodel/src/main/resources/message/RInputMessage_Definition_RModel.json TENANTID tenant1
    bash $KAMANJA_HOME/bin/kamanja $KAMANJA_HOME/config/MetadataAPIConfig.properties add message /home/osboxes/Source/javamodel/src/main/resources/message/ROutputMessage_Definition_RModel.json TENANTID tenant1

    I’m creating a model that depends on a jar file dependency:
    <pre style=”background-color: #ffffff; color: #000000; font-family: ‘DejaVu Sans Mono’; font-size: 9.0pt;”>{
    <span style=”color: #660e7a; font-weight: bold;”>”RModel”</span>: {
    <span style=”color: #660e7a; font-weight: bold;”>”Dependencies”</span>: [<span style=”color: #008000; font-weight: bold;”>”java-model-1.0-SNAPSHOT-jar-with-dependencies.jar”</span>],
    <span style=”color: #660e7a; font-weight: bold;”>”MessageAndContainers”</span>: [
    <span style=”color: #008000; font-weight: bold;”>”com.ligadata.kamanja.samples.messages.RInputMessage”</span>,
    <span style=”color: #008000; font-weight: bold;”>”com.ligadata.kamanja.samples.messages.ROutputMessage”
    </span> ],
    <span style=”color: #660e7a; font-weight: bold;”>”InputTypesSets”</span>: [
    [
    <span style=”color: #008000; font-weight: bold;”>”com.ligadata.kamanja.samples.messages.RInputMessage”
    </span> ]
    ],
    <span style=”color: #660e7a; font-weight: bold;”>”OutputTypes”</span>: [
    <span style=”color: #008000; font-weight: bold;”>”com.ligadata.kamanja.samples.messages.ROutputMessage”
    </span> ]
    }
    }
    And this meta data was also added successfully:
    bash $KAMANJA_HOME/bin/kamanja upload jar /home/osboxes/Source/javamodel/target/java-model-1.0-SNAPSHOT-jar-with-dependencies.jar
    bash $KAMANJA_HOME/bin/kamanja $KAMANJA_HOME/config/MetadataAPIConfig.properties upload compile config /home/osboxes/Source/javamodel/src/main/resources/config/Model_Config_RModel.json

    My Java model depends on one of the classes included in the jar file. when adding the java model it fails and gives this exception:

    [osboxes@osboxes bin]$ $KAMANJA_HOME/bin/kamanja $KAMANJA_HOME/config/MetadataAPIConfig.properties add model java /home/osboxes/Source/javamodel/src/main/java/com/ligadata/kamanja/samples/models/PredictiveRModel.java DEPENDSON RModel TENANTID tenant1
    WARN [main] – DATABASE_SCHEMA remains unset
    WARN [main] – DATABASE_LOCATION remains unset
    WARN [main] – DATABASE_HOST remains unset
    WARN [main] – ADAPTER_SPECIFIC_CONFIG remains unset
    WARN [main] – SSL_PASSWD remains unset
    WARN [main] – AUDIT_PARMS remains unset
    WARN [main] – DATABASE remains unset
    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/home/osboxes/Tools/Kamanja-1.5.3_2.11/lib/system/ExtDependencyLibs2_2.11-1.5.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [jar:file:/home/osboxes/Tools/Kamanja-1.5.3_2.11/lib/system/ExtDependencyLibs_2.11-1.5.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    SLF4J: Actual binding is of type [org.slf4j.helpers.NOPLoggerFactory]
    ERROR [main] – Node Undefined not found in metadata
    Adding the next model in the queue.
    /home/osboxes/Tools/Kamanja-1.5.3_2.11/workingdir/PredictiveRModel/PredictiveRModel.java:38: error: cannot access RInputMessage
    score = RServer.scoreMessageBasedOnModel(predictiveModelName, rInputMessage);
    ^
    class file for com.ligadata.kamanja.samples.messages.RInputMessage not found
    1 error
    ERROR [main] – Compile for PredictiveRModel.java has failed…rc = 1
    ERROR [main] – Command used: ArrayBuffer(sh, -c, /usr/java/jdk1.8.0_121/bin/javac -d /home/osboxes/Tools/Kamanja-1.5.3_2.11/workingdir/PredictiveRModel -cp /home/osboxes/Tools/Kamanja-1.5.3_2.11/lib/system/ExtDependencyLibs_2.11-1.5.3.jar:/home/osboxes/Tools/Kamanja-1.5.3_2.11/lib/system/KamanjaInternalDeps_2.11-1.5.3.jar:/home/osboxes/Tools/Kamanja-1.5.3_2.11/lib/system/ExtDependencyLibs2_2.11-1.5.3.jar:/home/osboxes/Tools/Kamanja-1.5.3_2.11/lib/system/java-model-1.0-SNAPSHOT-jar-with-dependencies.jar:/home/osboxes/Tools/Kamanja-1.5.3_2.11/lib/application/com.ligadata.kamanja.samples.messages_RInputMessage_2000000_1488006293732.jar:/home/osboxes/Tools/Kamanja-1.5.3_2.11/lib/application/com.ligadata.kamanja.samples.messages_ROutputMessage_1000000_1487932385856.jar:/home/osboxes/Tools/Kamanja-1.5.3_2.11/lib/application/com.ligadata.kamanja.samples.messages_ROutputMessage_2000000_1487994562765.jar /home/osboxes/Tools/Kamanja-1.5.3_2.11/workingdir/PredictiveRModel/PredictiveRModel.java)
    ERROR [main] – COMPILER_PROXY: Error compiling model source. Unable to create Jar RC = 1
    ERROR [main] – COMPILER_PROXY: unable to determine model metadata information during AddModel.
    com.ligadata.Exceptions.MsgCompilationFailedException: kamanja.RModel
    at com.ligadata.MetadataAPI.CompilerProxy.parseSourceForMetadata(CompilerProxy.scala:957) ~[KamanjaInternalDeps_2.11-1.5.3.jar:1.5.3]
    at com.ligadata.MetadataAPI.CompilerProxy.compileModelFromSource(CompilerProxy.scala:86) [KamanjaInternalDeps_2.11-1.5.3.jar:1.5.3]
    at com.ligadata.MetadataAPI.ModelUtils$.com$ligadata$MetadataAPI$ModelUtils$$AddModelFromSource(ModelUtils.scala:382) [KamanjaInternalDeps_2.11-1.5.3.jar:1.5.3]
    at com.ligadata.MetadataAPI.ModelUtils$$anonfun$6.apply(ModelUtils.scala:508) [KamanjaInternalDeps_2.11-1.5.3.jar:1.5.3]
    at com.ligadata.MetadataAPI.ModelUtils$$anonfun$6.apply(ModelUtils.scala:507) [KamanjaInternalDeps_2.11-1.5.3.jar:1.5.3]
    at scala.Option.fold(Option.scala:158) [ExtDependencyLibs2_2.11-1.5.3.jar:1.5.3]
    at com.ligadata.MetadataAPI.ModelUtils$.AddModel(ModelUtils.scala:507) [KamanjaInternalDeps_2.11-1.5.3.jar:1.5.3]
    at com.ligadata.MetadataAPI.MetadataAPIImpl$.AddModel(MetadataAPIImpl.scala:2308) [KamanjaInternalDeps_2.11-1.5.3.jar:1.5.3]
    at com.ligadata.MetadataAPI.Utility.ModelService$$anonfun$addModelJava$1.apply(ModelService.scala:223) [KamanjaInternalDeps_2.11-1.5.3.jar:1.5.3]
    at com.ligadata.MetadataAPI.Utility.ModelService$$anonfun$addModelJava$1.apply(ModelService.scala:220) [KamanjaInternalDeps_2.11-1.5.3.jar:1.5.3]
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33) [ExtDependencyLibs2_2.11-1.5.3.jar:1.5.3]
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186) [ExtDependencyLibs2_2.11-1.5.3.jar:1.5.3]
    at com.ligadata.MetadataAPI.Utility.ModelService$.addModelJava(ModelService.scala:220) [KamanjaInternalDeps_2.11-1.5.3.jar:1.5.3]
    at com.ligadata.MetadataAPI.StartMetadataAPI$.route(StartMetadataAPI.scala:513) [KamanjaInternalDeps_2.11-1.5.3.jar:1.5.3]
    at com.ligadata.MetadataAPI.StartMetadataAPI$.main(StartMetadataAPI.scala:354) [KamanjaInternalDeps_2.11-1.5.3.jar:1.5.3]
    at com.ligadata.MetadataAPI.StartMetadataAPI.main(StartMetadataAPI.scala) [KamanjaInternalDeps_2.11-1.5.3.jar:1.5.3]
    Result: {
    “APIResults” : {
    “Status Code” : -1,
    “Function Name” : “AddModel”,
    “Result Data” : null,
    “Result Description” : “Error : Model Compilation Failed, see compliation errors in the log”
    }
    }

    I’m sure that the jar files are in the correct directories for both Application and System folders, did I miss a configuration?

  • #26338 Reply

    mohammed alhourani

    I actually found the issue!

    the issue is related how Kamanja is constructing the namespace and package names while compiling the input and output messages.

    For example when importing an input message an extr postfix is added to the namespace like this:
    <pre style=”background-color: #ffffff; color: #000000; font-family: ‘DejaVu Sans Mono’; font-size: 9.0pt;”>com.ligadata.kamanja.samples.messages.V2000000.RInputMessage;

    The extra postfix V2000000 needs to be added in any extra classes/jars that needs to reference this class. so when I generated my external Jar I have a class RSerser that is referencing:
    com.ligadata.kamanja.samples.messages.RInputMessage;
    that don’t have the auto generated postfix of:
    com.ligadata.kamanja.samples.messages.V2000000.RInputMessage;
    This is why the access issue is happening.
    After I reorganized my packages and classes to have the version postfix it worked!
    But I think in the future this needs to be addresses in a way to make development easier for developers and transparent, or we need to force this convention somehow by making the developer aware when developing external libraries that he needs to follow certain steps so that the model can digest external classes.

Reply To: Exception while adding a model
Your information: