incubator-s4-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aboubakr Benabbas <aboubakr.benab...@tu-ilmenau.de>
Subject 'error''
Date Tue, 04 Jun 2013 16:51:07 GMT


hi, 

I successfully imported my app to eclipse, extended the myApp
that one could create with s4, in my app i added another PE that
receives events from the HelloPE and prints standard output, the build
was successful but when running the app, after the first input i gave to
the app, i got the following : 

Hello Bob!
Exception in thread "names"
java.lang.NullPointerException
 at
hello.HelloPE.onEvent(HelloPE.java:42)
 at
OverloadDispatcher1793.dispatchEvent(Unknown Source)
 at
org.apache.s4.core.ProcessingElement.handleInputEvent(ProcessingElement.java:447)

at org.apache.s4.core.Stream.run(Stream.java:309)
 at
java.lang.Thread.run(Thread.java:679)


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


the code does not show any errors 

here are my classes (i did not
modify the input adapter): 

MyPE.java


//////////////////////////////////////////////////////////////


package hello;

import org.apache.s4.base.Event;
import
org.apache.s4.core.ProcessingElement;

public class MyPE extends
ProcessingElement {

 public void onEvent(MyEvent event) {


System.out.println("this is my event !!");
 }

 @Override
 protected
void onCreate() {
 }

 @Override
 protected void onRemove() {

}

}
/////////////////////////////////////////////////////////////////////////////


HelloPE.java 

package hello;

import
org.apache.s4.base.Event;
import
org.apache.s4.core.ProcessingElement;
import
org.apache.s4.core.Stream;

public class HelloPE extends
ProcessingElement {

 // you should define downstream streams here and
inject them in the app definition

 boolean seen = false;
 Stream 
downStream; //this is the last addition

 public void
setDownStream(Stream stream) {
 this.downStream = stream;
 }
 /**
 *
This method is called upon a new Event on an incoming stream
 */
 public
void onEvent(Event event) {
 // in this example, we use the default
generic Event type, by you can also define your own type

System.out.println("Hello " + (seen ? "again " : "") + event.get("name")
+ "!");
 seen = true;
 downStream.put(new MyEvent(event.get("name")));


}

 @Override
 protected void onCreate() {
 }

 @Override
 protected
void onRemove() {

}

}

///////////////////////////////////////////////////////////////////////////////////


HelloApp.java 

package hello;

import java.util.Arrays;
import
java.util.List;

import org.apache.s4.base.Event;
import
org.apache.s4.base.KeyFinder;
import org.apache.s4.core.App;
import
org.apache.s4.core.Stream;

public class HelloApp extends App {


@Override
 protected void onStart() {
 }

 @Override
 protected void
onInit() {
 // create a prototype
 HelloPE helloPE =
createPE(HelloPE.class);
 MyPE myPE = createPE(MyPE.class);
 // Create a
stream that listens to the "names" stream and passes events to the
helloPE instance.
 createInputStream("names", new KeyFinder() {


@Override
 public List get(Event event) {
 return Arrays.asList(new
String[] { event.get("name") });
 }
 }, helloPE);
 Stream dStream =
createStream("my_events",myPE);
 dStream.start();
 }

 @Override

protected void onClose() {
 }

}

package hello;

import
java.util.Arrays;
import java.util.List;

import
org.apache.s4.base.Event;
import org.apache.s4.base.KeyFinder;
import
org.apache.s4.core.App;
import org.apache.s4.core.Stream;

public class
HelloApp extends App {

 @Override
 protected void onStart() {
 }


@Override
 protected void onInit() {
 // create a prototype
 HelloPE
helloPE = createPE(HelloPE.class);
 MyPE myPE = createPE(MyPE.class);

// Create a stream that listens to the "names" stream and passes events
to the helloPE instance.
 createInputStream("names", new KeyFinder() {


@Override
 public List get(Event event) {
 return Arrays.asList(new
String[] { event.get("name") });
 }
 }, helloPE);
 Stream dStream =
createStream("my_events",myPE);
 dStream.start();
 }

 @Override

protected void onClose() {
 }

}


Mime
View raw message