I am trying JBehave and I need to run my 3 stories (each story has more or less 2 scenarios (testCases -> Given/When/Then)) using maven.
When I run mvn integration-test I have the following exception
[ERROR] Failed to execute goal org.jbehave:jbehave-maven-plugin:4.0.5:run-stories-as-embeddables (run-stories-as-embeddables) on project bds: Failed to run stories as embeddables: Failures in running embeddables:
[ERROR] com.etermax.bds.test.stories.scenarios.RegisterContentScenarios: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask#77c7bb87 rejected from java.util.concurrent.ThreadPoolExecutor#7cc8d976[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]
[ERROR] com.etermax.bds.test.stories.scenarios.GenerateReportScenarios: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask#56999414 rejected from java.util.concurrent.ThreadPoolExecutor#7cc8d976[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]
My POM configuration is:
<plugin>
<groupId>org.jbehave</groupId>
<artifactId>jbehave-maven-plugin</artifactId>
<version>4.0.5</version>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>run-stories-as-embeddables</id>
<phase>integration-test</phase>
<configuration>
<includes>
<include>**/GenerateReportScenarios.java</include>
<include>**/DeleteReportScenarios.java</include>
<include>**/RegisterContentScenarios.java</include>
</includes>
<scope>test</scope>
<systemProperties>
<property>
<name>java.awt.headless</name>
<value>true</value>
</property>
</systemProperties>
<batch>true</batch>
<ignoreFailureInStories>false</ignoreFailureInStories>
<ignoreFailureInView>true</ignoreFailureInView>
</configuration>
<goals>
<goal>run-stories-as-embeddables</goal>
</goals>
</execution>
</executions>
</plugin>
But if I run one story (for instance, if I include only GenerateReportScenarios.java) the execution was successfully... I don't understand what is wrong when I run the 3 stories together
Can everyone help me on this issue?
Thanks.-
I have the same exception, I removed the
< scope> test < /scope >
line and now it's working.
Related
I have the following configured in the parent pom of my multi module Maven project.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7</version>
<configuration>
<skipTests>false</skipTests>
<useFile>false</useFile>
<disableXmlReport>true</disableXmlReport>
<!-- If you have classpath issue like NoDefClassError,...-->
<!-- useManifestOnlyJar>false</useManifestOnlyJar -->
<includes>
<include>**/*Test.*</include>
<include>**/*Suite.*</include>
<include>**/*Spec.*</include>
</includes>
</configuration>
</plugin>
<!-- enable scalatest -->
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>WDFTestSuite.txt</filereports>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
Nothing fancy here as it is just straight out the same configuration settings that could be found under the Scalatest documentation. But strangely, running the following does not detect any of my scala tests:
mvn clean install
[INFO]
[INFO] --- scalatest-maven-plugin:1.0:test (test) # My-Project ---
Discovery starting.
Discovery completed in 103 milliseconds.
Run starting. Expected test count is: 0
DiscoverySuite:
Run completed in 160 milliseconds.
Total number of tests run: 0
Suites: completed 1, aborted 0
Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
No tests were executed.
Is there anything that I'm missing in the form of any configuration?
EDIT:
Here is how my project is structured:
parent-project
pom.xml
src
main
scala
java
child-project
pom.xml
src
main
test
scala
java
I am working on a Scala Spark application to read data from a source db and load it into bigquery and I wrote below code for it.
object Marker extends App {
val ec = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(3)) // Spawning 3 threads for 3 active stages.
override def main(args: Array[String]): Unit = {
val conf = new SparkConf().set("spark.network.timeout", "12000s").set("spark.kryoSerializer.buffer.max", "512m")
conf.registerKryoClasses(Array(classOf[IntoBigquery]))
val spark = SparkSession.builder().appName("app").master("yarn").
config( "spark.serializer", "org.apache.spark.serializer.KryoSerializer").config(conf).getOrCreate()
spark.conf.set("temporaryGcsBucket", "bucket_location")
val ib = new IntoBigquery
if(ib.read_and_ingest(spark=spark, databasename=args(0), tablename=args(1), partitionColumn=args(2), numPartitions=args(3).toInt, upperBound=args(4).toInt)) println("Ingestion Successful!")
else println("Ingestion Failed!")
}
}
My main class is in the object Marker and is under the package: com.somename
This is my project structure:
<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.somename</groupId>
<artifactId>DeltaLoader</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<scala.version>2.12.12</scala.version>
<maven.compiler.source>3.1</maven.compiler.source>
<maven.compiler.target>3.1</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.12</artifactId>
<version>2.4.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-sql -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_2.12</artifactId>
<version>2.4.7</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.somename.Marker</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>default-jar</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.somename.Marker</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I build the project, I see a warning in the console as below:
JAR will be empty - no content was marked for inclusion!
And after the build is completed, I see two jar files:
Default jar file
A fat jar with all the dependencies
I build create the jar in this way:
click on maven from the right vertical pane of IntelliJ -> click on m symbol and then run mvn package
When I copied the jar to my gcp bucket and submitted the jar file there, I see an error message:
21/03/09 11:04:38 WARN org.apache.spark.deploy.SparkSubmit$$anon$2: Failed to load com.somename.Marker.
java.lang.ClassNotFoundException: com.somename.Marker
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348
I also tried to submit the same code from my loca sdk (powershell) using the below command:
gcloud dataproc jobs submit spark --cluster=clustername --region=region_name --jar=gs://bucketlocation/jars/DeltaLoader-1.0-SNAPSHOT-jar-with-dependencies.jar --jars=gs://mssql-jdbc-9.2.0.jre8.jar,gs://spark-bigquery-latest_2.12.jar -- arg1 arg2 arg3 arg4 arg5
Faced the same exception as from the cloud console:
21/03/09 11:14:05 WARN org.apache.spark.deploy.SparkSubmit$$anon$2: Failed to load com.micron.Marker.
java.lang.ClassNotFoundException: com.micron.Marker
And also tried to submit the job directly from local:
spark-submit --master local[2] --deploy-mode client --driver-memory 1g --executor-memory 1g --executor-cores 2 --jars C:\Users\Downloads\mssql-jdbc-9.2.0.jre8.jar,C:\Users\Downloads\spark-bigquery-latest_2.12.jar --class com.somename.Marker C:\Users\IdeaProjects\DeltaLoader\target\DeltaLoader-1.0-SNAPSHOT-jar-with-dependencies.jar arg1 arg2 arg3 arg4 arg5
Even this failed with the same exception.
Is there anything wron with the way I am creating the jar file or any error inside the pom.xml file ?
Could anyone let me know where did I make the mistake ? Any help is much appreciated.
Hi I am using compile time AspectJ to weave classes However some classes are so big that at compile time it is not able to weave it.
so I have already tried adding argument in plugin:
-Xmx2048m
pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
<configuration>
<argLine>-Xmx2048m</argLine>
<complianceLevel>${maven.compiler.target}</complianceLevel>
<source>${maven.compiler.target}</source>
<target>${maven.compiler.target}</target>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<Xlint>ignore</Xlint>
<encoding>${project.build.sourceEncoding}</encoding>
<forceAjcCompile>true</forceAjcCompile>
<sources />
<weaveDirectories>
<weaveDirectory>${project.build.directory}/classes</weaveDirectory>
</weaveDirectories>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
error log:
Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.11:compile (default) on project lsmvAdverseEvent: AJC compiler errors:
[ERROR] error at SafetyMBean.java::0 The class com.x.y.z.MBean exceeds the maximum class size supported by the JVM (constant pool too big).
[ERROR] abort ABORT -- (RuntimeException) key not found in wovenClassFile
[ERROR] key not found in wovenClassFile
[ERROR] java.lang.RuntimeException: key not found in wovenClassFile
[ERROR] java.lang.RuntimeException: key not found in wovenClassFile
[ERROR] at org.aspectj.weaver.WeaverStateInfo.findEndOfKey(WeaverStateInfo.java:408)
[ERROR] at org.aspectj.weaver.WeaverStateInfo.replaceKeyWithDiff(WeaverStateInfo.java:364)
[ERROR] at org.aspectj.weaver.bcel.LazyClassGen.getJavaClassBytesIncludingReweavable(LazyClassGen.java:711)
How to solve this issue Please Help?
I'm using maven scala test plugin as described here. I defined two test classes and put them under src/test/scala:
Tests are looking like the following:
class LoginTest extends FlatSpec with ShouldMatchers with WebBrowser with Eventually with IntegrationPatience {
...
}
My pom.xml contains the following dependencies / configuration:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.44.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>2.2.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>WDF TestSuite.txt</filereports>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<id>scala-compile</id>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
When I run mvn test I got the message:
[INFO] --- scalatest-maven-plugin:1.0:test (test) # selenium ---
Discovery starting.
Discovery completed in 30 milliseconds.
Run starting. Expected test count is: 0
DiscoverySuite:
Run completed in 91 milliseconds.
Total number of tests run: 0
Suites: completed 1, aborted 0
Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
No tests were executed.
Calling tests from Intellij brings a message:
0 test class found in package '<default package>'
Had similar problems
mvn install discovers test, mvn test does not
I had to make 2 changes for this to work in my case:
Change the name of the filereport, remove space: <filereports>WDFTestSuite.txt</filereports>
Explicitly say not to skip tests: <skipTests>false</skipTests>
So the configuration block looks like this:
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>WDFTestSuite.txt</filereports>
<skipTests>false</skipTests>
</configuration>
I try to do run-as -> mvn install in eclipse, but then i get an error but i dont know how to solve it.
This is the error:
Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.0:shade (default) on project reminder: Execution default of goal org.apache.maven.plugins:maven-shade-plugin:2.0:shade failed: Plugin org.apache.maven.plugins:maven-shade-plugin:2.0 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-shade-plugin:jar:2.0 (): Failed to read artifact descriptor for commons-io:commons-io:jar:1.3.2: Could not transfer artifact org.apache.commons:commons-parent:pom:3 from/to central (http://repo.maven.apache.org/maven2): No response received after 60000 -> [Help 1]
My pom looks like this:
<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>mednanny</groupId>
<artifactId>reminder</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Reminder</name>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.24</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.6</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>Reminder.ReminderErinnerungJob</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
For other folks who are facing same issue, mine got resolved by falling back to Maven version 3.0.x. Coz my project was not ready for the version 3.1.x.
Looks like an internet connection issue to me:
Could not transfer artifact org.apache.commons:commons-parent:pom:3
from/to central (http://repo.maven.apache.org/maven2):
No response received after 60000
What happens if you repeat the command? The file should be available on the central repo: http://search.maven.org/#artifactdetails%7Corg.apache.commons%7Ccommons-parent%7C3%7Cpom
Can you try to run the command again?
Probably already solved this, but everyone else, try updating maven-shade-plugin to 2.1. You can do so by editing pom.xml.
Found this solution here: https://issues.apache.org/jira/browse/CAMEL-6587