No DRL files found for the KieBase, using kmodule.xml - drools

I'm developing a Maven project using java and Drools 6.2.0, and I'm trying to "bind" a certain DRL file to a KieBase through the kmodule.xml file, but I keep getting the error
WARN org.drools.compiler.kie.builder.impl.AbstractKieModule - No files found for KieBase
when running the project.
I think I've configured everything the right way, as shown in the documentation (Chapter 4.2.2 - Overview - Build, Deploy, Utilize and Run - Building), but can't see where is my mistake.
In this project, I think it's not an option for me to declare/configure Drools by coding, due to the project architecture, that's why I'm using the kmodule.xml approach.
Any suggestion is welcome.
My kmodule.xml (location: src/main/resources/META-INF):
<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://jboss.org/kie/6.0.0/kmodule">
<kbase name="departureKB" packages="com.site.myapp.checks.departure">
<ksession name="departureKS" type="stateless" />
</kbase>
</kmodule>
My DRL file (dummy) (location: src/main/resources/com/site/myapp/checks/departure):
package com.site.myapp.checks.departure
rule "my rule 1"
when
// some conditions
then
// something to do
end
My class Departure (only the Drools code) (location: src/com/site/myapp/checks):
channelName = "departure";
KieServices ks = KieServices.Factory.get();
KieContainer kc = ks.getKieClasspathContainer();
String kSessionName = channelName+"KS";
kSession = kc.newStatelessKieSession(kSessionName);
My pom.xml (only the Drools dependencies) :
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-bom</artifactId>
<version>6.2.0.Final</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>6.2.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>6.2.0.Final</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>named-kiesession</artifactId>
<version>6.2.0.Final</version>
</dependency>

The problem is that it's needed to declare in the pom.xml file to include the DRL files.
The pom.xml file should look like this (in my project it's like this, should be similar in others):
<project ...>
...
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>META-INF/kmodule.xml</include>
<include>com/site/myapp/checks/departure/Departure.drl</include>
</includes>
<targetPath>.</targetPath>
</resource>
</resources>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-bom</artifactId>
<version>6.2.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
Take notice to the changes related with the pom.xml indicated in the Question.
Here, I've changed the location of the drools-bom artifact, it's now in the dependecyManagement tag (this artifact is used for the version control of the artifacts, with this you only need to declared the version of the artifacts one time); and have removed the named-kiesession artifact.

Related

eclipse 2018-09 maven can't find dependency but it exists everywhere

I'm using an older version of eclipse 2018-09 with 32-bit Java, not sure that makes a difference. (project limitation for using these older versions)
I have been using the default maven plugin with the project and it all has worked so far, except for the following one:
<!-- https://mvnrepository.com/artifact/com.github.kilianB/JImageHash -->
<dependency>
<groupId>com.github.kilianB</groupId>
<artifactId>JImageHash</artifactId>
<version>3.0.0</version>
</dependency>
https://mvnrepository.com/artifact/com.github.kilianB/JImageHash/3.0.0
I get:
Missing artifact com.github.kilianB:JImageHash:jar:3.0.0
I have done all the maven things, clean, install, etc...
This jar is located at "JCenter repository (https://jcenter.bintray.com/)".
And the url and files are all there.
https://bintray.com/kilianb/maven/JImageHash/3.0.0#files/com%2Fgithub%2FkilianB%2FJImageHash%2F3.0.0
I even downloaded the files and jars.
I have no settings.xml in my .m2, as I'm using the default eclipse maven. The pom.xml is the default one and I added the dependencies I have needed.
What's missing?
Thanks in advance.
FWIW here's my pom I'm using
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>patmangames</groupId>
<artifactId>carddetect</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j -->
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>4.5.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>4.3.0-1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.0</version>
</dependency>
<!-- FAILS TO FIND AND DOWNLOAD-->
<dependency>
<groupId>com.github.kilianB</groupId>
<artifactId>JImageHash</artifactId>
<version>3.0.0</version>
</dependency>
<!-- FAILS TO FIND AND DOWNLOAD-->
</dependencies>
</project>
Without a settings.xml you only get jars from MavenCentral.
Note that MavenCentral has nothing to do with mvnrepository. Finding a jar on mvnrepository does not mean that it is in MavenCentral.
Indeed, in your case, the jar is in jcenter, so you need to write a settings.xml where you add that repository as <repository>.

Cucumber-Maven Set up with Eclipse, Source option 5 is no longer supported. Use 7 or later

I am totally new in Java , and trying to install Cucumber.
I have downloaded JDK and JRE and their versions are: jdk-12.0.1 && jre1.8.0_211 and set the environment variables.
I have also downloaded Eclipse
I am following the tutorial https://www.toolsqa.com/cucumber-video-tutorials/
I have downloaded all jar files here, C:\JavaJars\Cucumber
then I have referenced them in my pom.xml file (C:\JavaProjects\CucumberMaven)
Here is a snippet of dependencies:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ToolsQA</groupId>
<artifactId>CucumberMaven</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>CucumberMaven</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm</artifactId>
<version>1.2.5</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.13-beta-3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.cobertura</groupId>
<artifactId>cobertura</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.5</version>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>4.6.0</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>2.0.2-beta</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13-beta-3</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
in command prompt -->
mvn clean install
I get the error -->
[ERROR] Source option 5 is no longer supported. Use 7 or later.
[ERROR] Target option 5 is no longer supported. Use 7 or later.
I am not sure how to fix it
maven-compiler-plugin by default will compile your project using Java 1.5 which is where m2e gets its information.
Your effective pom.xml will implicitly use the default settings in the maven-compiler-plugin pom.xml.
That's why you have to explicitly declare the maven-compiler-plugin in your project with something other than 1.5.
Add this to your pom.xml
<build>
<pluginManagement>
<plugins>
<!-- Default java version was 1.5, to change the default version added this plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

Import and use authenticated SAP WSDLs with Eclipse/Maven

I have an ASP.NET (C#) project that is based on consuming SOAP services from the german SAP ERP and we recently decided to port it to a Java dynamic web project. Mostly of all these web services needs authentication.
On Visual Studio (ASP.NET), though, it was pretty easy and straightforward to import a web service, as easy as clicking on Add service reference, putting the WSDL URL, giving a namespace name and clicking on Ok. Done. All the generated classes will be "hidden" just so someone wouldnt change then. Nice! Also, we have a bindings file, which is plain XML, containing stuff like maxBufferSize, maxBufferPoolSize, maxReceivedMessageSize etc...
On Eclipse (Java), I tried adding a New Web Service Client (New > Web Services > Web Service Client) and this is where I faced my first problem. It is like it does not recognize the WSDL as a valid URL for some reason, however it works in any browser (it even prompts for the authentication) and also in the Visual Studio project. This is what the WSDL look like: http://spceqsap01:8000/sap/bc/srt/wsdl/flv_10002A111AD1/bndg_url/sap/bc/srt/rfc/sap/zws_listar_municipios/300/zws_listar_municipios/zws_listar_municipios?sap-client=300
There are a few WSDLs out there used in examples and they are "successfully" imported, except that the Eclipse complains about some JARs. One curious thing that I noted is that most of them ends with ?wsdl, but placing this in the above WSDL wont work.
Maven has a few plugins to generate the source code for the WSDLs, but I couldnt get it to work too (sources weren't generated or anything, probably because missing some plugin configuration or wrong ones). If someone has a working example for consuming SAP web services, please post below!
For the Java dynamic web project, we're currently using the following:
Maven 3.3.9
Java 8
Tomcat 9
VRaptor 4.2
Hibernate 5.2.9
Eclipse Neon 4.6.1
This is my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!-- Artifact details -->
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.nooder</groupId>
<artifactId>portal</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<!-- Properties -->
<properties>
<deploy.version.log4j>2.8.2</deploy.version.log4j>
<deploy.version.vraptor>4.2.0-RC5</deploy.version.vraptor>
<deploy.version.weld>3.0.0.CR2</deploy.version.weld>
<deploy.version.hibernate>5.2.9.Final</deploy.version.hibernate>
<deploy.version.junit>4.12</deploy.version.junit>
<deploy.version.slf4j>1.7.25</deploy.version.slf4j>
</properties>
<!-- Development and production settings -->
<profiles>
<profile>
<id>tst</id>
<properties>
<deploy.enviroment>tst</deploy.enviroment>
</properties>
</profile>
<profile>
<id>prd</id>
<properties>
<deploy.enviroment>prd</deploy.enviroment>
</properties>
</profile>
</profiles>
<!-- Dependencies -->
<dependencies>
<!-- JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${deploy.version.junit}</version>
</dependency>
<!-- VRaptor -->
<dependency>
<groupId>br.com.caelum</groupId>
<artifactId>vraptor</artifactId>
<version>${deploy.version.vraptor}</version>
</dependency>
<!-- VRaptor plugins -->
<dependency>
<groupId>br.com.caelum.vraptor</groupId>
<artifactId>vraptor-java8</artifactId>
<version>4.0.0.Final</version>
</dependency>
<dependency>
<groupId>br.com.caelum.vraptor</groupId>
<artifactId>vraptor-brutauth</artifactId>
<version>4.0.4</version>
</dependency>
<dependency>
<groupId>br.com.caelum.vraptor</groupId>
<artifactId>vraptor-jpa</artifactId>
<version>4.0.5</version>
</dependency>
<!--
<dependency>
<groupId>br.com.caelum.vraptor</groupId>
<artifactId>vraptor-hibernate</artifactId>
<version>4.1.0</version>
</dependency>
-->
<!-- VRaptor's dependencies: Servlet Container (Tomcat) -->
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet-core</artifactId>
<version>${deploy.version.weld}</version>
<exclusions>
<exclusion>
<groupId>org.jboss.spec.javax.el</groupId>
<artifactId>jboss-el-api_3.0_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core-impl</artifactId>
<version>${deploy.version.weld}</version>
<exclusions>
<exclusion>
<groupId>org.jboss.spec.javax.el</groupId>
<artifactId>jboss-el-api_3.0_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- VRaptor's dependencies: Java 8 -->
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.18.1-GA</version>
</dependency>
<!-- VRaptor's dependencies: Bean Validation -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-cdi</artifactId>
<version>5.1.1.Final</version>
</dependency>
<!-- Hibernate + DB -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${deploy.version.hibernate}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version>
</dependency>
<!-- JavaEE 8: CDI -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- Tomcat's dependencies: JSTL -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Maven's dependencies (?) -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<!-- Expression language -->
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<!-- Log4j 2 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${deploy.version.log4j}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${deploy.version.log4j}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${deploy.version.log4j}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${deploy.version.slf4j}</version>
</dependency>
</dependencies>
<!-- Build -->
<build>
<finalName>portal</finalName>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<!-- Resources -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/filters/settings.${deploy.enviroment}.properties</filter>
</filters>
<plugins>
<!-- JDK Compiler Level -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-parameters</compilerArgument>
<testCompilerArgument>-parameters</testCompilerArgument>
</configuration>
</plugin>
<!-- Eclipse project -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<!-- Always download and attach dependencies source code -->
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<!-- Avoid type mvn eclipse:eclipse -Dwtpversion=2.0 -->
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
<!-- For Maven Tomcat Plugin -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/portal</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
Any input is GREATLY appreciated!

How to write my own job in samza

Recently I am trying to do some stream processing work on Samza framework. I have deployed the hello-samza example successfully. However, when I try to write my own job, I have no idea where to start my work.
I have read this document, but I still can't get the point. So can anyone help me:
What is my code's architecture (source code, lib code, and configuration).
Which directory will my code pushed in.
What other work I need to do to get my codes run.
Your suggestion will help me a lot, many thanks!
It is very simple to build your own Jobs. First get hello samza:
git clone https://git.apache.org/samza-hello-samza.git hello-samza
The next step is to set up the system by these command:
bin/grid bootstrap
Please make sure that all is going good by jps
The next step is to remove apache-rat-plugin from pom.xml instead of building your project inside hello-samza.
When you remome that you can add a java file Job in src folder(MyTask.java) and also a .properties file inside config directory (My.Task.properties)
This is a sample-empty Job(MyTask.java).
package com.samza;
public class MyTask implements StreamTask {
private static final SystemStream OUTPUT_STREAM = new SystemStream("kafka","topicOut");
public void process (IncomingMessageEnvelope envelope, MessageCollector collector,
TaskCoordinator coordinator) throws Exception {
// Do something useful
}
}
Don't forget to implement a .properties file.
If you hava non-error code, build with maven like:
mvn clean package
mkdir -p deploy/samza
tar -xvf ./samza-job-package/target/samza-job-package-0.10.0-dist.tar.gz -C deploy/samza
After that and your server is up (if it is not you can started by ./bin/grid start all) you can deploy your Job by deploy/samza/bin/run-job.sh --config-factory=org.apache.samza.config.factories.PropertiesConfigFactory --config-path=file://$PWD/deploy/samza/config/MyTask.properties
and consume the result by kafka client-consumer
deploy/kafka/bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic outTopic
If you follow the Hello Samza instructions, you will have a fully functioning Zookeeper, Kafka, and Yarn/Samza cluster running on your local computer. With that project there are the Wikipedia feed related tasks that you can run to test things.
However, like you, I had some trouble coming up with the proper directory structure and build settings for new tasks (without the cluster management stuff). So, I created hello-samza-base by stripping out everything unnecessary for new tasks outside of hello-samza. I included instructions in the README on building new tasks.
As far as deployment goes, that is a bit more complex. Do some reading on creating Zookeeper, Kafka, and Yarn clusters.
I created Samza jobs parting via a Maven Eclipse project. The dependencies for version 0.9.2 where loaded in the pom.xml file with this content (I had some version issues, so you may have some work there):
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.acio.samza</groupId>
<artifactId>samzafroga</artifactId>
<version>0.0.1</version>
<name>samzafroga</name>
<dependencies>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-core_2.10</artifactId>
</dependency>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-log4j</artifactId>
</dependency>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-shell</artifactId>
</dependency>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-yarn_2.10</artifactId>
<exclusions>
<exclusion>
<artifactId>jdk.tools</artifactId>
<groupId>jdk.tools</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-kv_2.10</artifactId>
</dependency>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-kv-rocksdb_2.10</artifactId>
</dependency>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-kafka_2.10</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
</dependency>
<dependency>
<groupId>org.schwering</groupId>
<artifactId>irclib</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jettyVersion}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jettyVersion}</version>
</dependency>
</dependencies>
<properties>
<!-- maven specific properties -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<samza.version>0.8.0</samza.version>
<jettyVersion>7.6.16.v20140903</jettyVersion>
</properties>
<repositories>
<repository>
<id>apache-releases</id>
<url>https://repository.apache.org/content/groups/public</url>
</repository>
<repository>
<id>scala-tools.org</id>
<name>Scala-tools Maven2 Repository</name>
<url>https://oss.sonatype.org/content/groups/scala-tools</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>scala-tools.org</id>
<name>Scala-tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</pluginRepository>
</pluginRepositories>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
<version>0.9</version>
<configuration>
<excludes>
<exclude>*.patch</exclude>
<exclude>**/target/**</exclude>
<exclude>*.json</exclude>
<exclude>.vagrant/**</exclude>
<exclude>.git/**</exclude>
<exclude>*.md</exclude>
<exclude>docs/**</exclude>
<exclude>config/**</exclude>
<exclude>bin/**</exclude>
<exclude>.gitignore</exclude>
<exclude>**/.cache/**</exclude>
<exclude>deploy/**</exclude>
<exclude>**/.project</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- plugin to build the tar.gz file filled with examples -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptors>
<descriptor>src/assembly/bin.xml</descriptor>
</descriptors>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-api</artifactId>
<version>${samza.version}</version>
</dependency>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-core_2.10</artifactId>
<version>${samza.version}</version>
</dependency>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-log4j</artifactId>
<version>${samza.version}</version>
</dependency>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-shell</artifactId>
<version>${samza.version}</version>
</dependency>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-yarn_2.10</artifactId>
<version>${samza.version}</version>
</dependency>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-kv_2.10</artifactId>
<version>${samza.version}</version>
</dependency>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-kv-rocksdb_2.10</artifactId>
<version>${samza.version}</version>
</dependency>
<dependency>
<groupId>org.apache.samza</groupId>
<artifactId>samza-kafka_2.10</artifactId>
<version>${samza.version}</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.10</artifactId>
<version>0.8.2.0</version>
</dependency>
<dependency>
<groupId>org.schwering</groupId>
<artifactId>irclib</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.8.5</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>2.6.0</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
The basic code of a job is this one:
package xxxx;
import java.util.Map;
import org.apache.samza.config.Config;
import org.apache.samza.system.IncomingMessageEnvelope;
import org.apache.samza.system.OutgoingMessageEnvelope;
import org.apache.samza.system.SystemStream;
import org.apache.samza.task.MessageCollector;
import org.apache.samza.task.StreamTask;
import org.apache.samza.task.TaskContext;
import org.apache.samza.task.TaskCoordinator;
public class Redirect implements StreamTask {
private final SystemStream OUTPUT_STREAM = new SystemStream("kafka", "samzaout");
public void process(IncomingMessageEnvelope envelope,
MessageCollector collector,
TaskCoordinator coordinator)
{
String msg = (String)envelope.getMessage();
// Transformation
String outmsg = "xxx-" + msg + "-xxx";
collector.send(new OutgoingMessageEnvelope(OUTPUT_STREAM, outmsg));
}
}
Once you have it compiled you need to group it into a jar file and place it in a location accesible for all the samza nodes, web or hdfs.
Reference this from the properties file you will have to create to launch it. Look for examples in the porject web page.
Read that document some more, look at the hello-samza example some more, and if you deployed it to YARN read about it some more. All the answers you're looking for are there.
There are three jobs in hello-samza. Pick one and follow it, configuration, launching scripts etc.
Here's from the hello-samza page how to launch the wikipedia-feed job
deploy/samza/bin/run-job.sh --config-factory=org.apache.samza.config.factories.PropertiesConfigFactory --config-path=file://$PWD/deploy/samza/config/wikipedia-feed.properties
The properties file shows where the compiled job/task code is among other things. The source code for the wikipedia-feed job/task is here:
https://github.com/apache/samza-hello-samza/blob/master/src/main/java/samza/examples/wikipedia/task/WikipediaFeedStreamTask.java
Just modify this job, or copy and modify, to get yours going.

Adding hibernate dependency in Eclipse with Maven and m2e plugin

I've created a Java project in eclipse and added hibernate 3.5.4 dependency to pom.xml file, but the only jar that appeared in Maven Dependencies tab is slf4j-api-1.5.8.jar. How should I configure Maven or m2e plugin to add all required dependencies for Hibernate?
My pom.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.edu.agh.bd2.tutorial</groupId>
<artifactId>HibernateTutorial</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.3</source>
<target>1.2</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.5.4-Final</version>
<type>pom</type>
</dependency>
</dependencies>
</project>
When specifying a dependency with <type> pom it won't be included into your dependencies library as you are expecting (a jar file).
Here is a list of basic hibernate artifact ids that I use to include:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>${hibernate.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>${hibernate.version}</version>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>
Replace the ${hibernate.version} with desired version or define a property with this identifier.