JaCoCo Check not failing AEM Multi-module Project build below Threshold Coverage - aem

I am trying to configure jaCoCo check in my multi-module AEM 6.4 project.
I have written Test Classes for JUnit5 Extensions which compile well.
I can see report being published to my Sonar Server as well, coverage being 45.9% - Failed.
When I deploy Maven project via maven Run Configurations: mvn clean verify, it always shows all modules deployed with SUCCESS.
Root POM Variables declaration:
<properties>
<!-- Sonar -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.reportPaths>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPaths>
<sonar.language>java</sonar.language>
<!-- JaCoCo -->
<jacoco.percentage.instruction>0.98</jacoco.percentage.instruction>
</properties>
Root POM Maven Surefire, Fail-safe and JaCoCo Plugins Configuration
<build>
<plugins>
<!-- Maven Surefire Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<argLine>${jacocoArgLine} -Xmx256m</argLine>
</configuration>
</plugin>
<!-- Maven Failsafe Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<!-- JaCoCo Plugin for Code Coverage -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<configuration>
<destFile>${sonar.jacoco.reportPaths}</destFile
<dataFile>${sonar.jacoco.reportPaths}</dataFile>
<append>true</append>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>jacocoArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>check</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<dataFile>${sonar.jacoco.reportPaths}</dataFile>
<rules>
<rule implementation="org.jacoco.maven.RuleConfiguration">
<element>PACKAGE</element>
<limits>
<limit implementation="org.jacoco.report.check.Limit">
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Please note that I did not configure any plugin on core or it.tests module POM files.
Output from logs - Core Bundle:
[INFO] Building Test - Core 0.0.1-SNAPSHOT [2/5]
[INFO] -------------------------------[ bundle ]-------------------------------
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) # test.core ---
[INFO] Deleting C:\Apps\Workspace\git\test-bitbucket\core\target
[INFO]
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-maven) # test.core ---
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.3:prepare-agent (prepare-agent) # test.core ---
[INFO] jacocoArgLine set to -javaagent:C:\\Users\\Public\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.8.3\\org.jacoco.agent-0.8.3-runtime.jar=destfile=C:\\Apps\\Workspace\\git\\test-bitbucket\\core\\..\\target\\jacoco.exec,append=true
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) # test.core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Apps\Workspace\git\test-bitbucket\core\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # test.core ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 20 source files to C:\Apps\Workspace\git\test-bitbucket\core\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) # test.core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Apps\Workspace\git\test-bitbucket\core\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) # test.core ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.22.0:test (default-test) # test.core ---
[INFO] No tests to run.
[INFO]
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.3:check (check) # marketing-garage.core ---
[INFO] Skipping JaCoCo execution due to missing execution data file:C:\Apps\Workspace\git\test-bitbucket\core\..\target\jacoco.exec
Output from logs - Tests Bundle:
[INFO] Building Test - Integration 0.0.1-SNAPSHOT [5/5]
[INFO] -------------------------------[ bundle ]-------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) # test.it.tests ---
[INFO] Deleting C:\Apps\Workspace\git\test-bitbucket\it.tests\target
[INFO]
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-maven) # test.it.tests ---
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.3:prepare-agent (prepare-agent) # test.it.tests ---
[INFO] jacocoArgLine set to -javaagent:C:\\Users\\Public\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.8.3\\org.jacoco.agent-0.8.3-runtime.jar=destfile=C:\\Apps\\Workspace\\git\\test-bitbucket\\it.tests\\..\\target\\jacoco.exec,append=true
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) # test.it.tests ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Apps\Workspace\git\test-bitbucket\it.tests\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # test.it.tests ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) # test.it.tests ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) # test.it.tests ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 8 source files to C:\Apps\Workspace\git\test-bitbucket\it.tests\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.0:test (default-test) # test.it.tests ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.test.it.tests.LogoutServletTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.603 s - in com.test.it.tests.LogoutServletTest
[INFO] Running com.test.it.tests.SocialFeedsServiceTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.731 s - in com.test.it.tests.SocialFeedsServiceTest
[INFO]
[INFO] Results:
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-bundle-plugin:4.1.0:bundle (default-bundle) # test.it.tests -
[WARNING] Bundle com.test:test.it.tests:bundle:0.0.1-SNAPSHOT : The JAR is empty: The instructions for the JAR named com.test.it.tests did not cause any content to be included, this is likely wrong
[INFO]
[INFO] --- jacoco-maven-plugin:0.8.3:check (check) # test.it.tests ---
[INFO] Loading execution data file C:\Apps\Workspace\git\test-bitbucket\it.tests\..\target\jacoco.exec
[INFO] Analyzed bundle 'test.it.tests' with 0 classes
[INFO] All coverage checks have been met.
[INFO] -----------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] test 0.0.1-SNAPSHOT ................ SUCCESS [ 2.091 s]
[INFO] Test - Core ........................ SUCCESS [ 15.467 s]
[INFO] Test - UI apps ..................... SUCCESS [ 55.583 s]
[INFO] Test - UI content .................. SUCCESS [ 47.815 s]
[INFO] Test - Integration 0.0.1-SNAPSHOT SUCCESS [ 36.362 s]
[INFO] -----------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] -----------------------------------------------------------------------
[INFO] Total time: 02:41 min
[INFO] Finished at: 2019-03-25T11:08:31+05:30
[INFO] -----------------------------------------------------------------------
I expected the build to fail if coverage is below 80% but this configuration is passing all builds from Maven Build perspective.

Related

Maven scala scoverage try to pull package for other module

I have a multimodule maven project with the following schema
root
- module-A
- module-B (depends on A)
- module-C1 (depends on B)
- module-C2 (depends on B)
...
- module-Cn (depends on B)
And it has the scoverage-maven-plugin configured like this.
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<aggregate>true</aggregate>
</configuration>
<executions>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
scoverage.plugin.version = 1.4.1
scala.version = 2.11.11
If I lunch a mvn clean package in local from the root project, it works as expected, but in the CI workflow (bamboo if its useful), modules A and B go great, but on C1 I get the following error:
14-May-2020 14:23:41 [INFO] >>> scoverage-maven-plugin:1.4.1:report (report) > [scoverage]test # C1 >>>
14-May-2020 14:23:41 [INFO]
14-May-2020 14:23:41 [INFO] --- scoverage-maven-plugin:1.4.1:pre-compile (report) # C1 ---
14-May-2020 14:23:41 [INFO] Downloading from nexus: https://fakenexusurl.com/repository/all/module-B/1.0.0-SNAPSHOT/maven-metadata.xml
14-May-2020 14:23:41 [INFO] Downloading from nexus: https://fakenexusurl.com/repository/all/module-B/1.0.0-SNAPSHOT/module-B-1.0.0-SNAPSHOT.jar
14-May-2020 14:23:41 [INFO] ------------------------------------------------------------------------
14-May-2020 14:23:41 [INFO] Reactor Summary:
14-May-2020 14:23:41 [INFO]
14-May-2020 14:23:41 [INFO] root .......................................... SUCCESS [ 3.610 s]
14-May-2020 14:23:41 [INFO] module-A ................................... SUCCESS [01:38 min]
14-May-2020 14:23:41 [INFO] modulde-B ............................. SUCCESS [01:30 min]
14-May-2020 14:23:41 [INFO] module-C1 ........................... FAILURE [01:37 min]
14-May-2020 14:23:41 [INFO] module-C2 ........................... SKIPPED
14-May-2020 14:23:41 [INFO] ------------------------------------------------------------------------
14-May-2020 14:23:41 [INFO] BUILD FAILURE
14-May-2020 14:23:41 [INFO] ------------------------------------------------------------------------
14-May-2020 14:23:41 [INFO] Total time: 04:50 min
14-May-2020 14:23:41 [INFO] Finished at: 2020-05-14T14:23:41Z
14-May-2020 14:23:42 [INFO] Final Memory: 85M/1627M
14-May-2020 14:23:42 [INFO] ------------------------------------------------------------------------
14-May-2020 14:23:42 [ERROR] Failed to execute goal on project module-C1: Could not resolve dependencies for project group:module-C1:jar:1.0.0-SNAPSHOT: Could not find artifact group:module-B:jar:1.0.0-SNAPSHOT in nexus (https://fakenexusurl.com/repository/all/) -> [Help 1]
I see that it's trying to download module B from the nexus of the company, and of course, it's not there because we didn't publish this snapshot. But I don't understand why it's trying to download dependencies that should look in another module of the same project. And why it doesn't do the same for B that depends on A, if the file are equal except the module name and the dependencies.
All the dependencies used are declared in the root dependencyManagment, and the plugins in the pluginManagment
The CI workflow is a black box for us, we can't know if they are using any extra profiles. The only thing we know is that the launch mvn clean package command.
The flow of scoverage creates a fork of the maven flow, and reruns all until testing. In this fork is not well managed the dependencies between modules, so the only way to execute it correctly from a clean execution is with the command:
mvn clean install scoverage:report
Change install to package, deploy, or any element that needs the report. This will force maven to execute the scoverage:report at the end of each module, preventing the unwanted behaviour.
Foud the information in this thread.

JDK9+ - The type org.springframework.beans.factory.annotation.Autowire cannot be resolved. It is indirectly referenced from required .class files

I am trying to run a very simple hello world in order to learn WebFlux (https://dzone.com/articles/spring-webflux-getting-started).
I can compile the project successfully but I am getting the error mentioned in the topic either in Eclipse and also when mvn spring-boot:run
From Eclipse Problems screen:
Description Resource Path Location Type
The project was not built since its build path is incomplete. Cannot find the class file for org.springframework.beans.factory.annotation.Autowire. Fix the build path then try building this project myspringwebfluxplanet Unknown Java Problem
The type org.springframework.beans.factory.annotation.Autowire cannot be resolved. It is indirectly referenced from required .class files ExampleRouter.java /myspringwebfluxplanet/src/main/java/com/mydeveloperplanet/myspringwebfluxplanet/examples line 1 Java Problem
In case it is relevant I have JDK11 installed and the project depends on JDK9.
I googling around and many solutions for similar issue is related to build path. Well I assume that if it was the case, I couldn't build and compile it. I mean I didn't get any exception when cleaning the tree (mvn clean dependency:tree) and then
# mvn clean compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------< com.mydeveloperplanet:myspringwebfluxplanet >-------------
[INFO] Building myspringwebfluxplanet 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) # myspringwebfluxplanet ---
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) # myspringwebfluxplanet ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\_d\samples\myspringwebfluxplanet\src\main\resources
[INFO] skip non existing resourceDirectory C:\_d\samples\myspringwebfluxplanet\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) # myspringwebfluxplanet ---
[INFO] Required filename-based automodules detected. Please don't publish this project to a public artifact repository!
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to C:\_d\samples\myspringwebfluxplanet\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.243 s
[INFO] Finished at: 2019-05-14T13:20:39-03:00
[INFO] ------------------------------------------------------------------------
I am pretty sure I am missing some basic concept around Modularity, WebFlux + Reactor.
Pom
<?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.mydeveloperplanet</groupId>
<artifactId>myspringwebfluxplanet</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.version>3.3.9</maven.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<jdk.version>1.9</jdk.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
module-info.java
module com.mydeveloperplanet.myspringwebfluxplanet {
requires reactor.core;
requires spring.web;
requires spring.context;
requires spring.webflux;
requires spring.boot;
requires spring.boot.autoconfigure;
}
*** Edited
If I try compile via command line I successfully can run while I keep getting the error on Eclipse. I found Java 9: java.lang.ClassNotFoundException: java.sql.SQLException in Spring Boot application suggesting to add "--add-modules java.sql" but it doesn't change anything in my case. I found alson someone fixing similar issue with InteliJ Getting noclassfoundexception : java.sql.SQLException in intellij idea for jdk 11 (Please don't compare neither point me to use InteliJ since there is nothing to do with my questiton)
From Command Line (Success):
# mvn clean compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------< com.mydeveloperplanet:myspringwebfluxplanet >-------------
[INFO] Building myspringwebfluxplanet 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.0.0:clean (default-clean) # myspringwebfluxplanet ---
[INFO] Deleting C:\_d\samples\myspringwebfluxplanet\target
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) # myspringwebfluxplanet ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\_d\samples\myspringwebfluxplanet\src\main\resources
[INFO] skip non existing resourceDirectory C:\_d\samples\myspringwebfluxplanet\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # myspringwebfluxplanet ---
[INFO] Required filename-based automodules detected. Please don't publish this project to a public artifact repository!
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to C:\_d\samples\myspringwebfluxplanet\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.470 s
[INFO] Finished at: 2019-05-15T11:04:28-03:00
[INFO] ------------------------------------------------------------------------
myuser#mycomputer C:\_d\samples\myspringwebfluxplanet
# mvn spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------< com.mydeveloperplanet:myspringwebfluxplanet >-------------
[INFO] Building myspringwebfluxplanet 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.0.0.RELEASE:run (default-cli) > test-compile # myspringwebfluxplanet >>>
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) # myspringwebfluxplanet ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\_d\samples\myspringwebfluxplanet\src\main\resources
[INFO] skip non existing resourceDirectory C:\_d\samples\myspringwebfluxplanet\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # myspringwebfluxplanet ---
[INFO] Required filename-based automodules detected. Please don't publish this project to a public artifact repository!
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) # myspringwebfluxplanet ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\_d\samples\myspringwebfluxplanet\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) # myspringwebfluxplanet ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\_d\samples\myspringwebfluxplanet\target\test-classes
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.0.0.RELEASE:run (default-cli) < test-compile # myspringwebfluxplanet <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:2.0.0.RELEASE:run (default-cli) # myspringwebfluxplanet ---
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.0.RELEASE)
2019-05-15 11:04:45.211 INFO 8524 --- [ main] c.m.myspringwebfluxplanet.Application : Starting Application on DESKTOP-AKCNE7F with PID 8524 (C:\_d\samples\myspringwebfluxplanet\target\classes started by resource in C:\_d\samples\myspringwebfluxplanet)
2019-05-15 11:04:45.223 INFO 8524 --- [ main] c.m.myspringwebfluxplanet.Application : No active profile set, falling back to default profiles: default
2019-05-15 11:04:45.324 INFO 8524 --- [ main] onfigReactiveWebServerApplicationContext : Refreshing org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext#5a68e0f8: startup date [Wed May 15 11:04:45 BRT 2019]; root of context hierarchy
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/Users/resource/.m2/repository/org/springframework/spring-core/5.0.4.RELEASE/spring-core-5.0.4.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2019-05-15 11:04:47.927 INFO 8524 --- [ main] o.s.w.r.f.s.s.RouterFunctionMapping : Mapped ((GET && /example) && Accept: [text/plain]) -> com.mydeveloperplanet.myspringwebfluxplanet.examples.ExampleRouter$$Lambda$442/0x0000000100691840#768f81f
2019-05-15 11:04:48.420 INFO 8524 --- [ main] o.s.w.r.f.s.s.RouterFunctionMapping : Mapped ((GET && /exampleFurther1) && Accept: [text/plain]) -> com.mydeveloperplanet.myspringwebfluxplanet.examples.ExampleRouter$$Lambda$444/0x00000001006ba040#26ddf6b5
((GET && /exampleFurther2) && Accept: [text/plain]) -> com.mydeveloperplanet.myspringwebfluxplanet.examples.ExampleRouter$$Lambda$445/0x00000001006ba440#46a9ce9c
((GET && /exampleFurther3) && Accept: [text/plain]) -> com.mydeveloperplanet.myspringwebfluxplanet.examples.ExampleRouter$$Lambda$446/0x00000001006ba840#bb74974
2019-05-15 11:04:48.437 INFO 8524 --- [ main] o.s.w.r.f.s.s.RouterFunctionMapping : Mapped ((GET && /hello) && Accept: [text/plain]) -> com.mydeveloperplanet.myspringwebfluxplanet.greeting.GreetingRouter$$Lambda$447/0x00000001006bac40#4b5ff01d
2019-05-15 11:04:48.473 INFO 8524 --- [ main] o.s.w.r.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.reactive.resource.ResourceWebHandler]
2019-05-15 11:04:48.476 INFO 8524 --- [ main] o.s.w.r.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.reactive.resource.ResourceWebHandler]
2019-05-15 11:04:48.694 INFO 8524 --- [ main] o.s.w.r.r.m.a.ControllerMethodResolver : Looking for #ControllerAdvice: org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext#5a68e0f8: startup date [Wed May 15 11:04:45 BRT 2019]; root of context hierarchy
2019-05-15 11:04:51.618 INFO 8524 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2019-05-15 11:04:52.688 INFO 8524 --- [ctor-http-nio-1] r.ipc.netty.tcp.BlockingNettyContext : Started HttpServer on /0:0:0:0:0:0:0:0:8080
2019-05-15 11:04:52.689 INFO 8524 --- [ main] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port(s): 8080
2019-05-15 11:04:52.696 INFO 8524 --- [ main] c.m.myspringwebfluxplanet.Application : Started Application in 8.217 seconds (JVM running for 18.277)
>> result = Hello, Spring!
2019-05-15 11:05:12.016 WARN 8524 --- [ctor-http-nio-4] .a.w.r.e.DefaultErrorWebExceptionHandler : Failed to handle request [GET http://localhost:8080/favicon.ico]: Response status 404
From Eclipse
and if I ignore the error that is in the topic of my question I get
Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationContextInitializer : org.springframework.boot.context.ConfigurationWarningsApplicationContextInitializer
at spring.boot#2.0.0.RELEASE/org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:441)
at spring.boot#2.0.0.RELEASE/org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:420)
at spring.boot#2.0.0.RELEASE/org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:411)
at spring.boot#2.0.0.RELEASE/org.springframework.boot.SpringApplication.(SpringApplication.java:266)
at spring.boot#2.0.0.RELEASE/org.springframework.boot.SpringApplication.(SpringApplication.java:247)
at spring.boot#2.0.0.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
at spring.boot#2.0.0.RELEASE/org.springframework.boot.SpringApplication.run(SpringApplication.java:1234)
at com.mydeveloperplanet.myspringwebfluxplanet/com.mydeveloperplanet.myspringwebfluxplanet.Application.main(Application.java:11)
Caused by: java.lang.NoClassDefFoundError: java/sql/SQLException
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:168)
at spring.boot#2.0.0.RELEASE/org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:437)
... 7 more
Caused by: java.lang.ClassNotFoundException: java.sql.SQLException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 9 more
*** edited
I edited my pom.xml adding --add-modules
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<compilerargs>
<arg>--add-modules</arg>
<arg>java.sql</arg>
</compilerargs>
</configuration>
</plugin>
</plugins>
</pluginManagement>

IntelliJ No Source to compile with Maven Error

I have created a maven project in intellij and added scala framework support
This project name is sparkexamples and I added the necessary dependencies
Below is the project directory structure .
S:\surender\intellij_1\sparkexamples
S:\surender\intellij_1\sparkexamples\src\main\scala\com\test\spark\examples\DemoMain.scala
S:\surender\intellij_1\sparkexamples\pom.xml
I went inside S:\surender\intellij_1\sparkexamples from command prompt and started running the below mvn commands
mvn clean compile
mvn package
After running mvn package I could see in cons
S:\surender\intellij_1\sparkexamples>mvn clean compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building spark-examples 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # spark-examples ---
[INFO] Deleting S:\surender\intellij_1\sparkexamples\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # spark-exam
ples ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # spark- examples
---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.950 s
[INFO] Finished at: 2017-03-28T10:46:18+01:00
[INFO] Final Memory: 13M/224M
[INFO] ------------------------------------------------------------------------
S:\surender\intellij_1\sparkexamples>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building spark-examples 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # spark-exam
ples ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # spark-examples
---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # sp
ark-examples ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory S:\surender\intellij_1\sparkexamples\
src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # spark-e
xamples ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # spark- examples ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # spark-examples ---
[INFO] Building jar: S:\surender\intellij_1\sparkexamples\target\spark-examples-
1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.651 s
[INFO] Finished at: 2017-03-28T10:47:09+01:00
[INFO] Final Memory: 15M/225M
[INFO] ------------------------------------------------------------------------
S:\surender\intellij_1\sparkexamples>ole that **No Sources to compile**
Could Someone help me to resolve this issue?
The Maven compiler is "incremental" by default. (That means that just the compile goal is "incremental", Maven still makes you go through the whole lifecycle, by default.)
When you first did:
mvn clean compile
Your sources got compiled. (Lifecycles: you ran up to and including the compile lifecycle phase.)
When you then did:
mvn package
The compiler was again invoked, and observed that it had already done its work previously. (Lifecycles: package is a lifecycle phase extending the compile phase.)
This is what seems to happen. Disclaimer: you only included output for mvn package. If your mvn compile also tells you that there's nothing to compile, something else going on, and you'd probably want to rephrase your question (or post a new one).
Also, if this lifecycle thing is messing you up, one more hint: compile is a lifecycle phase, and many people confuse it with doing a particular "task", which it is not. From mvn -h:
usage: mvn [options] [<goal(s)>] [<phase(s)>]
Again, compile is a phase, if you wanted to do a goal ("task"), in case of doing just compilation that'd be: compiler:compile (name_of_the_plugin:name_of_the_goal).

Compile Scala incrementally in Maven project

I'd like to compile Scala incrementally in a Maven project.
Currently, Scala compiles even if nothing changes.
I've tried scala-maven-plugin, but it doesn't seem to work incrementally at all.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0">
<artifactId>example</artifactId>
<build>
<plugins>
<plugin>
<artifactId>scala-maven-plugin</artifactId>
<configuration>
<recompileMode>incremental</recompileMode>
<scalaVersion>2.11.7</scalaVersion>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<groupId>net.alchim31.maven</groupId>
<version>3.2.2</version>
</plugin>
</plugins>
</build>
<groupId>example</groupId>
<modelVersion>4.0.0</modelVersion>
<name>example</name>
<version>0.0-SNAPSHOT</version>
</project>
src/main/scala/example/Foo.scala
package example
class Foo {
val foo = None
}
Maven version:
$ mvn --version
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T10:37:52-07:00)
Maven home: /usr/share/maven3
Java version: 1.8.0_45-internal, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-65-generic", arch: "amd64", family: "unix"
And then:
$ mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building example 0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/paul/dev/example/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # example ---
[INFO] No sources to compile
[INFO]
[INFO] --- scala-maven-plugin:3.2.2:compile (default) # example ---
[INFO] Using incremental compilation
[INFO] Compiling 1 Scala source to /home/paul/dev/example/target/classes...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.090 s
[INFO] Finished at: 2015-10-15T18:22:34-07:00
[INFO] Final Memory: 23M/412M
[INFO] ------------------------------------------------------------------------
$ mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building example 0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/paul/dev/stash-conditions-test/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # example ---
[INFO] No sources to compile
[INFO]
[INFO] --- scala-maven-plugin:3.2.2:compile (default) # example ---
[INFO] Using incremental compilation
[INFO] Compiling 1 Scala source to /home/paul/dev/stash-conditions-test/target/classes...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.661 s
[INFO] Finished at: 2015-10-15T18:22:39-07:00
[INFO] Final Memory: 23M/418M
[INFO] ------------------------------------------------------------------------
It compiles every time!
How can I get a Maven project that compiles Scala only when it has changed?
You should try: mvn scala:cc.
see the instruction here http://davidb.github.io/scala-maven-plugin/example_cc.html
Need pass all instead incremental
<configuration>
<recompileMode>all</recompileMode>
</configuration>

How to resolve missing context.xml during maven build?

I have a maven web app build using Eclipse, and have this command: install tomcat:deploy set in the goal. When I build the app, I hit this error:
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.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building web4 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # web4 ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/kokhoe/workspace/web4/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # web4 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) # web4 ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/kokhoe/workspace/web4/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # web4 ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) # web4 ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) # web4 ---
[INFO] Packaging webapp
[INFO] Assembling webapp [web4] in [/home/kokhoe/workspace/web4/target/web4-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/kokhoe/workspace/web4/src/main/webapp]
[INFO] Webapp assembled in [71 msecs]
[INFO] Building war: /home/kokhoe/workspace/web4/target/web4-0.0.1-SNAPSHOT.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) # web4 ---
[INFO] Installing /home/kokhoe/workspace/web4/target/web4-0.0.1-SNAPSHOT.war to /home/kokhoe/.m2/repository/org/huahsin/web4/0.0.1-SNAPSHOT/web4-0.0.1-SNAPSHOT.war
[INFO] Installing /home/kokhoe/workspace/web4/pom.xml to /home/kokhoe/.m2/repository/org/huahsin/web4/0.0.1-SNAPSHOT/web4-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] >>> tomcat-maven-plugin:1.1:deploy (default-cli) # web4 >>>
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # web4 ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/kokhoe/workspace/web4/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # web4 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) # web4 ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/kokhoe/workspace/web4/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) # web4 ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) # web4 ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) # web4 ---
[INFO] Packaging webapp
[INFO] Assembling webapp [web4] in [/home/kokhoe/workspace/web4/target/web4-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/kokhoe/workspace/web4/src/main/webapp]
[INFO] Webapp assembled in [14 msecs]
[INFO] Building war: /home/kokhoe/workspace/web4/target/web4-0.0.1-SNAPSHOT.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO]
[INFO] <<< tomcat-maven-plugin:1.1:deploy (default-cli) # web4 <<<
[INFO]
[INFO] --- tomcat-maven-plugin:1.1:deploy (default-cli) # web4 ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.938s
[INFO] Finished at: Mon Sep 17 12:16:34 MYT 2012
[INFO] Final Memory: 18M/215M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project web4: Cannot find context file: /home/kokhoe/workspace/web4/target/web4-0.0.1-SNAPSHOT/META-INF/context.xml -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
The error mention that context.xml is missing. May I know how this problem could be solve?
I have the problem solved by using this command in maven goal:
install tomcat:run