TestNG tests are not getting run when I execute testng.xml using POM file using maven-surefire - maven

0 tests are getting run, when I execute testng.xml using POM file using Maven-surefire.
I am running few selenium tests using testng.xml.
When I run testng.xml file as TestNG test Suite, then it runs fine.
But, when I include testng.xml file (as below) then its not running :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
Below is my POM file snippet:
<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>SAPAutomation</groupId>
<artifactId>SAPAutomation</artifactId>
<!-- <version>3.2</version> -->
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SAPAutomation</name>
<url>http://maven.apache.org</url>
<!-- For javadocs -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.17</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<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>
<!-- To exclude unwanted Package ex: com.SAPAutomation.TEMP etc-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<excludes>
<exclude>**/com/SAPAutomation/Temp/*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>1.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.1.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.45.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.15</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>com.github.detro.ghostdriver</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>org.codeartisans.thirdparties.swing</groupId>
<artifactId>org-openide-util</artifactId>
<version>8.6.2</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14-10.2.0.4.0</artifactId>
<version>10.2.0.4.0</version>
<scope>system</scope>
<systemPath>${basedir}/src/lib/ojdbc14.jar</systemPath>
<!-- <systemPath>${java.home}/lib/ojdbc14.jar</systemPath> -->
</dependency>
<dependency>
<groupId>org.monte.screenrecorder</groupId>
<artifactId>MonteScreenRecorder</artifactId>
<version>10</version>
<scope>system</scope>
<systemPath>${basedir}/src/lib/MonteScreenRecorder.jar</systemPath>
<!-- <systemPath>${java.home}/lib/ojdbc14.jar</systemPath> -->
</dependency>
<!-- <repositories>
<repository>
<id>ojdbc14</id>
<url>http://www.oracle.com/technetwork/apps-tech/jdbc-10201-088211.html</url>
</repository>
</repositories> -->
</dependencies>
</project>
My testng.xml file:
<suite name="Suite" parallel="tests">
<listeners>
<listener class-name="com.SAPAutomation.Listners.RetryListener"/>
</listeners>
<test name="Test1">
<parameter name="TestCaseId" value="TC1" />
<classes>
<class name="com.xyz.abc.MyAutomationTestByXML"/>
</classes>
</test>
<test name="Test2">
<parameter name="TestCaseId" value="TC2" />
<classes>
<class name="com.xyz.abc.MyAutomationTestByXML"/>
</classes>
</test>
<test name="Test3">
<parameter name="TestCaseId" value="TC3" />
<classes>
<class name="com.xyz.abc.MyAutomationTestByXML"/>
</classes>
</test>
</suite>
Test result of running Pom.xml:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for SAPAutomation:SAPAutomation:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for com.oracle:ojdbc14-10.2.0.4.0:jar should not point at files within the project directory, ${basedir}/src/lib/ojdbc14.jar will be unresolvable by dependent projects # line 153, column 16
[WARNING] 'dependencies.dependency.systemPath' for org.monte.screenrecorder:MonteScreenRecorder:jar should not point at files within the project directory, ${basedir}/src/lib/MonteScreenRecorder.jar will be unresolvable by dependent projects # line 162, 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] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SAPAutomation 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # SAPAutomation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\AutomationWorkSpace\SAPAutomation\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) # SAPAutomation ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # SAPAutomation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) # SAPAutomation ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 35 source files to C:\AutomationWorkSpace\SAPAutomation\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.14.1:test (default-test) # SAPAutomation ---
[INFO] Surefire report directory: C:\AutomationWorkSpace\SAPAutomation\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.496 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.137 s
[INFO] Finished at: 2015-04-09T15:01:01+00:00
[INFO] Final Memory: 24M/277M
[INFO] ------------------------------------------------------------------------
Kindly advise.
Issue still persists, even after giving full path of Testng.xml in my POM.xml file.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for SAPAutomation:SAPAutomation:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for com.oracle:ojdbc14-10.2.0.4.0:jar should not point at files within the project directory, ${basedir}/src/lib/ojdbc14.jar will be unresolvable by dependent projects # line 154, column 16
[WARNING] 'dependencies.dependency.systemPath' for org.monte.screenrecorder:MonteScreenRecorder:jar should not point at files within the project directory, ${basedir}/src/lib/MonteScreenRecorder.jar will be unresolvable by dependent projects # line 163, 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] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SAPAutomation 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # SAPAutomation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\AutomationWorkSpace\SAPAutomation\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) # SAPAutomation ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # SAPAutomation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) # SAPAutomation ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 35 source files to C:\AutomationWorkSpace\SAPAutomation\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.14.1:test (default-test) # SAPAutomation ---
[INFO] Surefire report directory: C:\AutomationWorkSpace\SAPAutomation\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.501 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.402 s
[INFO] Finished at: 2015-04-14T17:31:11+00:00
[INFO] Final Memory: 22M/167M
[INFO] ------------------------------------------------------------------------

You can place your testng.xml file under project directly with your pom file then it will execute your test suite.

You need to provide the full path to the testng.xml file for Maven to pick it up.

I was facing this same scenario (issue) while doing the Maven with TestNG integration hands-on along with Rahul Sir's video.
Without the TestNG.xml, POM.xml was able to execute all the tests while being invoked using "mvn test" command from the CLI.
However, I noticed, if I just run the test directly from testng.xml i.e. "run as TestNG suite", then none of the test cases were run.
While took a close look into my test java classes, I discovered that, for using the #Test annotations before my test cases (methods), the import library was --> import org.junit.Test; Because even jUnit has a Test class in its library.
But since we are using TestNG, thus we must need to use this import --> import org.testng.annotations.Test;
While we create a Maven project within Eclipse using the project template i.e. maven-archetype-quickstart template, it creates two parallel folder structure -> one for java (to have the object models & utilities) and the other for test (to contain the test cases). So, by default, there is AppTest.java class and that uses jUnit library for #Test annotation.
So, right after creating the Maven project in eclipse, we should add the TestNG dependency in the pom.xml in case we know that we'll be using TestNG for execution.
I am able to have this issue resolved just by using import org.testng.annotations.Test; within each of my test classes.
TestNG SuiteXML will only work on those #Test annotations while org.testng.annotations.Test is present for the classess.
Hope this will resolve your error too. Thank you.

In the maven-surefire-plugin, provide the full path from under your project to your testng.xml file -- Example:
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>

Above issue got resolved using updating version of Maven-Surefire-plugin in the mentioned POM.xml. Whole set-up lived Happily ever after & after!!
Thanks

Related

azure-functions-maven-plugin final jar missing libraries in classpath

I am try to deploy Java Azure function app from my local machine. My tech stack is fallows,
Azure Function App OS: Linux
Azure Functions Core Tools (2.0.3)
Springboot 2.6.3
spring-boot-maven-plugin 2.6.3
azure-functions-maven-plugin 1.14.3
azure-functions-java-library 1.4.2
spring-cloud-function-adapter-azure 3.2.1
Here is my 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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.avol.func</groupId>
<artifactId>springcloud-eh-func</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Azure Java Functions</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
<azure.functions.maven.plugin.version>1.14.3</azure.functions.maven.plugin.version>
<azure.functions.java.library.version>1.4.2</azure.functions.java.library.version>
<functionAppName>poc-java-func-apsp</functionAppName>
<resource.groupname>AvolPOCs</resource.groupname>
<appserviceplan.name>ASP-AvolPOCs-84f2</appserviceplan.name>
<azure.region>southcentralus</azure.region>
<azure.subscriptionid>xxxxxx</azure.subscriptionid>
<stagingDirectory>${project.build.directory}/azure-functions/${functionAppName}</stagingDirectory>
<start-class>com.avol.func.SpringAppRunner</start-class>
</properties>
<dependencies>
<dependency>
<groupId>com.microsoft.azure.functions</groupId>
<artifactId>azure-functions-java-library</artifactId>
<version>${azure.functions.java.library.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-adapter-azure</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-spring-boot-starter</artifactId>
<version>2.6.3</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-logging-logback</artifactId>
<version>2.6.3</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-function-dependencies</artifactId>
<version>3.2.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.microsoft.azure.functions</groupId>
<artifactId>azure-functions-java-library</artifactId>
<version>${azure.functions.java.library.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>obj</directory>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${stagingDirectory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-functions-maven-plugin</artifactId>
<version>${azure.functions.maven.plugin.version}</version>
<configuration>
<subscriptionId>${azure.subscriptionid}</subscriptionId>
<!-- function app name -->
<appName>${functionAppName}</appName>
<!-- function app resource group -->
<resourceGroup>${resource.groupname}</resourceGroup>
<!-- function app service plan name -->
<appServicePlanName>${appserviceplan.name}</appServicePlanName>
<!-- function app region-->
<!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details#supported-regions for all valid values -->
<region>${azure.region}</region>
<!-- function pricingTier, default to be consumption if not specified -->
<!-- refers https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Functions:-Configuration-Details#supported-pricing-tiers for all valid values -->
<!-- <pricingTier></pricingTier> -->
<!-- Whether to disable application insights, default is false -->
<disableAppInsights>false</disableAppInsights>
<runtime>
<os>linux</os>
<javaVersion>11</javaVersion>
</runtime>
<appSettings>
<property>
<name>FUNCTIONS_EXTENSION_VERSION</name>
<value>~4</value>
</property>
<property>
<name>FUNCTIONS_WORKER_RUNTIME</name>
<value>java</value>
</property>
</appSettings>
</configuration>
<executions>
<execution>
<id>package-functions</id>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>
${project.build.directory}/azure-functions/${functionAppName}
</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources
</directory>
<includes>
<include>**</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.6.3</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot.experimental</groupId>
<artifactId>spring-boot-thin-layout</artifactId>
<version>1.0.28.RELEASE</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Here is my maven build logs,
$ mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< com.avol.func:springcloud-eh-func >----------------
[INFO] Building Azure Java Functions 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # springcloud-eh-func ---
[INFO] Deleting C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) # springcloud-eh-func ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # springcloud-eh-func ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 10 source files to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) # springcloud-eh-func ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # springcloud-eh-func ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) # springcloud-eh-func ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-dependency-plugin:3.2.0:copy-dependencies (copy-dependencies) # springcloud-eh-func ---
[INFO] Copying azure-functions-java-library-1.4.2.jar to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\lib\azure-functions-java-library-1.4.2.jar
[INFO]
[INFO] --- maven-jar-plugin:3.2.2:jar (default-jar) # springcloud-eh-func ---
[INFO] Building jar: C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\springcloud-eh-func-1.0.0-SNAPSHOT.jar
[INFO]
[INFO] --- azure-functions-maven-plugin:1.14.3:package (package-functions) # springcloud-eh-func ---
[INFO] Java home : C:/Users/padaldl/workspace/installedsws/zulu-11-azure-jdk_11.52.13-11.0.13-win_x64
[INFO] Artifact compile version : 11
[INFO]
[INFO] Step 1 of 8: Searching for Azure Functions entry points
[INFO] 2 Azure Functions entry point(s) found.
[INFO]
[INFO] Step 2 of 8: Generating Azure Functions configurations
[INFO] Generation done.
[INFO]
[INFO] Step 3 of 8: Validating generated configurations
[INFO] Validation done.
[INFO]
[INFO] Step 4 of 8: Saving host.json
[INFO] Successfully saved to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\host.json
[INFO]
[INFO] Step 5 of 8: Saving local.settings.json
[INFO] Successfully saved to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\local.settings.json
[INFO]
[INFO] Step 6 of 8: Saving configurations to function.json
[INFO] Starting processing function: uppercase
[INFO] Successfully saved to C:\Users\padaldl\workspace\projects\Avol-POCs\\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\uppercase\function.json
[INFO] Starting processing function: assetSync
[INFO] Successfully saved to C:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp\assetSync\function.json
[INFO]
[INFO] Step 7 of 8: Copying JARs to staging directoryC:\Users\padaldl\workspace\projects\Avol-POCs\src\Java\JavaFunAppPOC\springcloud-eh-func\target\azure-functions\poc-java-func-apsp
[INFO] Copied successfully.
[INFO] Step 8 of 8: Installing function extensions if needed
[INFO] Extension bundle specified, skip install extension
[INFO] Successfully built Azure Functions.
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:copy-resources (copy-resources) # springcloud-eh-func ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 2 resources
[INFO]
[INFO] --- spring-boot-maven-plugin:2.6.3:repackage (repackage) # springcloud-eh-func ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 29.790 s
[INFO] Finished at: 2022-02-03T19:39:15+05:30
[INFO] ------------------------------------------------------------------------
Function App works fine in local from IntellIJ IDEA, and as well run through mvn azure-functions:run command.
When I run the jar using java command java -jar <> it fails with error No Class Definition found error.
mvn azure-functions:deploy succeeded without any issue, and am able to see functions created on azure, but when I trigger function it fails with 500 Internal Error.
I suspect function failing in azure due to external dependencies not added to classpath of jar. From the stackoverflow I found similar question here, suggestion is to go with maven assembly plugin, but my question is why should we use Assembly plugin when I am using springboot plugin?
Finally issue got resolved after installing Azure Functions Core Tools version 4.x through MSI installer on windows.
https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=v4%2Cwindows%2Ccsharp%2Cportal%2Cbash#v2
And it looks like azure functions refer /lib folder under staging directory when function triggers, it need not be springboot fat jar.

How to test methods in a java project using a maven junit5 framework project in eclipse

I created a new maven junit5 framework project to test existing java projects. I added the java project in build path of the newly created maven junit5 framework project. I right clicked the method I wanted to add junit test case for and selected new junit test case and changed the source folder to the new maven junit5 framework project src directory and left the rest of the options as default. Created the junit test and ran the test as a unit test without any issues(screenshot below). Running the same test using maven getting the error below. I added the surefire plugin in pom(below) but still getting the error below. Using eclipse.
-------------------------------------------------------------------------------
Test set: com.build.VersionInfoTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.003 s <<< FAILURE! - in com.build.VersionInfoTest
com.build.VersionInfoTest Time elapsed: 0.002 s <<< ERROR!
java.lang.NoClassDefFoundError: Lcom/build/VersionInfo;
Caused by: java.lang.ClassNotFoundException: com.build.VersionInfo
<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>UnitTesting</groupId>
<artifactId>com.unit.testing</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>com.unit.testing</name>
<description>Junit Tests</description>
<packaging>jar</packaging>
<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>
<junit.jupiter.version>5.5.2</junit.jupiter.version>
<junit.platform.version>1.5.2</junit.platform.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
</project>
Update : I cleaned up the pom(below) but now no tests discovered? when I run the project with junit the test is discovered?
[INFO] Scanning for projects...
[INFO]
[INFO] --------------< UnitTesting:com.unit.testing >---------------
[INFO] Building com.unit.testing 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------- -----------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # com.unit.testing ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # com.unit.testing ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default- testResources) # com.unit.testing ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # com.unit.testing ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M4:test (default-test) # com.unit.testing ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.build.VersionInfoTest
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in com.build.VersionInfoTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.955 s
[INFO] Finished at: 2020-03-09T10:00:22-04:00
[INFO] ------------------------------------------------------------------------
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
<junit.jupiter.version>5.6.0</junit.jupiter.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
</plugin>
</plugins>
</build>
package com.dbb.build
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import com.dbb.build.VersionInfo;
class VersionInfoTest {
VersionInfo versionInfo = VersionInfo.getInstance();
#Test
void getVersion() {
String version = versionInfo.getVersion();
System.out.println(version);
assertNotNull(versionInfo.getVersion(), "expected a return value of"+version+"but was null");
}
}
UPDATE:
[INFO] --- maven-resources-plugin:2.6:testResources (default- testResources) # DBB-Unit-Testing ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # DBB-Unit-Testing ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Unit-Testing/target/test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Unit-Testing/src/test/java/com/VersionInfoTest.java:[7,25] cannot find symbol
symbol: class VersionInfo
location: package com.build
[ERROR] /Unit-Testing/src/test/java/com/build/VersionInfoTest.java: [11,9] cannot find symbol
symbol: class VersionInfo
location: class com.build.TestVersionInfo
[ERROR] /Unit-Testing/src/test/java/com/ /build/VersionInfoTest.java: [11,35] cannot find symbol
symbol: variable VersionInfo
location: class com.build.TestVersionInfo
[INFO] 3 errors
Solution: Using junit-platform-console-standalone-1.5.2.jar and run units via command line. Looks like if we have a non maven project junit-platform-console-standalone seems to be a better option.
Here is a sample of some of my pom I use with Maven 3.x and tests executed as expected with JUnit 5 in Eclipse but also from command line:
Don't add too many Juniper artifacts, some will create some side effect if present.
Note also the updated version of the surefire plugin with had some issue in the past with JUnit5
<properties>
<!-- ensure proper encoding of source and resource files in the project -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit-5.version>5.6.0</junit-5.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-5.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
</plugin>
</plugins>
</build>
UPDATE:
You can find a small example here: https://gist.github.com/asa-git/8e34bbc51b5fcb09b7fab3efdaaa73c9
Note that I am using maven version 3.6.3 and a JDK 8.
Furthermore, when running from the command line on windows (but likewise on other systems), you need to make sure your JDK is on your path before any other JSE installed on your system.

Maven tests are running well locally (OSX) but not running at all on remove CI machine

I have some Maven tests suite using Junit 4.12, that running well using 'mvn test' locally on my Mac, but not running at all on remote CI machine:
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # AndroidAutomationTests ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/circleci/project/AndroidAutomaticTests/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # AndroidAutomationTests ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # AndroidAutomationTests ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/circleci/project/AndroidAutomaticTests/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # AndroidAutomationTests ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.0:test (default-test) # AndroidAutomationTests ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.619 s
[INFO] Finished at: 2019-10-17T07:33:04Z
[INFO] ------------------------------------------------------------------------
Here is the 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>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
<systemPropertyVariables>
<browserStack>0</browserStack>
<jenkins>0</jenkins>
<kobiton>0</kobiton>
<bs>null</bs>
<buildDirectory>${project.build.directory}</buildDirectory>
<appPath>k</appPath>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<groupId>GlucoMe</groupId>
<artifactId>AndroidAutomationTests</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- https://mvnrepository.com/artifact/io.appium/java-client -->
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20171018</version>
</dependency>
</dependencies>
</project>
Both Maven versions are 3.6.0, and it's exactly the same project and branch.
Any idea?
Also, all tests name ends with "Test" and so are the tests classes.
Thanks!

TestNG Results not displaying in Maven project for Selenium

Following are the code and pom.xml which I'm using
package com.org.test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class HelloWorld {
#Test
public void Hello() throws InterruptedException {
System.out.println("Logging into account");
System.setProperty("webdriver.gecko.driver", "D:\\Study materials\\Setups\\geckodriver.exe");
WebDriver driver=new FirefoxDriver();
driver.get("https://www.google.com");
driver.close();
}
}
And pom.xml is :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.org.test</groupId>
<artifactId>myTestProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>myTestProject</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven
defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
On running the project as Maven Test, I get a BUILD SUCCESS, but no result of the actual test is being displayed. Here is the result :
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.org.test:myTestProject >---------------------
[INFO] Building myTestProject 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) # myTestProject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Eclipse\myTestProject\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # myTestProject ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) # myTestProject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\Eclipse\myTestProject\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) # myTestProject ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) # myTestProject ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.984 s
[INFO] Finished at: 2018-12-30T21:33:57+05:30
[INFO] ------------------------------------------------------------------------
I have tried similar threads on Google,and tried updating my dependencies too. Any help would be appreciated.
Rename the class to include the word 'Test' to be picked up automatically by surefire plugin. Refer this https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html for more details.

UnsupportedClassVersionError Unsupported major.minor version 52.0 (unable to load class )

The same war file when deployed on my machine works fine. However on ubuntu 14. and jdk 1.8 on remote server, I keep getting an exception when I deploy it to tomcat using maven.
I checked the jdk listed on the remote server:
root#li1242-163:~# sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1072 auto mode
1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
* 2 /usr/lib/jvm/java-8-oracle/jre/bin/java 1072 manual mode
This is the java version on the remote serveR:
root#li1242-163:~# java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
May 26, 2015 12:10:27 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet crudservlet
java.lang.UnsupportedClassVersionError: crudapproot/EntityResource : Unsupported major.minor version 52.0 (unable to load class crudapproot.EntityResource)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2948)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1208)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at org.glassfish.jersey.internal.util.ReflectionHelper$7.run(ReflectionHelper.java:402)
at org.glassfish.jersey.internal.util.ReflectionHelper$7.run(ReflectionHelper.java:397)
at java.security.AccessController.doPrivileged(Native Method)
at org.glassfish.jersey.server.internal.scanning.AnnotationAcceptingListener$AnnotatedClassVisitor.getClassForName(AnnotationAcceptingListener.java:262)
at org.glassfish.jersey.server.internal.scanning.AnnotationAcceptingListener$AnnotatedClassVisitor.visitEnd(AnnotationAcceptingListener.java:224)
at jersey.repackaged.org.objectweb.asm.ClassReader.accept(ClassReader.java:697)
at jersey.repackaged.org.objectweb.asm.ClassReader.accept(ClassReader.java:506)
at org.glassfish.jersey.server.internal.scanning.AnnotationAcceptingListener.process(AnnotationAcceptingListener.java:170)
at org.glassfish.jersey.server.ResourceConfig.scanClasses(ResourceConfig.java:899)
at org.glassfish.jersey.server.ResourceConfig._getClasses(ResourceConfig.java:856)
at org.glassfish.jersey.server.ResourceConfig.getClasses(ResourceConfig.java:762)
at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1190)
at org.glassfish.jersey.server.ResourceConfig$RuntimeConfig.<init>(ResourceConfig.java:1162)
at org.glassfish.jersey.server.ResourceConfig.createRuntimeConfig(ResourceConfig.java:1158)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:322)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:338)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:171)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:363)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1279)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1192)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:864)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
I am deploying a webapplication using maven to a remote server, the pom file is configured as follows:
<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>OrbithubWeb</groupId>
<artifactId>OrbithubWeb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<!-- customize the catalina_home for remote deployment
for tomcat7, the remotedeployserverurl is http://localhost:8080/manager/text
and for tomcat6 http://localhost:8080/manager/html
-->
<properties>
<java-version>1.7</java-version>
<org.springframework-version>4.0.3.RELEASE</org.springframework-version>
<warfilename>${project.groupId}</warfilename>
<!-- change the url to : http://45.79.143.163:8080/manager/text -->
<remotedeployserverurl>http://localhost:8080/manager/text</remotedeployserverurl>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework-version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- spring framework just added ends here -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<!-- jersey dependencies ends -->
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.3.1</version>
</dependency>
<!-- jersey dependency ends -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<!-- used for httpclient library -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.35</version>
</dependency>
<!-- adding for log4j dependency for logging -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<!-- Added 25 May: added the dependecy for Jax-RS 2.0 jersey core Servlet 3.x implementation -->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.17</version>
</dependency>
<!-- Added 25 May: for jersey-client implementation -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.17</version>
</dependency>
<!-- dependency resolved for jax-rs -->
<!-- Uses this dependency to read from build.properties file. The artifact id # properties-maven-plugin -->
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- changes the default location of war deployment -->
<!-- commented it since we are directly deploying war to the ${catalina_home}/webapps -->
<!-- <warName>${warfilename}</warName> -->
<!-- <outputDirectory>${catalina_home}/webapps</outputDirectory> -->
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- added to deploy maven build to remote tomcat, update = true :: redeploy's the war files on update -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>${remotedeployserverurl}</url>
<server>tomcat7</server>
<path>/${project.groupId}</path>
<!-- configuring the tomcat7 to update itself while deploying -->
<update>true</update>
<!-- added this on 25 April -->
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<!-- Associate the read-project-properties goal with the initialize phase, to read the properties file. -->
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<!-- taking the build.properties from the relative location of the pom file -->
<file>build.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
A snapshot of the deployment for war file on tomcat is :
root#li1242-163:~/OrbitHub-Java-Rest-API# mvn clean tomcat7:deploy
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building OrbithubWeb 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # OrbithubWeb ---
[INFO] Deleting /root/OrbitHub-Java-Rest-API/target
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.2:deploy (default-cli) # OrbithubWeb >>>
[INFO]
[INFO] --- properties-maven-plugin:1.0-alpha-2:read-project-properties (default) # OrbithubWeb ---
[INFO]
[INFO] --- maven-resources-plugin:2.3:resources (default-resources) # OrbithubWeb ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # OrbithubWeb ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 19 source files to /root/OrbitHub-Java-Rest-API/target/classes
[WARNING] /root/OrbitHub-Java-Rest-API/src/test/TestCallToWebapp.java: /root/OrbitHub-Java-Rest-API/src/test/TestCallToWebapp.java uses or overrides a deprecated API.
[WARNING] /root/OrbitHub-Java-Rest-API/src/test/TestCallToWebapp.java: Recompile with -Xlint:deprecation for details.
[WARNING] /root/OrbitHub-Java-Rest-API/src/asyncrequesthandlr/ControllableExecutors.java: /root/OrbitHub-Java-Rest-API/src/asyncrequesthandlr/ControllableExecutors.java uses unchecked or unsafe operations.
[WARNING] /root/OrbitHub-Java-Rest-API/src/asyncrequesthandlr/ControllableExecutors.java: Recompile with -Xlint:unchecked for details.
[INFO]
[INFO] --- maven-resources-plugin:2.3:testResources (default-testResources) # OrbithubWeb ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/OrbitHub-Java-Rest-API/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # OrbithubWeb ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) # OrbithubWeb ---
[INFO] No tests to run.
[INFO] Surefire report directory: /root/OrbitHub-Java-Rest-API/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-war-plugin:2.4:war (default-war) # OrbithubWeb ---
[INFO] Packaging webapp
[INFO] Assembling webapp [OrbithubWeb] in [/root/OrbitHub-Java-Rest-API/target/OrbithubWeb-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/root/OrbitHub-Java-Rest-API/WebContent]
[INFO] Webapp assembled in [202 msecs]
[INFO] Building war: /root/OrbitHub-Java-Rest-API/target/OrbithubWeb-0.0.1-SNAPSHOT.war
[INFO]
[INFO] <<< tomcat7-maven-plugin:2.2:deploy (default-cli) # OrbithubWeb <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.2:deploy (default-cli) # OrbithubWeb ---
[INFO] Deploying war to http://45.79.143.163:8080/OrbithubWeb
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.
Uploading: http://45.79.143.163:8080/manager/text/deploy?path=%2FOrbithubWeb&update=true
Uploaded: http://45.79.143.163:8080/manager/text/deploy?path=%2FOrbithubWeb&update=true (12330 KB at 20279.0 KB/sec)
[INFO] tomcatManager status code:200, ReasonPhrase:OK
[INFO] OK - Deployed application at context path /OrbithubWeb
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.924s
[INFO] Finished at: Tue May 26 00:00:28 UTC 2015
[INFO] Final Memory: 22M/54M
[INFO] ------------------------------------------------------------------------
This worked for me , I found a tutorial for the same here: https://askubuntu.com/questions/121654/how-to-set-default-java-version
:
Made changes to the JAVA_HOME variable : vi /etc/default/tomcat7
java8 was found here:
/usr/lib/jvm/java-8-oracle/bin/
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java-8-oracle/bin/javac" 1
sudo update-alternatives --config javac
To check the jvm that the tomcat is using :
ps -ef | grep tomcat
Also, curl http://admin:admin#localhost:8080/manager/text/serverinfo

Resources