Topic
7 replies Latest Post - ‏2009-12-25T17:57:17Z by SystemAdmin
SystemAdmin
SystemAdmin
1245 Posts
ACCEPTED ANSWER

Pinned topic Java Udop Sample (041_javaudop_at_work) won't run

‏2009-12-22T15:47:19Z |
Hello:

Before asking specific questions (at bottom of this message), here is the background on the questions I want to ask: I am trying to learn how utilize java udops in InfoSphereStreams. In the samples directory of the InfoSphereStreams copy we have ( path = /opt/distillery1.0.1.1/InfoSphereStreams1.0.1.1/samples ), there is an example spade application 041_javaudop_at_work for a simple java udop. I assume that everyone has the same samples directory in their InfoSphereStreams instance/copy.

However, I am unable to get it to run via Eclipse (via the RUN-->Run Configurations menu option in Eclipse, which is how I have run other spade applications in Eclipse (i.e., those not containing any java udops)). When I try to run the sample 041_javaudop_at_work, I get two errors in the Eclipse Console:

ERROR: Network byte ordering flag (-u or --use-network-byte-order-encoding not set for application containing JavaUdop
ERROR in file: /home/jasond/workspace/041_javaudop_at_work/SalaryMultiplier.dps
in line: 43, near token '}'
className: "sample.spade.SalaryMultiplier"] {}

The first error I don't understand because the -u flag seems to be set in the following portion of the Makefile (also in the Sample):

ifeq ($(STREAMS_INSTALL),)
DPSFLAGS = -a -b -l -n -z -u
DPS = ../../spadec
else
DPSFLAGS = -a -l -n -z -u
DPS = $(STREAMS_INSTALL)/bin/spadec
endif

I also am unable to understand the source of the second error.

This leads to the questions I have:
1. Are other people able to get this sample spade application (041_javaudop_at_work) to run (either inside of Eclipse or from the Command Line)? If other people can get it to work, then I may need to track something down in my own environment that is causing the program to fail to run.
2. Is the Makefile the proper place to set the -u flag (regarding the first ERROR mentioned above)?
3. Where can I find more examples of spade applications that contain java udops that I can run? I have the documentation (Programming Model and Langauge Reference dated Oct 22 2009) but examples of working code are always very useful.

Thanks very much for any help you can provide...I am happy to provide further information/details if some aspect of the question is unclear or incomplete.

Jason Duncan
  • SystemAdmin
    SystemAdmin
    1245 Posts
    ACCEPTED ANSWER

    Re: Java Udop Sample (041_javaudop_at_work) won't run

    ‏2009-12-22T18:58:27Z  in response to SystemAdmin
    Hello:

    One update to add to my earlier post. I was able to get the application (041_javaudop_at_work) to compile and run from the command line and produce the expected results. However, I am still unable to get it to run in Eclipse via the RUN-->Run Configurations menu option (I still receive the same two errors mentioned in the previous post).

    Also, I remain very interested in seeing any examples of working spade applications that contain/use java udops so I can learn from those examples.

    Best,

    Jason
    • SystemAdmin
      SystemAdmin
      1245 Posts
      ACCEPTED ANSWER

      Re: Java Udop Sample (041_javaudop_at_work) won't run

      ‏2009-12-23T15:43:06Z  in response to SystemAdmin
      Hi Jason,

      The IDE has a separate location for configuring the compiler options. If you go to Project -> Properties -> SPADE Compiler Options, you can add the -u flag there.

      About the two errors: There is really one error that causes both. The second one is just marking the operator that is causing the trouble.

      Some news: The need for -u is a temporary limitation, which is being lift off in the upcoming version. Also, the IDE will be able to import the settings from the Makefile during import, improving the situation. For now, you will need to make the compiler option changes from the eclipse IDE, manually.

      I hope this helps.

      Cheers,
      -bugra
      • SystemAdmin
        SystemAdmin
        1245 Posts
        ACCEPTED ANSWER

        Re: Java Udop Sample (041_javaudop_at_work) won't run

        ‏2009-12-23T19:27:58Z  in response to SystemAdmin
        Hi Bugra:

        Yes, adding in the -u manually in Eclipse caused the two errors to go away, which is good. Unfortunately, I now get a different error when running this program via Eclipse:

        Exception in thread "main" java.lang.ClassNotFoundException: sample.spade.SalaryMultiplier
        at java.net.URLClassLoader.findClass(URLClassLoader.java:419)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:643)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:609)
        at com.ibm.streams.spade.internal.OperatorAdapter.newAdapter(Unknown Source)
        at com.ibm.streams.spade.internal.jni.JNIBridge.initialize(Unknown Source)

        I see that the Class SalaryMultiplier.java is in the application directory structure in what seems to be the correct location (i.e., 041_javaudop_at_work/src/sample/spade/SalaryMultiplier.java ), and also I am able to run the application from the command line, so I'm not sure why this error is being generated. Are you able to run this application successfully in Eclipse?

        Thanks for your help and for the info about upcoming changes regarding the -u flag.

        Best,

        Jason
        • SystemAdmin
          SystemAdmin
          1245 Posts
          ACCEPTED ANSWER

          Re: Java Udop Sample (041_javaudop_at_work) won't run

          ‏2009-12-25T17:57:17Z  in response to SystemAdmin
          Hi Jason,

          The Makefile has the following for executing the compiler:

          
          $(DPS) $(DPSFLAGS) -f $< $(PWD)/bin
          


          Note that the $(PWD)/bin is a command line argument which gets plugged into the JavaUdop parameter named 'classLibrary':
          
          stream AfterSalary(schemaFor(Salary), newSalary: Integer) := JavaUdop(BeforeSalary) [classLibrary: 
          "CLASSLIB"; className: 
          "sample.spade.SalaryMultiplier"] 
          {
          }
          


          In the case of IDE, you will have to specify that manually (until the new version with the improved import support is out).

          Cheers,
          -bugra
    • SystemAdmin
      SystemAdmin
      1245 Posts
      ACCEPTED ANSWER

      Re: Java Udop Sample (041_javaudop_at_work) won't run

      ‏2009-12-23T17:10:38Z  in response to SystemAdmin
      While not working application examples streams.spade.jar has some example skeleton JavaUdop code in the package

      com.ibm.streams.spade.samples.patterns

      TupleProducer - Abstract class that can be extended to implement SPADE Source like functionality

      PollingTupleProducer - Abstract Source style operator that periodically polls for new tuples, your sub-class provides the code that fetches tuples from an external source. PollingTupleProducer does the rest, setting up the polling, and delivering the tuples on its output stream.

      TupleConsumer - Abstract class that can be extended to implement SPADE Sink like functionality, includes batching support. Your class provides the methods that delivers the received tuples into an external system.

      TupleInTupleOut - Abstract class that can be extended to implement SPADE Functor like functionality. Has a filter method and a transform method that your sub-class can provide, to implement filtering and output processing (creation of an output tuple from an input tuple)

      From the Streams 1.0.10 release onwards the source for these samples is included in the above jar, thus clicking on the class in Eclipse should take you to the source code.
      • SystemAdmin
        SystemAdmin
        1245 Posts
        ACCEPTED ANSWER

        Re: Java Udop Sample (041_javaudop_at_work) won't run

        ‏2009-12-23T19:29:25Z  in response to SystemAdmin
        Thank you for the pointers, I will definitely take a look at them.

        Best,

        Jason
        • SystemAdmin
          SystemAdmin
          1245 Posts
          ACCEPTED ANSWER

          Re: Java Udop Sample (041_javaudop_at_work) won't run

          ‏2009-12-25T17:13:38Z  in response to SystemAdmin
          Hi Jason,

          Streams Studio provides custom launchers for running SPADE applications. To run the application in a standalone mode (compiled into a single executable), create a "Streams Standalone" launcher for the SPADE project. Otherwise, to run the application on the Streams runtime, create and run a "Streams" launcher.

          These launchers will build the SPADE application and invoke the corrsponding launch operations

          In the case of the Streams Standalone launcher, the launcher is activated via "Run-As" runs the application in a Eclipse console. To see output to the console, select a "Log message level" greater than "None" on the launch dialog. When launched via "Debug-As", Eclipse will start an xterm, and run the application with the Streams Debugger enabled in the xterm.

          For the Steams Launcher, the launcher will invoke whatever launch actions you specify in the launcher's dialog. For example, if you select Start Streams instance and Submit application(s), the launcher will build the application, start an instance of the Streams runtime, and submit the application to the runtime.

          For more information on launching Streams applications, please see the Streams Studio User's Guide.

          Regards,
          Andy