Getting the below error in maven jenkins web project
Below is my pom file:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.mojo/versions-maven-plugin -->
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-dependency-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-assembly-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.mycompany</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<descriptor>src/assembly/dep.xml</descriptor>
</configuration>
<executions>
<execution>
<id>create-archive</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.2</version>
<inherited>false</inherited>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
</plugin>
</plugins>
<finalName>MyWebAppMaven</finalName>
</build>
</project>
When ever i try to build in jenkins it throws that error which is given above.
My project is simple web project, and my jenkins config for proj is as below:
Related
I am trying to compile a Jave project using maven into a single executable .jar but am recieveing one of two errors:
no main manifest attribute, in csci6461-1.0-SNAPSHOT.jar
or one pertaining to JavaFX
Error: JavaFX runtime components are missing, and are required to run this application
I need the file to be able to be ran directly by the user, what is the best way to approach this?
This is my pom file:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.csci6461</groupId>
<artifactId>csci6461</artifactId>
<version>1.0-SNAPSHOT</version>
<name>CSCI6461</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.8.0</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17.0.0.1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codeartisans.javafx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.codeartisans.javafx</groupId>
<artifactId>javafx-deployer-maven-plugin</artifactId>
<version>1.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
<!-- Skip the tests run. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<!-- Sources generation -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.csci6461.ComputerSimulation</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I have also tried using an Ant build but the latter of the two errors still persist.
I'm working with Java 8 in a project that requires some libraries from JavaFX the problem is that I have already added some other libraries like JFreeChart to my project and only need to import the jar and all the dependencies.
However with JavaFX I can't do it, I got missing several dependencies like osgi.wiring.package=org.w3c.dom.html, but I can't solved it, so how would be the proper way to work with Maven, OSGi and JavaFX?
I left my pom file so you can see how I'm configuring it.
<?xml version="1.0"?>
<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.EconTech</groupId>
<artifactId>Dashboard</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Inside Dashboard</name>
<packaging>bundle</packaging>
<properties>
<!--********************************************************************-->
<!-- Note: Update this section with relevant meta data -->
<!-- that comes along with your URCap -->
<!--********************************************************************-->
<!--******************* BEGINNING OF URCAP META DATA *******************-->
<urcap.symbolicname>com.EconTech.Dashboard</urcap.symbolicname>
<urcap.vendor>Econ Tech S.A. de C.V.</urcap.vendor>
<urcap.contactAddress>info#econ-tech.com</urcap.contactAddress>
<urcap.copyright>Copyright © 2019 ECON Tech. All rights reserved.</urcap.copyright>
<urcap.description>Shows and saves robot information inside itself</urcap.description>
<urcap.licenseType>Apache License 2.0</urcap.licenseType>
<!--********************** END OF URCAP META DATA **********************-->
<!--********************************************************************-->
<!-- Host, username and password of the robot to be used when running "mvn install -Premote" -->
<urcap.install.host>localhost</urcap.install.host>
<urcap.install.username>root</urcap.install.username>
<urcap.install.password>easybot</urcap.install.password>
<!-- <ursimvm.install.host></ursimvm.install.host>
<ursimvm.install.username>ur</ursimvm.install.username>
<ursimvm.install.password>easybot</ursimvm.install.password>-->
<!--Install path for the UR Sim-->
<ursim.home></ursim.home>
<!--Host and standard user/password for UR Sim running in a VM-->
<ursimvm.install.host></ursimvm.install.host>
<ursimvm.install.username>ur</ursimvm.install.username>
<ursimvm.install.password>easybot</ursimvm.install.password>
</properties>
<build>
<plugins>
<!-- Plugin for maven and JDK 1.8-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<runOrder>alphabetical</runOrder>
<useSystemClassLoader>false</useSystemClassLoader>
<includes>
<include>**/JFreeChartTestSuite.java</include>
</includes>
</configuration>
</plugin>
<!-- Este plugin es para agregar jars
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.4.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<configuration>
<instructions>
<!--********** DO NOT MODIFY THE ENTRIES OF THIS SECTION **********-->
<Bundle-Category>URCap</Bundle-Category>
<Bundle-Activator>com.EconTech.Dashboard.impl.Activator</Bundle-Activator>
<Bundle-Vendor>${urcap.vendor}</Bundle-Vendor>
<Bundle-ContactAddress>${urcap.contactAddress}</Bundle-ContactAddress>
<Bundle-Copyright>${urcap.copyright}</Bundle-Copyright>
<Bundle-LicenseType>${urcap.licenseType}</Bundle-LicenseType>
<Bundle-Description>${urcap.description}</Bundle-Description>
<!--***************************************************************-->
<Import-Package>
com.ur.urcap.api*;version="[1.4.0,2.0.0)", org.jfree.jfreechart*;resolution:=optional,
org.jfree.jcommon*;resolution:=optional, javax.servlet.*;resolution:=optional,
eu.hansolo.Medusa*;resolution:=optimal, com.oracle.javafx*;resolution:=optimal,
org.eclipse.platform*;resolution:=optimal, org.w3c.dom*;resolution:=optimal,
<!-- org.openjfx.javafx-controls*;resolution:=optimal, !com.EconTech.Dashboard.jfreechart-1.0.19.*, !com.EconTech.Dashboard.jcommon-1.0.23.*, -->
*
</Import-Package>
<!-- !org.openjfx.javafx-controls, -->
<Embed-Dependency>
!org.jfree.jfreechart, !org.jfree.jcommon, !javax.servlet,
!com.oracle.javafx, !org.osgi.core, !com.ur.urcap.api,
!org.eclipse.platform, !org.w3c.dom; scope=compile|runtime
</Embed-Dependency>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<!-- generate URCap package after compiling -->
<execution>
<id>package-urcap</id>
<phase>package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>cp</executable>
<commandlineArgs>target/${project.build.finalName}.jar target/${project.build.finalName}.urcap</commandlineArgs>
<workingDirectory>.</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- JavaFX Dependency-->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>javafx</artifactId>
<version>8.0.60</version>
</dependency>
<!-- Eclipse SWT Dependency-->
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.swt</artifactId>
<version>3.106.3</version>
</dependency>
<!-- Eclipse SWT Dependency
<dependency>
<groupId>org.w3c.dom</groupId>
<artifactId>org.w3c.dom.css</artifactId>
<version>1.0</version>
</dependency>-->
<dependency>
<groupId>org.w3c</groupId>
<artifactId>dom</artifactId>
<version>2.3.0-jaxb-1.0.6</version>
</dependency>
<!-- <dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>11.0.2</version>
</dependency> -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.0</version>
</dependency>
<!-- jcommon Dependency-->
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jcommon</artifactId>
<version>1.0.23</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<!-- Medusa Dependency for gauges-->
<dependency>
<groupId>eu.hansolo</groupId>
<artifactId>Medusa</artifactId>
<version>8.3</version>
</dependency>
<!-- jfreechart Dependency -->
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.19</version>
</dependency>
<dependency>
<groupId>com.ur.urcap</groupId>
<artifactId>api</artifactId>
<version>1.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xmlrpc-client</artifactId>
<version>3.1.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xmlrpc-common</artifactId>
<version>3.1.3.0</version>
<exclusions>
<exclusion>
<groupId>org.antlr</groupId>
<artifactId>stringtemplate</artifactId>
</exclusion>
<exclusion>
<groupId>org.antlr</groupId>
<artifactId>antlr-runtime</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.util</groupId>
<artifactId>ws-commons-util</artifactId>
<version>1.0.2.0</version>
<exclusions>
<exclusion>
<artifactId>xml-apis</artifactId>
<groupId>xml-apis</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1.0.0</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>remote</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>remote-install-urcap</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>sshpass</executable>
<commandlineArgs>-p ${urcap.install.password} scp -o StrictHostKeyChecking=no target/${project.build.finalName}.jar ${urcap.install.username}#${urcap.install.host}:/root/.urcaps/${urcap.symbolicname}.jar</commandlineArgs>
<workingDirectory>.</workingDirectory>
</configuration>
</execution>
<execution>
<id>remote-restart-ui</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>sshpass</executable>
<commandlineArgs>-p ${urcap.install.password} ssh ${urcap.install.username}#${urcap.install.host} pkill java</commandlineArgs>
<workingDirectory>.</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>local</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>local-install-urcap</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>cp</executable>
<commandlineArgs>target/${project.build.finalName}.jar ${user.home}/.urcaps/${urcap.symbolicname}.jar</commandlineArgs>
<workingDirectory>.</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>ursim</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>ursim-install-urcap</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>cp</executable>
<commandlineArgs>target/${project.build.finalName}.jar ${ursim.home}/.urcaps/${urcap.symbolicname}.jar</commandlineArgs>
<workingDirectory>.</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>ursimvm</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>ursimvm-install-urcap</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>sshpass</executable>
<commandlineArgs>-p ${ursimvm.install.password} scp -o StrictHostKeyChecking=no target/${project.build.finalName}.jar ${ursimvm.install.username}#${ursimvm.install.host}:/home/ur/ursim-current/.urcaps/${urcap.symbolicname}.jar</commandlineArgs>
<workingDirectory>.</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
I created Jar with the following 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>XXXXXXXXXXXXX</groupId>
<artifactId>XXXXXXXXXXXX</artifactId>
<version>XXXXXXXXXXXXX</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<dependency.locations.enabled>false</dependency.locations.enabled>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>
<arg>-Xlint:all</arg>
<arg>-Xlint:-processing</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<!-- get all project dependencies -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>XXXXXXXXXXXXXXXX</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- bind to the packaging phase -->
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.9</version>
<reportSets>
<reportSet>
<reports>
<report>summary</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.4</version>
<!--<version>3.0.5-SNAPSHOT</version> -->
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<xmlOutput>true</xmlOutput>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.7</version>
<configuration>
<rulesets>
<ruleset>/rulesets/java/basic.xml</ruleset>
<ruleset>/rulesets/java/design.xml</ruleset>
</rulesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
<dependencies>
<dependency>
<groupId>com.google.cloud.dataflow</groupId>
<artifactId>google-cloud-dataflow-java-sdk-all</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.30</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<!-- Hamcrest and JUnit are required dependencies of DataflowAssert, which
is used in the main code of DebuggingWordCount example. -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.7</version>
</dependency>
</dependencies>
maven command
mvn clean
mvn compile
mvn package
Jar Command to execute
java -jar XXXXXX-jar-with-dependencies.jar
--runner=DataflowRunner
--jobName=XXXXXXXXXX
--project=XXXXXXXXXX
--network=XXXXXXXXXX
--subnetwork=XXXXXXXXXXXX
--workerMachineType=XXXXXXX
--region=XXXXXXXXXX
--maxNumWorkers=XXX
--stagingLocation=XXXXXXXXXX
--tempLocation=XXXXXXXXXXXX
--dataflowJobFile=XXXXXXXXXX
The following error occurred
java.lang.IllegalArgumentException: Unknown 'runner' specified 'DataflowRunner', supported pipeline runners [DirectRunner]
at org.apache.beam.sdk.options.PipelineOptionsFactory.parseObjects(PipelineOptionsFactory.java:1615)
at org.apache.beam.sdk.options.PipelineOptionsFactory.access$400(PipelineOptionsFactory.java:104)
at org.apache.beam.sdk.options.PipelineOptionsFactory$Builder.as(PipelineOptionsFactory.java:291)
Caused by: java.lang.ClassNotFoundException: DataflowRunner
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
As a workaround for the above error, we added the following to the pom file and use DirectRunner only when testing.
<dependency>
<groupId>org.apache.beam</groupId>
<artifactId>beam-runners-direct-java</artifactId>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
When executing with the above workaround, the following error occurred.
java.lang.IllegalArgumentException: Unable to infer a coder and no Coder was specified. Please set a coder by invoking Create.withCoder() explicitly.
at org.apache.beam.sdk.transforms.Create$Values.expand(Create.java:318)
at org.apache.beam.sdk.transforms.Create$Values.expand(Create.java:268)
at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:514)
at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:473)
at org.apache.beam.sdk.values.PBegin.apply(PBegin.java:56)
at org.apache.beam.sdk.Pipeline.apply(Pipeline.java:180)
at org.apache.beam.sdk.io.gcp.bigquery.BatchLoads.expand(BatchLoads.java:344)
at org.apache.beam.sdk.io.gcp.bigquery.BatchLoads.expand(BatchLoads.java:67)
at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:514)
at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:454)
at org.apache.beam.sdk.values.PCollection.apply(PCollection.java:284)
at org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expandTyped(BigQueryIO.java:1019)
at org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expand(BigQueryIO.java:972)
at org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expand(BigQueryIO.java:659)
at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:514)
at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:473)
at org.apache.beam.sdk.values.PCollection.apply(PCollection.java:297)
Caused by: org.apache.beam.sdk.coders.CannotProvideCoderException: Unable to provide a Coder for com.google.api.services.bigquery.model.TableRow.
Building a Coder using a registered CoderProvider failed.
See suppressed exceptions for detailed failures.
As a workaround for the above error, setCoder is set, but the result does not change.
In SDK 1.9.0 we were able to create executable Jar with maven.
If Jar can be created, can you give me a hint of how to change pom file and how to run jar?
Have you tried including the beam-runners-google-cloud-dataflow-java dependency?
https://beam.apache.org/documentation/runners/dataflow/
In the sample example in Netbeans (DukeScript Application) the archetype creates this POM.xml for Maven. I tried commenting out the JUNIT dependency and putting in TestNG.
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>test</scope>
</dependency>
I am still getting errors. Any ideas on how to convert to Testng? Yes they are generally just testing suites but I have a bunch of code built for base classes I would like to reuse.
<?xml version="1.0"?>
<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>
<parent>
<groupId>b</groupId>
<artifactId>a-pom</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>b</groupId>
<artifactId>a</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>a General Client Code</name>
<properties>
<netbeans.compile.on.save>all</netbeans.compile.on.save>
<project.mainclass>b.a.Main</project.mainclass>
<exec.java.bin>${java.home}/bin/java</exec.java.bin>
<exec.debug.arg>-Ddebug=false</exec.debug.arg>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Export-Package>b.a</Export-Package>
<Bundle-SymbolicName>b.a</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<junitArtifactName>com.dukescript.api:junit-osgi</junitArtifactName>
<systemPropertyVariables>
<fxpresenter.headless>true</fxpresenter.headless>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<phase>post-integration-test</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<executable>${exec.java.bin}</executable>
<classpathScope>runtime</classpathScope>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>-javaagent:${project.build.directory}/springloaded.jar</argument>
<argument>-Xverify:none</argument>
<argument>-Dbrowser.rootdir=${basedir}/src/main/webapp/</argument>
<argument>-Dnetbeans.inspect.port=${netbeans.inspect.port}</argument>
<argument>${exec.debug.arg}</argument>
<argument>${project.mainclass}</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>process-classes</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.3.RELEASE</version>
<type>jar</type>
<overWrite>false</overWrite>
<destFileName>springloaded.jar</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>web-pages</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/webpages.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.netbeans.html</groupId>
<artifactId>net.java.html</artifactId>
<version>${net.java.html.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.html</groupId>
<artifactId>net.java.html.json</artifactId>
<version>${net.java.html.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.html</groupId>
<artifactId>net.java.html.boot</artifactId>
<version>${net.java.html.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.html</groupId>
<artifactId>net.java.html.sound</artifactId>
<version>${net.java.html.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.html</groupId>
<artifactId>ko4j</artifactId>
<version>${net.java.html.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>b</groupId>
<artifactId>a-js</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.html</groupId>
<artifactId>net.java.html.boot.fx</artifactId>
<version>${net.java.html.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dukescript.api</groupId>
<artifactId>junit-osgi</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.dukescript.api</groupId>
<artifactId>junit-browser-runner</artifactId>
<version>${junit.browser.version}</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<!-- Nashorn presenter for BrowserRunner
<dependency>
<groupId>org.netbeans.html</groupId>
<artifactId>net.java.html.boot.script</artifactId>
<version>${net.java.html.version}</version>
<scope>test</scope>
<type>jar</type>
</dependency>
-->
<!-- Bck2Brwsr VM presenter for BrowserRunner - - >
<dependency>
<groupId>org.apidesign.bck2brwsr</groupId>
<artifactId>launcher.http</artifactId>
<version>${bck2brwsr.version}</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apidesign.bck2brwsr</groupId>
<artifactId>ko-bck2brwsr</artifactId>
<version>${bck2brwsr.version}</version>
<classifier>bck2brwsr</classifier>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.dukescript.api</groupId>
<artifactId>junit-browser-runner</artifactId>
<version>${junit.browser.version}</version>
<scope>test</scope>
<classifier>bck2brwsr</classifier>
<type>jar</type>
</dependency>
< ! - - End of Bck2Brwsr VM presenter for BrowserRunner -->
</dependencies>
<profiles>
<profile>
<id>javafx</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.netbeans.html</groupId>
<artifactId>net.java.html.boot.fx</artifactId>
<version>${net.java.html.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>desktop</id>
<dependencies>
<dependency>
<groupId>org.netbeans.html</groupId>
<artifactId>net.java.html.boot.fx</artifactId>
<version>${net.java.html.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>${project.mainclass}</mainClass>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<useUniqueVersions>false</useUniqueVersions>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>distro-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/javafx.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>webkit-presenter</id>
<dependencies>
<dependency>
<groupId>com.dukescript.presenters</groupId>
<artifactId>webkit</artifactId>
<version>${presenters.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>browser-presenter</id>
<dependencies>
<dependency>
<groupId>com.dukescript.presenters</groupId>
<artifactId>browser</artifactId>
<version>${presenters.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
Add testng dependency to pom
Comment out the 2 JUNIT dependencies
You only need imports org.testng. Assert; annotations.*;
In your Test package.
Remove #RunWith
Assert.assertTrue(arr.get(0).startsWith("Hello"));
Phone post
My problem: I have to run maven clean site everytime a file is changed so that Eclipse runs the new version... Can someone help me? It's quite annoying to run clean site everytime.
This is (partially) my pom file:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<slick2d.version>1.0.2</slick2d.version>
<junit.version>4.12</junit.version>
<json.plugin.version>1.1.1</json.plugin.version>
<mockito.version>1.9.5</mockito.version>
<findbugs.annotations.version>1.3.2</findbugs.annotations.version>
<javadoc.plugin.version>2.10.3</javadoc.plugin.version>
<checkstyle.plugin.version>2.17</checkstyle.plugin.version>
<pmd.plugin.version>3.6</pmd.plugin.version>
<findbugs.plugin.version>3.0.3</findbugs.plugin.version>
<cobertura.plugin.version>2.7</cobertura.plugin.version>
</properties>
<dependencies>
<dependency> <!-- slick2D dependency -->
<groupId>org.slick2d</groupId>
<artifactId>slick2d-core</artifactId>
<version>${slick2d.version}</version>
</dependency>
<dependency> <!-- junit dependency -->
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency> <!-- json dependency -->
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>${json.plugin.version}</version>
</dependency>
<dependency> <!-- mockito dependency -->
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>${findbugs.annotations.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin> <!-- cobertura -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${cobertura.plugin.version}</version>
<configuration>
<instrumentation>
<excludes>
<exclude>*/CoberturaIgnore.class</exclude>
<exclude>*/highscore/HighScore.class</exclude>
<exclude>*/pop/PopBehaviour.class</exclude>
<exclude>*/ui/*.class</exclude>
</excludes>
<ignoreMethodAnnotations>
<ignoreMethodAnnotation>spiceballs.CoberturaIgnore</ignoreMethodAnnotation>
</ignoreMethodAnnotations>
</instrumentation>
</configuration>
</plugin>
<plugin> <!-- checkstyle -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<configuration>
<configLocation>${basedir}/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>
<plugin> <!-- pmd -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.plugin.version}</version>
<configuration>
<skipEmptyReport>false</skipEmptyReport>
<includeTests>true</includeTests>
<rulesets>
<ruleset>pmd-rules.xml</ruleset>
</rulesets>
</configuration>
</plugin>
<plugin> <!-- findbugs -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs.plugin.version}</version>
<configuration>
<xmlOutput>true</xmlOutput>
<includeTests>true</includeTests>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin> <!-- javadoc report -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${javadoc.plugin.version}</version>
<configuration>
<failOnError>false</failOnError>
</configuration>
<reportSets>
<reportSet>
<id>default</id>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin> <!-- cobertura report -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${cobertura.plugin.version}</version>
</plugin>
<plugin> <!-- checkstyle report -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.plugin.version}</version>
<configuration>
<configLocation>${basedir}/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>
<plugin> <!-- pmd report -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.plugin.version}</version>
<configuration>
<skipEmptyReport>false</skipEmptyReport>
<includeTests>true</includeTests>
<rulesets>
<ruleset>pmd-rules.xml</ruleset>
</rulesets>
</configuration>
</plugin>
<plugin> <!-- findbugs report -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs.plugin.version}</version>
<configuration>
<xmlOutput>true</xmlOutput>
<includeTests>true</includeTests>
</configuration>
</plugin>
</plugins>
</reporting>
If you working within your workspace locally, you can just run -- clean compile --goals. When you are finally done and pushing to higher environments- DEV/TEST/pre-prod, then you would run all the recommended goals for your project.
Look into this link for more details on what each goal does-
https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html