Topic
  • 6 replies
  • Latest Post - ‏2013-10-30T13:58:44Z by MQVA_javier_vidal
MQVA_javier_vidal
MQVA_javier_vidal
6 Posts

Pinned topic Java primitive operator and additional jar files

‏2013-10-25T11:01:03Z |

Hello, I'm trying to develop a Java primitive operator. The operator class requires other jar files. Even in the eclipse environment the jar file are in the project and correctly found, when I deploy the application to the streams instance I get a ClassNotFound Error related to a class in the jars.

Where I have to put the jar files in the eclipse project in order to be deployed automatically?

Thanks

  • Jason T
    Jason T
    31 Posts

    Re: Java primitive operator and additional jar files

    ‏2013-10-26T00:42:59Z  

    Hello Javier,

    For Streams 3.1... you will need to edit the <operator-name>.xml file to include any external dependencies for your primitive operator.  The required jars have to be part of the operator model XML file as a lib path.  This is documented in step 8 in the following link.

    http://pic.dhe.ibm.com/infocenter/streams/v3r1/topic/com.ibm.swg.im.infosphere.streams.studio.doc/tasks/creating-spl-toolkit-app-elements-javaprim-op.html

    For Streams 3.2... we introduced the @Libraries annotation on the operator class.  It takes the path of the jar as an argument and is documented here.

    http://pic.dhe.ibm.com/infocenter/streams/v3r2/topic/com.ibm.swg.im.infosphere.streams.spl-java-operators.doc/api/com/ibm/streams/operator/model/Libraries.html

    This link talks about operator models and differences between C++ and Java for your reference.

    http://pic.dhe.ibm.com/infocenter/streams/v3r1/topic/com.ibm.swg.im.infosphere.streams.spl-operator-model-reference.doc/doc/javaoperatormodels.html

    Please let me know if you have any further questions about this Javier.

    Jason

  • MQVA_javier_vidal
    MQVA_javier_vidal
    6 Posts

    Re: Java primitive operator and additional jar files

    ‏2013-10-28T11:02:48Z  
    • Jason T
    • ‏2013-10-26T00:42:59Z

    Hello Javier,

    For Streams 3.1... you will need to edit the <operator-name>.xml file to include any external dependencies for your primitive operator.  The required jars have to be part of the operator model XML file as a lib path.  This is documented in step 8 in the following link.

    http://pic.dhe.ibm.com/infocenter/streams/v3r1/topic/com.ibm.swg.im.infosphere.streams.studio.doc/tasks/creating-spl-toolkit-app-elements-javaprim-op.html

    For Streams 3.2... we introduced the @Libraries annotation on the operator class.  It takes the path of the jar as an argument and is documented here.

    http://pic.dhe.ibm.com/infocenter/streams/v3r2/topic/com.ibm.swg.im.infosphere.streams.spl-java-operators.doc/api/com/ibm/streams/operator/model/Libraries.html

    This link talks about operator models and differences between C++ and Java for your reference.

    http://pic.dhe.ibm.com/infocenter/streams/v3r1/topic/com.ibm.swg.im.infosphere.streams.spl-operator-model-reference.doc/doc/javaoperatormodels.html

    Please let me know if you have any further questions about this Javier.

    Jason

    Thanks Jason!

     

    Do you have an example of how to specify the jars in the <cmn:libPath></cmn:libPath>  field. I have to put the jar files delimited by ';'?, only a directory?? I get an error in any case :-(

     

    Thanks

  • Jason T
    Jason T
    31 Posts

    Re: Java primitive operator and additional jar files

    ‏2013-10-28T18:28:07Z  

    Thanks Jason!

     

    Do you have an example of how to specify the jars in the <cmn:libPath></cmn:libPath>  field. I have to put the jar files delimited by ';'?, only a directory?? I get an error in any case :-(

     

    Thanks

    You are welcome Javier.  Here is an example for a single and multipe library declaration.

    For a single library:

              <cmn:managedLibrary>
                <cmn:libPath>path_to_jar_relative_to_this_XML_file</cmn:libPath>
              </cmn:managedLibrary>

    For multiple libraries:

              <cmn:managedLibrary>
                <cmn:libPath>test.jar</cmn:libPath>
                <cmn:libPath>test2.jar</cmn:libPath>
              </cmn:managedLibrary>

    Please let me know if this solves your issue.

    Jason

  • MQVA_javier_vidal
    MQVA_javier_vidal
    6 Posts

    Re: Java primitive operator and additional jar files

    ‏2013-10-29T17:15:25Z  
    • Jason T
    • ‏2013-10-28T18:28:07Z

    You are welcome Javier.  Here is an example for a single and multipe library declaration.

    For a single library:

              <cmn:managedLibrary>
                <cmn:libPath>path_to_jar_relative_to_this_XML_file</cmn:libPath>
              </cmn:managedLibrary>

    For multiple libraries:

              <cmn:managedLibrary>
                <cmn:libPath>test.jar</cmn:libPath>
                <cmn:libPath>test2.jar</cmn:libPath>
              </cmn:managedLibrary>

    Please let me know if this solves your issue.

    Jason

    Thanks Jason!! I'm struggling with that :-)

    In order to remove the errors in the java class of the operator, I've to add the jars to the build path in the eclipse project. Is this required?

    If I do that I resolve the error in the java class, but not in the spl code. This is the error I have:

    Errors:
    - CDISP9164E Operator invocation error for Java primitive twitter.application::TwitterTopicListener
    - CDISP0232E An error was encountered during the generation of the code for the Op_1 operator.
     
    Operator: twitter.application::TwitterTopicListener Op_1
     
    Source: 
    (stream<tuple<ustring tweet_raw_data>,Twitter_Raw_Data,Twitter_Raw_Data> Op_1_out0) as Op_1  = 
    TwitterTopicListener()
    {
    }

     

    I have this xml:

     

    <?xml version="1.0" ?>
    <operatorModel
      xmlns="http://www.ibm.com/xmlns/prod/streams/spl/operator" 
      xmlns:cmn="http://www.ibm.com/xmlns/prod/streams/spl/common" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://www.ibm.com/xmlns/prod/streams/spl/operator operatorModel.xsd"> 
      <!-- Generated by Streams Studio: October 29, 2013 4:39:41 PM GMT+01:00 -->
      <javaOperatorModel> 
        <context>  
          <description>Java Operator TwitterTopicListener</description> 
          <executionSettings> 
            <className>twitter.application.TwitterTopicListener</className> 
          </executionSettings> 
          <libraryDependencies> 
            <library> 
              <cmn:description>Java operator class library</cmn:description> 
              <cmn:managedLibrary> 
                <cmn:libPath>../../impl/lib/signpost-core-1.2.1.2.jar</cmn:libPath> 
                <cmn:libPath>../../impl/lib/commons-codec-1.8.jar</cmn:libPath> 
              </cmn:managedLibrary> 
            </library> 
          </libraryDependencies> 
        </context>   
        <parameters> 
        </parameters> 
        <inputPorts> 
        </inputPorts> 
        <outputPorts> 
          <outputPortSet>
            <description>Port that produces tuples</description>
            <windowPunctuationOutputMode>Generating</windowPunctuationOutputMode>
            <cardinality>1</cardinality>
            <optional>false</optional>
          </outputPortSet>    
          <outputPortOpenSet> 
            <windowPunctuationOutputMode>Generating</windowPunctuationOutputMode> 
          </outputPortOpenSet>     
        </outputPorts> 
      </javaOperatorModel> 
    </operatorModel>

     

    Thanks 

  • Jason T
    Jason T
    31 Posts

    Re: Java primitive operator and additional jar files

    ‏2013-10-30T00:34:02Z  

    Thanks Jason!! I'm struggling with that :-)

    In order to remove the errors in the java class of the operator, I've to add the jars to the build path in the eclipse project. Is this required?

    If I do that I resolve the error in the java class, but not in the spl code. This is the error I have:

    Errors:
    - CDISP9164E Operator invocation error for Java primitive twitter.application::TwitterTopicListener
    - CDISP0232E An error was encountered during the generation of the code for the Op_1 operator.
     
    Operator: twitter.application::TwitterTopicListener Op_1
     
    Source: 
    (stream<tuple<ustring tweet_raw_data>,Twitter_Raw_Data,Twitter_Raw_Data> Op_1_out0) as Op_1  = 
    TwitterTopicListener()
    {
    }

     

    I have this xml:

     

    <?xml version="1.0" ?>
    <operatorModel
      xmlns="http://www.ibm.com/xmlns/prod/streams/spl/operator" 
      xmlns:cmn="http://www.ibm.com/xmlns/prod/streams/spl/common" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://www.ibm.com/xmlns/prod/streams/spl/operator operatorModel.xsd"> 
      <!-- Generated by Streams Studio: October 29, 2013 4:39:41 PM GMT+01:00 -->
      <javaOperatorModel> 
        <context>  
          <description>Java Operator TwitterTopicListener</description> 
          <executionSettings> 
            <className>twitter.application.TwitterTopicListener</className> 
          </executionSettings> 
          <libraryDependencies> 
            <library> 
              <cmn:description>Java operator class library</cmn:description> 
              <cmn:managedLibrary> 
                <cmn:libPath>../../impl/lib/signpost-core-1.2.1.2.jar</cmn:libPath> 
                <cmn:libPath>../../impl/lib/commons-codec-1.8.jar</cmn:libPath> 
              </cmn:managedLibrary> 
            </library> 
          </libraryDependencies> 
        </context>   
        <parameters> 
        </parameters> 
        <inputPorts> 
        </inputPorts> 
        <outputPorts> 
          <outputPortSet>
            <description>Port that produces tuples</description>
            <windowPunctuationOutputMode>Generating</windowPunctuationOutputMode>
            <cardinality>1</cardinality>
            <optional>false</optional>
          </outputPortSet>    
          <outputPortOpenSet> 
            <windowPunctuationOutputMode>Generating</windowPunctuationOutputMode> 
          </outputPortOpenSet>     
        </outputPorts> 
      </javaOperatorModel> 
    </operatorModel>

     

    Thanks 

    Hello Javier,

    I'm sorry you are still having issues.

    What is the physical location of your operator class? 

    If it is not included in either of these two directories...

    <cmn:libPath>../../impl/lib/signpost-core-1.2.1.2.jar</cmn:libPath>
    <cmn:libPath>../../impl/lib/commons-codec-1.8.jar</cmn:libPath>

    ...you will need to add the relative path of the location of the compiled operator to this section.

    For example, if your compiled operator is stored in the directory impl/java/bin your would need to add that line to your libPath section like this...

    <cmn:libPath>../../impl/lib/signpost-core-1.2.1.2.jar</cmn:libPath>
    <cmn:libPath>../../impl/lib/commons-codec-1.8.jar</cmn:libPath>
    <cmn:libPath>../../impl/java/bin</cmn:libPath>

    Please let me know if this helps with deploying your project.

    Jason

     

  • MQVA_javier_vidal
    MQVA_javier_vidal
    6 Posts

    Re: Java primitive operator and additional jar files

    ‏2013-10-30T13:58:44Z  
    • Jason T
    • ‏2013-10-30T00:34:02Z

    Hello Javier,

    I'm sorry you are still having issues.

    What is the physical location of your operator class? 

    If it is not included in either of these two directories...

    <cmn:libPath>../../impl/lib/signpost-core-1.2.1.2.jar</cmn:libPath>
    <cmn:libPath>../../impl/lib/commons-codec-1.8.jar</cmn:libPath>

    ...you will need to add the relative path of the location of the compiled operator to this section.

    For example, if your compiled operator is stored in the directory impl/java/bin your would need to add that line to your libPath section like this...

    <cmn:libPath>../../impl/lib/signpost-core-1.2.1.2.jar</cmn:libPath>
    <cmn:libPath>../../impl/lib/commons-codec-1.8.jar</cmn:libPath>
    <cmn:libPath>../../impl/java/bin</cmn:libPath>

    Please let me know if this helps with deploying your project.

    Jason

     

    Solved!!! Thanks Jason!