I have an akka maven project and I want to run unit test it.
I have defined the test class but when I run it I have an error displayed.
the actor class code snippet is given below :
public class WorkerActor extends UntypedActor {
#Override
public void onReceive(Object msg) throws Exception {
if(msg instanceof GesturePoints)
{ GesturePoints message = (GesturePoints) msg;
Result rslt = initial_Theta(message);
getSender().tell(rslt);
}
else {unhandled(msg);}
}
public Result initial_Theta(GesturePoints p)
{
Result result = new Result();
if(p.getPoints().get("x").size() < 3) //The number of x coordinates as size
{ return null;}
dx = (double) ((Integer)p.getPoints().get("x").get(2) - (Integer)p.getPoints().get("x").get(0)) ;
dy = ((Double)p.getPoints().get("y").get(2)) - ((Double)p.getPoints().get("y").get(0));
{
result.setResult("feature1", initial_cos);
result.setResult("feature2", initial_sin);
}
return result;
}
}
the test class is given in the code below
public class ActorTest {
TestKit testKit;
TestActorRef<WorkerActor> testedActor ;
TestProbe tProbe;
#Before
public void setUp()
{
testKit = new TestKit(ActorSystem.apply());
tProbe = TestProbe.apply(testKit.system());
testedActor = TestActorRef.apply(new Props(new UntypedActorFactory()
{
public WorkerActor create()
{
return new WorkerActor();
}
}),testKit.system());
}
#Test
public void testWorkerActor()
{
ArrayList<Object> x = new ArrayList<Object>();
ArrayList<Object> y = new ArrayList<Object>();
x.add(0, 1); x.add(1, 2); x.add(2, 3); x.add(3, 4); x.add(4, 5);
y.add(0, 1.00); y.add(1, 2.00); y.add(2, 3.00); y.add(3, 4.00); y.add(4, 5.00);
Map<String, ArrayList<Object>> map = new HashMap<String, ArrayList<Object>>();
map.put("x", x);
map.put("y", y);
GesturePoints gp = new GesturePoints();
gp.setPoints(map);
tProbe = TestProbe.apply(testKit.system());
testedActor.tell(gp , tProbe.ref());
TestActor.Message message = tProbe.lastMessage();
Result result = (Result)message;
assertEquals(0.25 , result.getResult().get("x"));
assertEquals(0.25 , result.getResult().get("y"));
}
}
the maven also contain a default test class. Both the efault testclass and the Actortest class are located in the src/test/java folder.
this is the pom file
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.theta.gesture</groupId>
<artifactId>com-theta-gesture</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>com-theta-gesture</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>Com.RubineEngine.GesturePoints</groupId>
<artifactId>Com-RubineEngine-GesturePoints</artifactId>
<version>1.0-SANPSHOT</version>
</dependency>
<dependency>
<groupId>com.result.gesture</groupId>
<artifactId>com-result-gesture</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-remote</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-slf4j</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-testkit</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-kernel</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>typesafe</id>
<name>Typesafe Repository</name>
<url>http://repo.typesafe.com/typesafe/releases/</url>
</repository>
<repository>
<id>repo</id>
<name>repo</name>
<snapshots>
<enabled>true</enabled>
</snapshots>
<url>file://${project.basedir}/repo</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12.4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
the error message is given below
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building com-theta-gesture 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # com-theta-gesture ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # com-theta-gesture ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) # com-theta-gesture ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\FAISAL\Desktop\disaster\com-theta-gesture\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # com-theta-gesture ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # com-theta-gesture ---
[WARNING] The POM for org.apache.maven:maven-plugin-api:jar:2.0.9 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.maven:maven-artifact:jar:2.0.9 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.maven:maven-project:jar:2.0.9 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.maven:maven-core:jar:2.0.9 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.maven:maven-toolchain:jar:2.0.9 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] Surefire report directory: C:\Users\FAISAL\Desktop\disaster\com-theta-gesture\target\surefire-reports
[INFO] Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Concurrency config is parallel='none', perCoreThreadCount=true, threadCount=2, useUnlimitedThreads=false
Running com.theta.gesture.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.011 sec
Running com.theta.gesture.ActorTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.562 sec <<< FAILURE!
testWorkerActor(com.theta.gesture.ActorTest) Time elapsed: 0.002 sec <<< ERROR!
java.lang.ClassCastException: akka.testkit.TestActor$NullMessage$ cannot be cast to com.result.gesture.Result
at com.theta.gesture.ActorTest.testWorkerActor(ActorTest.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:62)
at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Results :
Tests in error:
testWorkerActor(com.theta.gesture.ActorTest): akka.testkit.TestActor$NullMessage$ cannot be cast to com.result.gesture.Result
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.098s
[INFO] Finished at: Tue Oct 23 05:24:12 BST 2012
[INFO] Final Memory: 16M/106M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project com-theta-gesture: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\FAISAL\Desktop\disaster\com-theta-gesture\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Do I have to add any configuration to the application.conf file
hope somebody will help me out.
In your ActorTest, try replacing
TestActor.Message message = tProbe.lastMessage();
Result result = (Result)message;
With this:
tProbe.expectMsgClass(Result.class);
//TestActor.Message message = tProbe.lastMessage();
//Result result = (Result) message.msg(); <- Important
Then change WorkerActor to this:
if(msg instanceof GesturePoints) {
GesturePoints message = (GesturePoints) msg;
//Result rslt = initial_Theta(message);
//getSender().tell(rslt);
getSender().tell(new Result());
}
That should pass. This verifies that WorkerActor is sending back the right type of message (e.g. a Result).
The next step is to uncomment your call to initial_Theta() and figure out why that is not populating the Result correctly.
Related
This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 2 years ago.
I am trying to create a simple WorkbenchFX based project (Java 11) using Maven in the Eclipse IDE but I cannot get it to work because of the following error
[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.4:run (default-cli) on project test_workbenchfx: Error: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
The entire console output is;
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< com.workfx:test_workbenchfx >---------------------
[INFO] Building test_workbenchfx 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # test_workbenchfx ---
[INFO] Deleting C:\Users\JD\eclipse-workspace\test_workbenchfx\target
[INFO]
[INFO] >>> javafx-maven-plugin:0.0.4:run (default-cli) > process-classes # test_workbenchfx >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # test_workbenchfx ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # test_workbenchfx ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to C:\Users\JD\eclipse-workspace\test_workbenchfx\target\classes
[INFO]
[INFO] <<< javafx-maven-plugin:0.0.4:run (default-cli) < process-classes # test_workbenchfx <<<
[INFO]
[INFO]
[INFO] --- javafx-maven-plugin:0.0.4:run (default-cli) # test_workbenchfx ---
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:221)
at java.base/java.util.Arrays$ArrayList.<init>(Arrays.java:4323)
at java.base/java.util.Arrays.asList(Arrays.java:4310)
at javafx.base/javafx.collections.ObservableListBase.addAll(ObservableListBase.java:246)
at javafx.base/javafx.beans.binding.ListExpression.addAll(ListExpression.java:360)
at com.dlsc.workbenchfx.Workbench.initModules(Workbench.java:386)
at com.dlsc.workbenchfx.Workbench.<init>(Workbench.java:339)
at com.dlsc.workbenchfx.Workbench$WorkbenchBuilder.build(Workbench.java:311)
at com.workfx.test_workbenchfx.App.initWorkbench(App.java:76)
at com.workfx.test_workbenchfx.App.start(App.java:59)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
... 1 more
Exception running application com.workfx.test_workbenchfx.App
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:504)
at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:394)
at org.openjfx.JavaFXRunMojo.execute(JavaFXRunMojo.java:100)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:504)
at org.openjfx.JavaFXBaseMojo.executeCommandLine(JavaFXBaseMojo.java:394)
at org.openjfx.JavaFXRunMojo.execute(JavaFXRunMojo.java:100)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.357 s
[INFO] Finished at: 2020-04-10T19:44:03+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.4:run (default-cli) on project test_workbenchfx: Error: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
I built the Maven project using the goal: clean javafx:run
This is 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.workfx</groupId>
<artifactId>test_workbenchfx</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>com.dlsc.workbenchfx</groupId>
<artifactId>workbenchfx-core</artifactId>
<version>11.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.4</version>
<configuration>
<mainClass>com.workfx.test_workbenchfx.App</mainClass>
</configuration>
</plugin>
<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2</version>
</plugin>
-->
<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.workfx.test_workbenchfx.App</mainClass>
</configuration>
</plugin>
-->
</plugins>
</build>
</project>
The project's main class is
package com.workfx.test_workbenchfx;
import java.io.IOException;
import java.util.Locale;
import com.dlsc.workbenchfx.Workbench;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
/**
* JavaFX Workbench App
*/
public class App extends Application {
private Workbench wbench;
/**
* Application entry point
*
* #param args
*/
public static void main(String[] args) {
// See https://stackoverflow.com/questions/64038/setting-java-locale-settings
// https://stackoverflow.com/questions/24988491/difference-between-e-getmessage-and-e-getlocalizedmessage
Locale.setDefault(Locale.FRANCE);
launch(args);
}
#Override
public void start(Stage primaryStage) {
// preferences = new Preferences();
// Initialize the workbench
Scene myScene = new Scene(initWorkbench());
primaryStage.setScene(myScene);
primaryStage.setWidth(1300);
primaryStage.setHeight(730);
primaryStage.show();
primaryStage.centerOnScreen();
// initNightMode();
}
/**
*
* #return
*/
private Workbench initWorkbench() {
wbench = Workbench.builder(null).build();
return wbench;
}
}
I would really appreciate some help to get around this problem because nothing I've tried thus far (clean, update, rebuild) works.
Thanks a lot for your kind assistance.
JD
James_D Thanks a lot. It was so obvious after I read your comment. I passed null as a parameter into Workbench.builder() in the initWorkbench() method. Once I removed it and added a proper class, it worked.
I'm running a Spark quick start application:
/* SimpleApp.java */
import org.apache.spark.sql.SparkSession;
import org.apache.spark.sql.Dataset;
public class SimpleApp {
public static void main(String[] args) {
String logFile = "/data/software/spark-2.4.4-bin-without-hadoop/README.md"; // Should be some file on your system
SparkSession spark = SparkSession.builder().appName("Simple Application").getOrCreate();
Dataset<String> logData = spark.read().textFile(logFile).cache();
long numAs = logData.filter(s -> s.contains("a")).count();
long numBs = logData.filter(s -> s.contains("b")).count();
System.out.println("Lines with a: " + numAs + ", lines with b: " + numBs);
spark.stop();
}
}
As the official document told,
# Package a JAR containing your application
$ mvn package
When I ran mvn package it raise the below error:
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /home/dennis/java/spark_quick_start/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/dennis/java/spark_quick_start/src/main/java/SimpleApp.java:[11,25] reference to filter is ambiguous
both method filter(scala.Function1<T,java.lang.Object>) in org.apache.spark.sql.Dataset and method filter(org.apache.spark.api.java.function.FilterFunction<T>) in org.apache.spark.sql.Dataset match
[ERROR] /home/dennis/java/spark_quick_start/src/main/java/SimpleApp.java:[12,25] reference to filter is ambiguous
both method filter(scala.Function1<T,java.lang.Object>) in org.apache.spark.sql.Dataset and method filter(org.apache.spark.api.java.function.FilterFunction<T>) in org.apache.spark.sql.Dataset match
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:00 min
[INFO] Finished at: 2020-01-13T15:04:55+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project simple-project: Compilation failure: Compilation failure:
[ERROR] /home/dennis/java/spark_quick_start/src/main/java/SimpleApp.java:[11,25] reference to filter is ambiguous
[ERROR] both method filter(scala.Function1<T,java.lang.Object>) in org.apache.spark.sql.Dataset and method filter(org.apache.spark.api.java.function.FilterFunction<T>) in org.apache.spark.sql.Dataset match
[ERROR] /home/dennis/java/spark_quick_start/src/main/java/SimpleApp.java:[12,25] reference to filter is ambiguous
[ERROR] both method filter(scala.Function1<T,java.lang.Object>) in org.apache.spark.sql.Dataset and method filter(org.apache.spark.api.java.function.FilterFunction<T>) in org.apache.spark.sql.Dataset match
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
This is pom.xml:
<project>
<groupId>edu.berkeley</groupId>
<artifactId>simple-project</artifactId>
<modelVersion>4.0.0</modelVersion>
<name>Simple Project</name>
<packaging>jar</packaging>
<version>1.0</version>
<dependencies>
<dependency> <!-- Spark dependency -->
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.12</artifactId>
<version>2.4.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
It means that your lambda expression can both be turned into a scala.Function1<T,java.lang.Object>or a org.apache.spark.api.java.function.FilterFunction<T>.
I don't know if this would be ambiguous in Scala as well, but in Java it is. You need to explicitely state the type in this case:
long numAs = logData.filter((org.apache.spark.api.java.function.FilterFunction<String>)s -> s.contains("a")).count();
Or write the code in Scala.
It seems to be an compatible issue, as Spark 2.4.4 is using Scala 2.11 (I'm not sure). Because I saw this from the official website:
After changing to 2.11, all is working fine!
<dependency> <!-- Spark dependency -->
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.11</artifactId>
<version>2.4.4</version>
<scope>provided</scope>
</dependency>
You can convert lambda expression to anonymous class creation as shown in below example:
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.SparkSession;
import scala.Function1;
public class SimpleApp {
public static void main(String[] args) {
String logFile = "/data/software/spark-2.4.4-bin-without-hadoop/README.md"; // Should be some file on your system
SparkSession spark = SparkSession.builder().appName("Simple Application").getOrCreate();
Dataset<String> logData = spark.read().textFile(logFile).cache();
long numAs = logData.filter(new Function1<String, Object>() {
public Object apply(String s) {
return s.contains("a");
}
}).count();
long numBs = logData.filter(new Function1<String, Object>() {
public Object apply(String s) {
return s.contains("b");
}
}).count();
System.out.println("Lines with a: " + numAs + ", lines with b: " + numBs);
spark.stop();
}
}
I'm trying to connect to Neo4J using Java, and have been following this sample demo.
I setup a new Maven Project, and added the code which creates a few Nodes and Relationships among the nodes. This is how my main class looks like -
package neo4j;
import org.neo4j.cypher.internal.compiler.v2_3.No;
import org.neo4j.graphdb.*;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import java.io.File;
/**
* Created by manish on 5/15/17.
*/
public class Neo4JDemo {
public enum NodeType implements Label {
Person, Course, Dummy;
}
public enum RelationType implements RelationshipType {
Knows, BelongsTo;
}
public static void main(String[] args) {
GraphDatabaseFactory databaseFactory = new GraphDatabaseFactory();
File file = new File("/home/manish/Documents/Development/Software/neo4j-community-3.1.4/data/databases/graph.db");
GraphDatabaseService graphDatabaseService = databaseFactory.newEmbeddedDatabase(file);
try(Transaction tx = graphDatabaseService.beginTx()) {
Node bobNode = graphDatabaseService.createNode(NodeType.Person);
bobNode.setProperty("PID", 5001);
bobNode.setProperty("Name", "Bob");
bobNode.setProperty("Age", 23);
Node bNode = graphDatabaseService.createNode(NodeType.Dummy);
bNode.setProperty("PID", 5001);
bNode.setProperty("Name", "Bob");
bNode.setProperty("Age", 23);
Node aliceNode = graphDatabaseService.createNode(NodeType.Person);
aliceNode.setProperty("PID", 5002);
aliceNode.setProperty("Name", "Alice");
aliceNode.setProperty("Age", 20);
Node eveNode = graphDatabaseService.createNode(NodeType.Person);
eveNode.setProperty("PID", 5003);
eveNode.setProperty("Name", "Eve");
eveNode.setProperty("Age", 25);
Node itNode = graphDatabaseService.createNode(NodeType.Course);
itNode.setProperty("ID", 1);
itNode.setProperty("Name", "IT Beginners");
itNode.setProperty("Location", "Room 154");
Node ecNode = graphDatabaseService.createNode(NodeType.Course);
ecNode.setProperty("ID", 2);
ecNode.setProperty("Name", "Advanced Electronics");
bobNode.createRelationshipTo(aliceNode, RelationType.Knows);
Relationship bobRelIt = bobNode.createRelationshipTo(itNode, RelationType.BelongsTo);
bobRelIt.setProperty("Role", "Student");
Relationship bobRelEc = bobNode.createRelationshipTo(ecNode, RelationType.BelongsTo);
bobRelEc.setProperty("Role", "Supply Teacher");
Relationship aliceRelIt = aliceNode.createRelationshipTo(itNode, RelationType.BelongsTo);
aliceRelIt.setProperty("Role", "Teacher");
tx.success();
}
graphDatabaseService.shutdown();
}
}
When I run the project, it compiles successfully -
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for neo4j:neo4j-setup:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 10, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building neo4j-setup 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # neo4j-setup ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/manish/Documents/Development/Thesis/Neo4J-Test1/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # neo4j-setup ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /home/manish/Documents/Development/Thesis/Neo4J-Test1/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.420 s
[INFO] Finished at: 2017-05-15T19:24:46-04:00
[INFO] Final Memory: 25M/263M
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0
However, when I head over to the Neo4J Browser at localhost:7474, there are no nodes or relationships of the type that was created through this Java code -
I'm not sure what's going wrong, and would appreciate any help with this.
UPDATE - including 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">
<modelVersion>4.0.0</modelVersion>
<groupId>neo4j</groupId>
<artifactId>neo4j-setup</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<packaging>jar</packaging>
<name>neo4j-setup</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>3.1.4</version>
</dependency>
</dependencies>
</project>
I'm newborn in writing anotations in Java. I was trying to write my own following this tutorial: Playing with Java annotation processing
I wrote everything like it is there, but during compilation I'm getting an error:
Bad service configuration file javax.annotation.processing.Processor Provider <my class> not found.
I'm using netbeans and maven with plugin maven-compiler-plugin v. 2.5.1. and java sources v.1.8.
In my pom.xml file I have (like suggested in page) following code:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- Disable annotation processing for ourselves. -->
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
My OS is Linux (leatest ubuntu) and maven is that one integrated in Netbeans.
I was trying to google it, but nothing helped me. All tutorials were for older release of plugin and Java. I tried older release of maven-compiler-plugin but with no effect. I cannot switch to older version of java because of new features introduced in Java 8.
Thanks a lot for any pointing me how to fix it.
Edit:
Here is full list of my sources:
Config.java
#Retention(RetentionPolicy.SOURCE)
#Target(value = {ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.PARAMETER})
public #interface Config {
String name();
String type();
String defaultValue();
}
ConfigAnnotationProcessor.java
#SupportedAnnotationTypes(
{"sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotations"}
)
public class ConfigAnnotationProcessor extends AbstractProcessor {
#Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment env) {
Messager messager = processingEnv.getMessager();
annotations.stream().forEach((te) -> {
env.getElementsAnnotatedWith(te).stream().forEach((e) -> {
messager.printMessage(Diagnostic.Kind.NOTE,
"Printing: " + e.toString());
});
});
return true;
}
#Override
public SourceVersion getSupportedSourceVersion() {
return SourceVersion.latestSupported();
}
}
META-INF/services/javax.annotation.processing.Processor
sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotationProcessor
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>sk.lieskove301.jianghongtiao</groupId>
<artifactId>MotionAnalyser</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
.... some dependencies ...
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<profiles>
<profile>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- Disable annotation processing for ourselves.-->
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
And this is log of my compiler:
cd /home/xjuraj/Dropbox/Work/MotionAnalyser; JAVA_HOME=/usr/lib/jvm/java-8-oracle /usr/local/netbeans-8.0/java/maven/bin/mvn clean install
Scanning for projects...
------------------------------------------------------------------------
Building MotionAnalyser 1.0-SNAPSHOT
------------------------------------------------------------------------
--- maven-clean-plugin:2.4.1:clean (default-clean) # MotionAnalyser ---
Deleting /home/xjuraj/Dropbox/Work/MotionAnalyser/target
--- maven-resources-plugin:2.5:resources (default-resources) # MotionAnalyser ---
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
Copying 6 resources
--- maven-compiler-plugin:2.3.2:compile (default-compile) # MotionAnalyser ---
Compiling 27 source files to /home/xjuraj/Dropbox/Work/MotionAnalyser/target/classes
-------------------------------------------------------------
COMPILATION ERROR :
-------------------------------------------------------------
error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotationProcessor not found
1 error
-------------------------------------------------------------
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.661s
Finished at: Mon Aug 11 19:56:16 CEST 2014
Final Memory: 12M/180M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project MotionAnalyser: Compilation failure
error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotationProcessor not found
-> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Edit 2 and so on...:
Screenshot of my environment is here
Screenshot of my folder structure
Output of non-integrated maven
xjuraj#xjuraj-pc:~/Dropbox/Work/MotionAnalyser$ mvn -e package
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - sk.lieskove301.jianghongtiao:MotionAnalyser:jar:1.0-SNAPSHOT
[INFO] task-segment: [package]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 6 resources
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 27 source files to /home/xjuraj/Dropbox/Work/MotionAnalyser/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotationProcessor not found
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotationProcessor not found
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.BuildFailureException: Compilation failure
error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotationProcessor not found
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:715)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
error: Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: Provider sk.lieskove301.jianghongtiao.motionanalyser.config.ConfigAnnotationProcessor not found
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:729)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Thu Aug 14 15:10:26 CEST 2014
[INFO] Final Memory: 19M/187M
[INFO] ------------------------------------------------------------------------
Cheers,
juraj
Thanks a lot bigdestroyer for your time and help. I already found where the bug was. It was in pom.xml file. My structure was:
<project>
[...]
<dependencies>.... some dependencies ...</dependencies>
<properties>.... some properties ...</properties>
<profiles>
<profile>
<build>
<plugins>
<plugin>
... plugins & settings ...
But there were problem with tags <profiles> and <profile>. I removed them and it works like a charm now.
So my working pom.xml now looks like:
<?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>sk.lieskove301.jianghongtiao</groupId>
<artifactId>MotionAnalyser</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
...dependencies...
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- Disable annotation processing for ourselves.-->
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>
</project>
The problem seems to be in this instruction:
<compilerArgument>-proc:none</compilerArgument>
OP's answer has that line in Maven configuration, but he doesn't mention its importance.
I, too, tried to write an annotation processor and compile it with Maven. Addinng the line did the trick.
I'm running Jbehave maven plugin with run-stories-with-annotated-embedder. But when any scenario fails, then stop all the other scenarios. But I would like to run all the scenarios and then do a report with the scenarios that fails. Is it possible to do this ??
I setup the jbehave strategy configuration to SilentlyAbsorbingFailure, and also I tryed ignoreFailureInStories option... but it dosen't work for me. I think I am missing something.
This is my maven execution code when fails:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Consumer Regression Test Suite .................... SUCCESS [0.591s]
[INFO] Customer Regression Test Suite Commons module ..... SUCCESS [2.678s]
[INFO] Customer Regression Test Suite Core module ........ FAILURE [25:24.539s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 25:28.081s
[INFO] Finished at: Mon Dec 16 15:42:02 CET 2013
[INFO] Final Memory: 71M/664M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jbehave:jbehave-maven-plugin:3.7.4:run-stories-with- annotated-embedder (embeddable-stories) on project consumer-regression-test-suite-core: Failed to run stories with annotated embedder runner: Annotated embedder run failed with runner org.jbehave.core.junit.spring.SpringAnnotatedEmbedderRunner#72f4abb9: Failures in running stories: ReportsCount[stories=2,storiesNotAllowed=0,storiesPending=0,scenarios=16,scenariosFailed=2, scenariosNotAllowed=0,scenariosPending=0,stepsFailed=2] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jbehave:jbehave-maven-plugin:3.7.4:run-stories-with-annotated-embedder (embeddable- stories) on project consumer-regression-test-suite-core: Failed to run stories with annotated embedder runner
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoFailureException: Failed to run stories with annotated embedder runner
at org.jbehave.mojo.RunStoriesWithAnnotatedEmbedderRunner.execute(RunStoriesWithAnnotatedEmbedderRunner.java:23)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
Caused by: org.jbehave.core.embedder.Embedder$AnnotatedEmbedderRunFailed: Annotated embedder run failed with runner org.jbehave.core.junit.spring.SpringAnnotatedEmbedderRunner#72f4abb9
at org.jbehave.core.embedder.Embedder.runStoriesWithAnnotatedEmbedderRunner(Embedder.java:178)
at org.jbehave.mojo.RunStoriesWithAnnotatedEmbedderRunner.execute(RunStoriesWithAnnotatedEmbedderRunner.java:21)
... 21 more
Caused by: org.jbehave.core.embedder.Embedder$RunningStoriesFailed: Failures in running stories: ReportsCount[stories=2,storiesNotAllowed=0,storiesPending=0,scenarios=16,scenariosFailed=2,scenariosNotAllowed=0,scenariosPending=0,stepsFailed=2]
at org.jbehave.core.embedder.Embedder$ThrowingRunningStoriesFailed.handleFailures(Embedder.java:499)
at org.jbehave.core.embedder.Embedder.handleFailures(Embedder.java:265)
at org.jbehave.core.embedder.Embedder.generateReportsView(Embedder.java:252)
at org.jbehave.core.embedder.Embedder.generateReportsView(Embedder.java:233)
at org.jbehave.core.embedder.Embedder.runStoriesAsPaths(Embedder.java:212)
at nl.tele2.crts.core.business.configuration.CommonsStoryConfiguration.run(CommonsStoryConfiguration.java:89)
at org.jbehave.core.embedder.Embedder.runStoriesWithAnnotatedEmbedderRunner(Embedder.java:173)
... 22 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :consumer-regression-test-suite-core
My Maven configuration:
...
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<version>${jbehave.version}</version>
<executions>
<execution>
<id>unpack-view-resources</id>
<phase>process-resources</phase>
<goals>
<goal>unpack-view-resources</goal>
</goals>
</execution>
<execution>
<id>embeddable-stories</id>
<phase>test</phase>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<scope>test</scope>
<includes>
<include>**/Order1Story.java</include>
<include>**/Order2Story.java</include>
<include>**/Order3Story.java</include>
<include>**/Order4Story.java</include>
</includes>
<generateViewAfterStories>true</generateViewAfterStories>
</configuration>
<goals>
<goal>run-stories-with-annotated-embedder</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
</dependencies>
</plugin>
</plugins>
My Story class:
#RunWith(SpringAnnotatedEmbedderRunner.class)
#Configure()
#UsingEmbedder(embedder = Embedder.class, generateViewAfterStories = true, ignoreFailureInStories = false, ignoreFailureInView = false, storyTimeoutInSecs = 1200)
#UsingSpring(resources = { "classpath:crts-application-context.xml",
"classpath:steps/dsl/crts-jbehave-commons-dsl-configuration- steps.xml",
"classpath:steps/dsl/crts-jbehave-order-dsl-steps- context.xml" })
public class Order1Story extends CommonsStoryConfiguration {
protected List<String> storyPaths() {
return new StoryFinder().findPaths(codeLocationFromClass(this.getClass()).getFile(),
asList("**/" + System.getProperty("storyFilter", "*") + "order/dsl/order- 1P-dsl*.story"), null);
}
}
Configuration class:
public abstract class CommonsStoryConfiguration extends InjectableEmbedder {
#Test
public void run() throws Throwable {
final CrossReference crossReference =
new CrossReference().withJsonOnly().withOutputAfterEachStory(true).excludingStoriesWithNoExecutedScenarios(true);
final SeleniumContext seleniumContext = new SeleniumContext();
// Step Monitor
// final ContextView contextView = new LocalFrameContextView().sized(640, 120);
// final SeleniumStepMonitor stepMonitor = new SeleniumStepMonitor(contextView,
// seleniumContext, crossReference.getStepMonitor());
// Formatting
final Format[] formats = new Format[] { new SeleniumContextOutput(seleniumContext), CONSOLE, HTML };
// StoryRporterBuilder
final StoryReporterBuilder reporterBuilder = new StoryReporterBuilder();
reporterBuilder.withCodeLocation(codeLocationFromClass(CommonsStoryConfiguration.class));
reporterBuilder.withFailureTrace(true);
reporterBuilder.withFailureTraceCompression(true);
reporterBuilder.withDefaultFormats();
reporterBuilder.withFormats(formats);
reporterBuilder.withCrossReference(crossReference);
// PatternParser
final RegexPrefixCapturingPatternParser stepPatternParser = new RegexPrefixCapturingPatternParser("$");
// Parameter converter
final DateConverter dateConverter = new DateConverter(new SimpleDateFormat("yyyy-MM-dd"));
final ParameterConverters parameterConverters = new ParameterConverters();
parameterConverters.addConverters(dateConverter);
// Failure Strategy
final FailureStrategy strategy = new SilentlyAbsorbingFailure();
// Story Control
final StoryControls storyControls = new StoryControls();
storyControls.doDryRun(false);
storyControls.doSkipScenariosAfterFailure(false);
// Configuration
final Configuration configuration = injectedEmbedder().configuration();
configuration.useStoryLoader(new LoadFromClasspath(CommonsStoryConfiguration.class));
configuration.useStoryReporterBuilder(reporterBuilder);
configuration.useStepPatternParser(stepPatternParser);
configuration.useParameterConverters(parameterConverters);
configuration.useFailureStrategy(strategy);
configuration.useStoryControls(storyControls);
// configuration.useStepMonitor(stepMonitor);
injectedEmbedder().runStoriesAsPaths(storyPaths());
}
protected abstract List<String> storyPaths();
}
Thanks in advance,
For continue running scenarios, set
ignoreFailureInStories=true
See How do I make JBehave ignore failed scenarios?