Unable to run "Hello World" Java client of Elastic-Search - java

I am unable to run a very basic program of creating a "Hello World" java client of Elastic-Search.
The documentation is extremely terse about what to do in such cases.
Here is my code:
find . -type f
./pom.xml
./src/main/java/examples/EsRoutingNodeClient.java
Both files are shown below.
Java file containing the code:
package examples;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.NodeBuilder;
public class EsRoutingNodeClient
{
private static final String ZEN_DISCOVERY_UNICAST_HOSTS = "[\"10.10.10.10:9200\"]"; // Used an actual ES master node's IP here
private static final String ES_PATH_HOME = "/Users/appuser/work/software/elasticsearch/dummy-path-home/";
private static final String ES_CLUSTER_NAME = "my-cluster";
private Client client;
private void createEsClient ()
{
Settings settings = Settings.settingsBuilder()
.put("http.enabled", false)
.put("discovery.zen.ping.multicast.enabled", false)
.put("discovery.zen.ping.unicast.hosts", ZEN_DISCOVERY_UNICAST_HOSTS)
.put("discovery.zen.minimum_master_nodes", 1)
.put("path.home", ES_PATH_HOME)
.build();
client =
NodeBuilder.nodeBuilder()
.settings(settings)
.clusterName(ES_CLUSTER_NAME)
.data(false)
.client(true)
.node().client();
}
public EsRoutingNodeClient ()
{
createEsClient();
}
public static void main (String args[])
{
new EsRoutingNodeClient();
}
}
pom.xml:
<?xml version="1.0" encoding="UTF-8"?><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>examples</groupId>
<artifactId>es-node-client</artifactId>
<version>0.0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>es-node-client</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>2.2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<configuration />
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>org.slf4j:*</exclude>
<exlcude>com.esotericsoftware.kryo:kryo:*</exlcude>
</excludes>
</artifactSet>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>examples.EsRoutingNodeClient</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Finally I run it as follows:
mvn clean package
java -jar target/es-node-client-0.0.3-SNAPSHOT.jar
And the exception I get is:
194) Error injecting constructor, java.lang.IllegalStateException: This is a proxy used to support circular references involving constructors. The object we're proxying is not constructed yet. Please wait until after injection has completed to use this object.
at org.elasticsearch.node.service.NodeService.<init>(Unknown Source)
while locating org.elasticsearch.node.service.NodeService
for parameter 5 at org.elasticsearch.action.admin.cluster.node.stats.TransportNodesStatsAction.<init>(Unknown Source)
while locating org.elasticsearch.action.admin.cluster.node.stats.TransportNodesStatsAction
for parameter 2 at org.elasticsearch.cluster.InternalClusterInfoService.<init>(Unknown Source)
while locating org.elasticsearch.cluster.InternalClusterInfoService
while locating org.elasticsearch.cluster.ClusterInfoService
for parameter 3 at org.elasticsearch.cluster.routing.allocation.AllocationService.<init>(Unknown Source)
while locating org.elasticsearch.cluster.routing.allocation.AllocationService
for parameter 3 at org.elasticsearch.cluster.metadata.MetaDataCreateIndexService.<init>(Unknown Source)
while locating org.elasticsearch.cluster.metadata.MetaDataCreateIndexService
for parameter 5 at org.elasticsearch.snapshots.RestoreService.<init>(Unknown Source)
while locating org.elasticsearch.snapshots.RestoreService
Caused by: java.lang.IllegalStateException: This is a proxy used to support circular references involving constructors. The object we're proxying is not constructed yet. Please wait until after injection has completed to use this object.
at org.elasticsearch.common.inject.internal.ConstructionContext$DelegatingInvocationHandler.invoke(ConstructionContext.java:103)
at com.sun.proxy.$Proxy11.setNodeService(Unknown Source)
at org.elasticsearch.node.service.NodeService.<init>(NodeService.java:77)
at sun.reflect.GeneratedConstructorAccessor4.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.elasticsearch.common.inject.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:50)
at org.elasticsearch.common.inject.ConstructorInjector.construct(ConstructorInjector.java:86)
at org.elasticsearch.common.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:104)
at org.elasticsearch.common.inject.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:47)
at org.elasticsearch.common.inject.InjectorImpl.callInContext(InjectorImpl.java:887)
at org.elasticsearch.common.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:43)
at org.elasticsearch.common.inject.Scopes$1$1.get(Scopes.java:59)
at org.elasticsearch.common.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:46)
at org.elasticsearch.common.inject.SingleParameterInjector.inject(SingleParameterInjector.java:42)
... more such lines
at org.elasticsearch.common.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:46)
at org.elasticsearch.common.inject.InjectorBuilder$1.call(InjectorBuilder.java:201)
at org.elasticsearch.common.inject.InjectorBuilder$1.call(InjectorBuilder.java:193)
at org.elasticsearch.common.inject.InjectorImpl.callInContext(InjectorImpl.java:880)
at org.elasticsearch.common.inject.InjectorBuilder.loadEagerSingletons(InjectorBuilder.java:193)
at org.elasticsearch.common.inject.InjectorBuilder.injectDynamically(InjectorBuilder.java:175)
at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:110)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:93)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:70)
at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:46)
at org.elasticsearch.node.Node.<init>(Node.java:200)
at org.elasticsearch.node.Node.<init>(Node.java:128)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:145)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:152)
at examples.EsRoutingNodeClient.createEsClient(EsRoutingNodeClient.java:30)
at examples.EsRoutingNodeClient.<init>(EsRoutingNodeClient.java:46)
at examples.EsRoutingNodeClient.main(EsRoutingNodeClient.java:51)
194 errors
at org.elasticsearch.common.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:360)
at org.elasticsearch.common.inject.InjectorBuilder.injectDynamically(InjectorBuilder.java:178)
at org.elasticsearch.common.inject.InjectorBuilder.build(InjectorBuilder.java:110)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:93)
at org.elasticsearch.common.inject.Guice.createInjector(Guice.java:70)
at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:46)
at org.elasticsearch.node.Node.<init>(Node.java:200)
at org.elasticsearch.node.Node.<init>(Node.java:128)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:145)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:152)
at examples.EsRoutingNodeClient.createEsClient(EsRoutingNodeClient.java:30)
at examples.EsRoutingNodeClient.<init>(EsRoutingNodeClient.java:46)
at examples.EsRoutingNodeClient.main(EsRoutingNodeClient.java:51)
My ultimate aim is to use a routing node client in storm.
Any help would be very much appreciated.
Thanks!

While upgrading from 1.4 to 2.4 I ran into this same issue. I'm not 100% why, but for me it was something to due with specifying the unicast host. I'm running ES via the zip download with the defaults.
At first I had set the ports for Client Node (ie, the app i'm working on) to be outside the default range thinking I need to do this to avoid conflicts running 2 nodes on the same box. When I did this my client could never find the master. Turns out that the zen discovery only pings 5 local ports in its own range. Before I figured this out (by reading https://github.com/elastic/elasticsearch/blob/master/core/src/main/java/org/elasticsearch/discovery/zen/ping/unicast/UnicastZenPing.java) I added in a unicast.host to get the same issue you are having. After removing both settings my app is now connecting to my ES server.
here's my config
cluster.name=elasticsearch
node.name=local-dev
node.master=false
node.data=false
path.home=${project.build.directory}/es
path.data=${project.build.directory}/es/data
path.logs=${project.build.directory}/es/logs
network.host=127.0.0.1
discovery.zen.minimum_master_nodes=1
code
#Bean
public Node elasticSearchNode() throws Exception {
Settings settings = Settings.settingsBuilder().put(getProps()).build();
return nodeBuilder()
.settings(settings)
.client(true)
.node();
}
#Bean
public Client elasticSearchClient(Node node) throws Exception {
return node.client();
}
private Properties getProps() {
try {
String profile = getProfile();
log.info("Loading ES properties for env: {}", profile);
ClassPathResource resource = new ClassPathResource("es/es."+profile+".properties");
return PropertiesLoaderUtils.loadProperties(resource);
} catch (IOException e) {
log.error("Can not read property file");
throw new RuntimeException(e);
}
}
private String getProfile() {
return System.getProperty("env", "local");
}

Related

Why does JavaFX app using OpenJDK+openjfx fail on Ubuntu 16?

I have created a very basic JavaFX application
// Viewer.java
package crossjavafx;
public class Viewer {
public static void main(String[] args) {
MainViewer.main(args);
}
}
// MainViewer.java
package crossjavafx;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class MainViewer extends Application {
#Override
public void start(Stage stage) {
try {
System.out.println("Hello from Viewer");
Group root = new Group();
Scene scene = new Scene(root, 400, 300);
stage.setTitle("Hello");
stage.setScene(scene);
stage.show();
} catch (final Exception e) {
System.exit(1);
}
}
public static void main(String args[]){
launch(args);
}
}
there is also simple pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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.test</groupId>
<artifactId>crossjavafx</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
<properties>
<java.version>1.8</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I have built it on Ubuntu 16.04 using mvn and:
./java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~16.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
I have also installed openjfx and libopenjfx packages:
libopenjfx-java/xenial,xenial,now 8u60-b27-4 all [installed]
libopenjfx-jni/xenial,now 8u60-b27-4 amd64 [installed,automatic]
openjfx/xenial,now 8u60-b27-4 amd64 [installed]
The application is built successfully, but fails to launch. The process hangs before printing "Hello from Viewer". I start it:
/usr/lib/jvm/java-8-openjdk-amd64/bin/java -cp crossjavafx-0.1.0-SNAPSHOT.jar crossjavafx.Viewer
I do not have problem to start a non-javafx application build in the same way, even when calling its class from the same JAR, so I suppose there is something wrong with my JavaFX installation.
I also tried to build it and run using Java 8 Oracle SDK, with the same result. Is there anything missing in my JavaFX installation that I forgot?
Edit
I have built and attempted to run it using Java 8 Oracle, printing the stacktrace. I got:
Hello from Viewer
Framebuffer object format is unsupported by the video hardware. (GL_FRAMEBUFFER_UNSUPPORTED)(FBO - 820)
Error creating framebuffer object with TexID 1)
[VGL] ERROR: OpenGL error 0x0502
[VGL] ERROR: in readPixels--
[VGL] 475: Could not Read Pixels
I had a similar issue and added the following parameters as VM arguments "-Djavafx.platform=monocle -Dmonocle.platform=X11 -Dembedded=monocle". As I am using eclipse I added it to the Run configuration Run -> Run configuration ...
Run Configurations in eclipse
I found that hint at https://wiki.openjdk.java.net/display/OpenJFX/Building+the+OpenJFX+embedded+stack+for+Linux+desktop

AWS Lambda: ClassNotFoundException

I currently get a ClassNotFoundException whenever I try to test my Lambda function on AWS Lambda. The exception is shown here:
I've searched online, including this link here: AWS Lambda: class java.lang.ClassNotFoundException, to no avail.
I am working in Android Studio and created a JAR file (using this link: How to make a .jar out from an Android Studio project) to use to upload the class to the AWS Lambda console.
Below is the structure of my project:
When I upload my JAR file to the AWS Lambda console, the Configuration tab looks like this:[
I was previously told that it could have been because my JAR file was not an executable JAR file with a MANIFEST.MF file, but I definitely have that.
Any other reason as to why this error consistently pops up and how to fix it?
Your handler needs to include the full Java package. In your example, you need to have the handler be:
edu.csulb.android.riseandshine.Dynamodb::handleRequest
This is configured on the Lambda screen where you currently have Dynamodb::handleRequest
EDIT
My "hello world" Lambda in looks like the following. Note that this is a maven project so the code has to live where maven expects it. At the "root" of the directory where you're developing is the pom.xml file (below) and the Java file needs to live in src/main/java/com/hotjoe/aws/lambda/hello/handler.
Once you have that and maven installed, run mvn clean package. The deployable jar will be target/hello-world-lambda-1.0-SNAPSHOT.jar. I deployed this to Lambda just now and can run it with the test:
{
"key3": "value3",
"key2": "value2",
"key1": "value1"
}
which is the default for the Lambda tests. This is all taken from the AWS docs on creating a deployment. In my example, the Lambda handler is com.hotjoe.aws.lambda.hello.handler.HelloWorldLambdaHandler::handleRequest.
The code I've used is below.
HelloWorldLambdaHandler.java
package com.hotjoe.aws.lambda.hello.handler;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
#SuppressWarnings("unused")
public class HelloWorldLambdaHandler implements RequestHandler<HelloWorldLambdaHandler.InputObject, String> {
public String handleRequest(InputObject inputObject, Context context) {
System.out.println( "got \"" + inputObject + "\" from call" );
return "{\"result\": \"hello lambda java\"}";
}
public static class InputObject {
private String key1;
private String key2;
private String key3;
public String getKey1() {
return key1;
}
public String getKey2() {
return key2;
}
public String getKey3() {
return key3;
}
public void setKey1(String key1) {
this.key1 = key1;
}
public void setKey2(String key2) {
this.key2 = key2;
}
public void setKey3(String key3) {
this.key3 = key3;
}
#Override
public String toString() {
return "InputObject{" +
"key1='" + key1 + '\'' +
", key2='" + key2 + '\'' +
", key3='" + key3 + '\'' +
'}';
}
}
}
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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.hotjoe.aws.lambda.hello</groupId>
<artifactId>hello-world-lambda</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The stack trace indicates that the Java runtime cannot find a class named "Dynamodb". There is no such class in the AWS SDK for Java .. the correct class name is "DynamoDB". Notice the difference in case between your class from the exception stack trace and the correct name.
I fixed my issue by following below link. Basically need to run mvn "package shade:shade" command to include all depending jars. https://docs.aws.amazon.com/lambda/latest/dg/java-create-jar-pkg-maven-and-eclipse.html (Later experiments showed that just do mvn package would be enough as long as the shade plugin defined in pom.xml file.)
The next challenge I faced is the jar too big. I followed the below link to include dynomaDB, S3, ec2 components instead of the entire sdk.
https://aws.amazon.com/blogs/developer/managing-dependencies-with-aws-sdk-for-java-bill-of-materials-module-bom/.
Then I need to use EnvironmentVariableCredentialsProvider to deploy to lambda function.
It's not an answer to the original question. But I was facing the same issue of class not found and solved it by placing pom.xml at the correct location in the directory structure.
In Android Studio, "src/main/java/.." lives in the Application folder inside the root directory. I was wrongly placing the xml file in the root directly.
When I created a separate directory structure outside of Android Project and placed the xml file as described here, the problem was resolved.
I know it's late to share the solution,
but the same problem I was facing in Apr, 2021 and none of these answers worked in my case. so I'm sharing how I fixed it, it may help someone.
I got it resolved by adding following maven plugin with spring-boot-thin-layout to create a thin jar.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot.experimental</groupId>
<artifactId>spring-boot-thin-layout</artifactId>
<version>1.0.26.RELEASE</version>
</dependency>
</dependencies>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>aws</shadedClassifierName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
<resource>META-INF/spring.factories</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
</transformers>
</configuration>
and then you can run
./mvnw clean package
or if you're using STS/Eclipse, then run Maven build.. with goals clean package
This will generate a jar file in KB in your target folder and you can use this JAR to deploy on AWS lambda code.
PS:
remove maven-shade-plugin
I've refereed Official documentation of spring.cloud.io

Building a standalone executeable JAR with OpenEJB

I am building a CLI tool, which integrates with several EJB modules. For this reason, I need to build a fat jar, which is then executed as a standalone application.
However, executing this fat jar with java -jar (Note: conf/openejb.xml is in the same directory as the fat jar) fails with the following stacktrace:
INFORMATION - PersistenceUnit(name=demo, provider=org.hibernate.jpa.HibernatePersistenceProvider) - provider time 2706ms
INFORMATION - Jndi(name="java:global/DemoMain/demo-shade-1.0-SNAPSHOT/MEJB!javax.management.j2ee.ManagementHome")
INFORMATION - Jndi(name="java:global/DemoMain/demo-shade-1.0-SNAPSHOT/MEJB")
INFORMATION - Jndi(name="java:global/DemoMain/demo-shade-1.0-SNAPSHOT/openejb/Deployer!org.apache.openejb.assembler.Deployer")
INFORMATION - Jndi(name="java:global/DemoMain/demo-shade-1.0-SNAPSHOT/openejb/Deployer")
INFORMATION - Jndi(name="java:global/DemoMain/demo-shade-1.0-SNAPSHOT/openejb/ConfigurationInfo!org.apache.openejb.assembler.classic.cmd.ConfigurationInfo")
INFORMATION - Jndi(name="java:global/DemoMain/demo-shade-1.0-SNAPSHOT/openejb/ConfigurationInfo")
INFORMATION - Jndi(name="java:global/DemoMain/demo-shade-1.0-SNAPSHOT/DemoServiceImpl!com.github.rzo1.service.DemoService")
INFORMATION - Jndi(name="java:global/DemoMain/demo-shade-1.0-SNAPSHOT/DemoServiceImpl")
INFORMATION - Existing thread singleton service in SystemInstance(): org.apache.openejb.cdi.ThreadSingletonServiceImpl#557c8e7e
INFORMATION - Closing DataSource: demoDS
INFORMATION - Closing DataSource: demoDSNonJTA
Exception in thread "Thread-0" java.lang.RuntimeException: org.apache.openejb.OpenEjbContainer$AssembleApplicationException: javax.enterprise.inject.spi.DeploymentException: couldn't start owb context
at com.github.rzo1.DemoMain.run(DemoMain.java:116)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.openejb.OpenEjbContainer$AssembleApplicationException: javax.enterprise.inject.spi.DeploymentException: couldn't start owb context
at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:346)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56)
at com.github.rzo1.DemoMain.run(DemoMain.java:90)
... 1 more
Caused by: javax.enterprise.inject.spi.DeploymentException: couldn't start owb context
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:191)
at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:41)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:913)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:717)
at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:342)
... 3 more
Caused by: org.apache.webbeans.exception.WebBeansException: Wrong startup object.
at org.apache.webbeans.web.lifecycle.WebContainerLifecycle.getServletContext(WebContainerLifecycle.java:227)
at org.apache.webbeans.web.lifecycle.WebContainerLifecycle.startApplication(WebContainerLifecycle.java:86)
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:189)
... 7 more
Executing the code directly from my IDE (IntelliJ) the standalone container comes up and behaves as expected.
Version Summary:
openejb in version 1.7.0 / openejb-server in version 7.0.2
maven-shade-plugin in version 2.4.3
Maven in version 3.3.9
hibernate in version 5.2.7
Basic Setup
I was able to reproduce my problem on a simple working example, which I added as an GitHub project for further investigation.
The basic project layout is as follows:
| # demo-shade
| - demo-services (EJB-Module)
| - demo-main (Shading happens here)
The configuration of the maven-shade-plugin is as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>demo-shade-${project.version}</finalName>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.github.rzo1.DemoMain</Main-Class>
</manifestEntries>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/openwebbeans/openwebbeans.properties</resource>
</transformer>
</transformers>
<filters>
<filter> <!-- we don't want JSF to be activated -->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/faces-config.xml</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<shadedClassifierName>dist</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
The code to start up the container:
EJBContainer ejbContainer = null;
try {
final Properties properties = new Properties();
properties.setProperty(EJBContainer.APP_NAME, applicationName);
properties.setProperty(EJBContainer.PROVIDER, OpenEjbContainer.class.getName());
properties.setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "false");
properties.setProperty("ejbd.disabled", "true");
properties.setProperty("ejbds.disabled", "true");
properties.setProperty("admin.disabled", "true");
properties.setProperty("openejb.jaxrs.application", "false");
Path launchPath = Paths.get(DemoMain.class.getProtectionDomain().getCodeSource().getLocation().toURI());
properties.setProperty("openejb.configuration", launchPath.toAbsolutePath() + "/conf/openejb.xml");
properties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
properties.put("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
// This is the line starting the EJB container
ejbContainer = EJBContainer.createEJBContainer(properties);
ejbContainer.getContext().bind("inject", this);
ejbContainerReady = true;
final CountDownLatch latch = new CountDownLatch(1);
// Graceful shutdown
Runtime.getRuntime().addShutdownHook(new Thread() {
#Override
public void run() {
try {
logger.info("Shutting down..");
latch.countDown();
logger.info("Shutdown completed successfully.");
} catch (final Exception e) {
logger.error("Graceful shutdown went wrong. SIGKILL (kill -9) if you want.", e);
}
}
});
try {
latch.await();
} catch (final InterruptedException e) {
// ignored
}
} catch (final Exception e) {
ejbContainerReady = false;
throw new RuntimeException(e);
} finally {
if (ejbContainer != null) {
ejbContainer.close();
}
}
}
Questions
Did I miss something in the configuration of the maven-shade-plugin?
How can I build a fat jar using openejb in a standalone manner?
Example Project
The full code example is available as a GitHub Project
UPDATE 1:
I changed the pom according to the answer by P. Merkle. I found an other article here describing the process of shading specifically for TomEE.
pom changed to
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>demo-shade-${project.version}</finalName>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.github.rzo1.DemoMain</Main-Class>
</manifestEntries>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.openwebbeans.maven.shade.OpenWebBeansPropertiesTransformer"/>
</transformers>
<filters>
<filter> <!-- we don't want JSF to be activated -->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/faces-config.xml</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<shadedClassifierName>dist</shadedClassifierName>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-maven</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>
</plugin>
Extecuting this fat jar brings:
INFORMATION - OpenWebBeans Container is starting...
INFORMATION - Adding OpenWebBeansPlugin : [CdiPlugin]
SCHWERWIEGEND - CDI Beans module deployment failed
java.lang.NullPointerException
at org.apache.openejb.cdi.CdiScanner.handleBda(CdiScanner.java:271)
at org.apache.openejb.cdi.CdiScanner.init(CdiScanner.java:148)
at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:179)
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:189)
at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:41)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:913)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:717)
at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:342)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56)
at com.github.rzo1.DemoMain.run(DemoMain.java:90)
at java.lang.Thread.run(Unknown Source)
INFORMATION - Closing DataSource: demoDS
INFORMATION - Closing DataSource: demoDSNonJTA
Exception in thread "Thread-0" java.lang.RuntimeException: org.apache.openejb.OpenEjbContainer$AssembleApplicationException: javax.enterprise.inject.spi.DeploymentException: couldn't start owb context
at com.github.rzo1.DemoMain.run(DemoMain.java:116)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.openejb.OpenEjbContainer$AssembleApplicationException: javax.enterprise.inject.spi.DeploymentException: couldn't start owb context
at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:346)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56)
at com.github.rzo1.DemoMain.run(DemoMain.java:90)
... 1 more
Caused by: javax.enterprise.inject.spi.DeploymentException: couldn't start owb context
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:191)
at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:41)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:913)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:717)
at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:342)
... 3 more
Caused by: org.apache.openejb.OpenEJBRuntimeException: java.lang.NullPointerException
at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:200)
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:189)
... 7 more
Caused by: java.lang.NullPointerException
at org.apache.openejb.cdi.CdiScanner.handleBda(CdiScanner.java:271)
at org.apache.openejb.cdi.CdiScanner.init(CdiScanner.java:148)
at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:179)
... 8 more
I added a branch with this changes on the GitHub Project for further investigation.
UPDATE 2
I excluded javax.xml.* from the shade:
<excludes>
<exclude>META-INF/faces-config.xml</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>javax/xml/**</exclude>
</excludes>
However, the exception remains the same as in Update 1. I pushed a related branch to the GitHub repository.
So my question is:
What else needs to be excluded from the shade?
With the help of the other answers , I was finally able to find a working solution for building a standalone fat jar, which is working for my use-case.
UPDATE 3:
The steps (for now) are:
Usage of OpenWebBeansPropertiesTransformer instead AppendingTransformer as stated by P. Merkle
Exclude java.xml.* in the shade as stated by Romain Manni-Bucau:
<excludes>
<exclude>META-INF/faces-config.xml</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>javax/xml/**</exclude>
Add a scan.xml in META-INF including only packages / classes, which should be scanned. Current working version can be found here
Question:
Is their an official or better way of doing this?
http://tomee.apache.org/advanced/shading/index.html and maybe http://tomee.apache.org/advanced/applicationcomposer/index.html are also good starting points.
Now it seems you scan unexpected classes like xml one where the classloader is null. Likely exclude javax.xml.* from scanning or even the shade and it will work
The exception is caused by merging multiple openwebbeans.properties files from different modules into a single properties file via AppendingTransformer.
This is because openwebbeans.properties files are structured in a special way:
All those files contain a single property configuration.ordinal which defines their 'importance'. Any setting from a property file with a higher configuration.ordinal will overwrite settings from one with a lower configuration.ordinal.
Now, if you naively merge these files--as AppendingTransformer does-- , you will end up with multiple competing ordinal properties in the same file.
The solution is to replace AppendingTransformer with OpenWebBeansPropertiesTransformer, which preserves priorities while merging.
An example pom.xml is available here: http://openwebbeans.apache.org/meecrowave/meecrowave-maven/index.html
Bad news is, however, that this solution uncovers another exception:
java.lang.NullPointerException at org.apache.openejb.cdi.CdiScanner.handleBda(CdiScanner.java:271)
So far I've not been able to identify the cause of that.

Calling IDX MLS SOAP APIs of ihomefinder from Java Spring MVC

I want to use ihomefinder's test APIs to get the data and insert it into my own database. I am using Spring MVC and the link provided by them which I configured in my pom.xml to get the data is http://axisws.idxre.com:8080/axis2/services/IHFPartnerServices?wsdl.
From various searches I found that all the provided APIs are in package com.ihomefinder.api so I included it too into the pom.xml
Here is the pom.xml code:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-ws</artifactId>
<version>1.3.1.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.13.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>com.ihomefinder.api</generatePackage>
<schemas>
<schema>
<url>http://axisws.idxre.com:8080/axis2/services/IHFPartnerServices?wsdl</url>
</schema>
</schemas>
</configuration>
</plugin>
</plugins>
</build>
Now I am trying to login with the test username and password provided by them, but to hit the login service I need to create the Object of Request class which is not found in the package com.ihomefinder.api.
Here is the java code I am using to make the request:
import javax.xml.bind.JAXBElement;
import org.springframework.ws.client.core.support.WebServiceGatewaySupport;
import org.springframework.ws.soap.client.core.SoapActionCallback;
import com.ihomefinder.api.Login;
import com.ihomefinder.api.ObjectFactory;
public class IdxMls extends WebServiceGatewaySupport {
public void main() {
// TODO Auto-generated method stub
ObjectFactory objectFactory = new ObjectFactory();
JAXBElement<String> user = objectFactory.createLoginUsername("username");
JAXBElement<String> pass = objectFactory.createLoginPassword("password");
Login login = new Login();
login.setUsername(user);
login.setPassword(pass);
Integer int1 = (Integer) getWebServiceTemplate().marshalSendAndReceive(login, new SoapActionCallback("http://axisws.idxre.com:8080/axis2/services/Login"));
System.out.println(int1);
}
public static void main(String[] args) {
IdxMls idxMls = new IdxMls();
idxMls.main();
}
}
I think the above code is not perfect some things are really missing. So can anybody help me to correct the code by which I can get the response from the API?
It looks like you're using our partner API soap client. Our most current Reseller API is a REST API, and the entry point URL is:
https://www.idxhome.com/restServices/reseller/login
Documentation for the reseller API is not publicly posted at this time. Please email us at support#ihomefinder.com, and we would be happy to provide you the documentation.

Very simple step by step JBehave setup tutorial?

Though I have read many, but many articles on how to use JBehave, I can't get it to work. Here are the steps I went through so far:
Created new Java Project
Downloaded JBehave JAR file version 3.6.8 and added it to my build path libraries
Created a package called com.wmi.tutorials.bdd.stack.specs under the test source folder in my workspace
Added the JBehave JAR file to my Build path Library configuration
Created a JBehave story in the above-mentioned package (StackBehaviourStories.story)
Created a Java class in the above-mentioned package (StackBehaviourStory.java)
Created a Java class in the above-mentioned package (StackBehaviourSteps.java)
Imported the Given, Named, Then, When annotations in my Java class
Written two different scenarios in my JBehave story file
And still, I can't get it to work/run! =(
The story file:
Narrative:
In order to learn to with JBehave using Eclipse
As a junior Java developer though senior in .Net and in BDD
I want to define the behaviour of a custom stack
Scenario: I push an item onto the stack
Given I have an empty stack
When I push an item 'orange'
Then I should count 1
Scenario: I pop from the stack
Given I have an empty stack
When I push an item 'apple'
And I pop the stack
Then I should count 0
The story class
package com.wmi.tutorials.bdd.stack.specs
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.junit.JUnitStory;
public class StackBehaviourStory extends JUnitStory {
#Override
public Configuration configuration() { return new MostUsefulConfiguration(); }
#Override
public InjectableStepsFactory stepsFactory() {
return new InstanceStepsFactory(configuration()
, new StackBehaviourSteps());
}
}
The steps class
package com.wmi.tutorials.bdd.stack.specs
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;
import org.jbehave.core.junit.Assert;
public class StackBehaviourSteps {
#Given("I have an empty stack")
public void givenIHaveAnEmptyStack() { stack = new CustomStack(); }
#When("I push an item $item")
public void whenIPushAnItem(#Named("item") String item) { stack.push(item); }
#Then("I should count $expected")
public void thenIShouldCount(#Named("expected") int expected) {
int actual = stack.count();
if (actual != expected)
throw new RuntimeException("expected:"+expected+";actual:"+actual);
}
}
I'm currently using Eclipse Kepler (4.3) JEE with everything I need to use JUnit, Google App Engine, and yes, JBehave is installed correctly following the Eclipse JBehave installation tutorial.
I can't get it to work. So how can I make it work correctly using Eclipse, JBehave and JUnit?
I know I'm late to the party here but I'm posting because this is the info I wish I had a week ago as it would've saved me a lot of pain. I'm very much into the idea of BDD, but am unfortunately finding JBehave's docs to be a bit of a nightmare, especially when it comes to Maven integration. Moreover a lot of the code I found both on their website and elsewhere didn't work. Through trial and error, and lots of tutorials, I was able to piece together the following. It runs both in Maven and Eclipse, has a single binding class that maps stories to step files, and is able to find story files located in src/test/resources.
here is a working pom 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>com.projectvalis.st1</groupId>
<artifactId>st1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>st1</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgument></compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${failsafe.and.surefire.version}</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<version>4.0.2</version>
<executions>
<execution>
<id>run-stories-as-embeddables</id>
<phase>integration-test</phase>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<ignoreFailureInStories>false</ignoreFailureInStories>
<ignoreFailureInView>false</ignoreFailureInView>
<systemProperties>
<property>
<name>java.awt.headless</name>
<value>true</value>
</property>
</systemProperties>
</configuration>
<goals>
<goal>run-stories-as-embeddables</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-core</artifactId>
<version>4.0.2</version>
</dependency>
</dependencies>
</project>
here is a sample story file
Narrative:
In order to work with files to compress
As a guy who wants to win a bet with cameron
I want to ensure files are ingested and processed in the manner in which the
methods in the ingest class purport to process them.
Scenario: Simple test to give JBehave a test drive
Given a file, a.log
When the caller loads the file as a byte array
Then the byte array that is returned contains the correct number of bytes.
here is a sample step file
package com.projectvalis.compUtils.tests.ingest;
import java.io.File;
import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Named;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;
import org.jbehave.core.steps.Steps;
import org.junit.Assert;
import com.projectvalis.compUtils.util.fileIO.Ingest;
/**
* BDD tests for the ingest class
* #author funktapuss
*
*/
public class LoadByteSteps extends Steps {
private String fNameS;
private byte[] byteARR;
#Given("a file, $filename")
public void setFileName(#Named("filename") String filename) {
File file = new File(getClass().getResource("/" + filename).getFile());
fNameS = file.getPath();
}
#When("the caller loads the file as a byte array")
public void loadFile() {
byteARR = Ingest.loadFile(fNameS);
}
#Then("the byte array that is returned contains the "
+ "correct number of bytes.")
public void checkArrSize() {
File file = new File(fNameS);
Assert.assertTrue(
"loading error - "
+ "the file and the resultant byte array are different sizes!",
(long)byteARR.length == file.length());
}
}
and here is the generic runner
package com.projectvalis.compUtils.tests.runner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.jbehave.core.configuration.Configuration;
import org.jbehave.core.configuration.MostUsefulConfiguration;
import org.jbehave.core.io.CodeLocations;
import org.jbehave.core.io.LoadFromClasspath;
import org.jbehave.core.io.StoryFinder;
import org.jbehave.core.junit.JUnitStories;
import org.jbehave.core.reporters.Format;
import org.jbehave.core.reporters.StoryReporterBuilder;
import org.jbehave.core.steps.InjectableStepsFactory;
import org.jbehave.core.steps.InstanceStepsFactory;
import org.jbehave.core.steps.Steps;
import com.projectvalis.compUtils.tests.ingest.LoadByteSteps;
/**
* generic binder for all JBehave tests. Binds all the story files to the
* step files. works for both Eclipse and Maven command line build.
* #author funktapuss
*
*/
public class JBehaveRunner_Test extends JUnitStories {
#Override
public Configuration configuration() {
return new MostUsefulConfiguration()
.useStoryLoader(
new LoadFromClasspath(this.getClass().getClassLoader()))
.useStoryReporterBuilder(
new StoryReporterBuilder()
.withDefaultFormats()
.withFormats(Format.HTML, Format.CONSOLE)
.withRelativeDirectory("jbehave-report")
);
}
#Override
public InjectableStepsFactory stepsFactory() {
ArrayList<Steps> stepFileList = new ArrayList<Steps>();
stepFileList.add(new LoadByteSteps());
return new InstanceStepsFactory(configuration(), stepFileList);
}
#Override
protected List<String> storyPaths() {
return new StoryFinder().
findPaths(CodeLocations.codeLocationFromClass(
this.getClass()),
Arrays.asList("**/*.story"),
Arrays.asList(""));
}
}
the runner lives in src/test/java//tests.runner.
the ingest test lives in src/test/java//tests.ingest.
the story files live in src/test/resources/stories.
As far as I can tell, JBehave has LOTS of options, so this certainly isn't the only way of doing things. Treat this like a template that will get you up and running quickly.
full source is on github.
Following step by step closely the jbehave Getting Started tutorial, the Run story section says: [...] the ICanToggleACell.java class will allow itself to run as a JUnit test.
This means that the JUnit library is required in your Build path.
Using Eclipse:
Select your current project and right-click it, Build path, Configure Build Path...
Properties for [current project], Java Build Path, Libraries, click [Add Library...]
Add Library, select JUnit, click [Next]
JUnit Library, JUnit library version, select the version you wish to use, click [Finish]
Java Build Path, click [OK]
Project Explorer, select your ICanToggleACell.java class, right-click it, then Run As, and click on JUnit Test
So this is the same here as for the above-example code. The StackBehaviourStory.java class should let itself run as a JUnit test after you add the proper library to the Java build path.
In my case, I have extended my Steps class from Steps (from jbehave core)
i had updated the JunitStory to JunitStories and it worked
public class StackBehaviourStory extends JUnitStory ---> JunitStories

Categories

Resources