running app as jar gives fileNotFoundException - spring

Im attempting to run my spring app as a jar, but i get the below error
java.io.FileNotFoundException: class path resource [org/springframework/web/socket/config/annotation/AbstractWebSocketMessageBrokerConfigurer.class] cannot be opened because it does not exist
It runs fine from intelij(as in my main class can runs using the play button). I find the file under project structure --> Libraries and under external libraries (albeit depracted)
Ive tried to look into it, but everywhere (list of examples below) seem to talk about xml files instead of a class
Spring ClassPathResource - cannot be opened because it does not exist
Class path resource cannot be opened because it does not existHow to avoid "class path resource [...] cannot be opened because it does not exist" in a spring boot application?
java.io.FileNotFoundException: class path resource can't be opened
java.io.FileNotFoundException: class path resource cannot be opened because it does not exist
My gradle file:
plugins {
id 'org.springframework.boot' version '2.2.4.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'war'
id 'groovy'
// id 'java'
}
war {
enabled = true
}
jar {
manifest {
attributes 'Main-Class': 'co.za.ebucks.HandlingRewardsFormSubmission'
}
}
group = 'co.za.ebucks'
version = '1.0.0'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
ext {
seleniumVersion = '3.141.59'
}
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
test {
useTestNG()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-tomcat'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
// implementation 'org.springframework.session:spring-session-core'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-integration'
implementation 'org.springframework.boot:spring-boot-starter-websocket'
implementation 'org.springframework:spring-messaging'
implementation 'org.springframework.integration:spring-integration-file'
implementation group: 'org.webjars.bower', name: 'angular-ui-router', version: '0.2.8'
implementation group: 'org.webjars', name:'angularjs', version: '1.3.0-beta.11'
implementation group: 'org.webjars', name: 'bootstrap', version: '3.1.1-1'
// implementation 'org.webjars.bower:angular-ui-router'//, version: '1.0.20'
implementation 'commons-io:commons-io'//, version: '2.4'
implementation 'org.apache.commons:commons-dbcp2'//, version: '2.7.0'
implementation 'org.hibernate.validator:hibernate-validator'//, version: '6.1.2.Final'
// implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'//, version: '2.4.1'
implementation 'javax.servlet:javax.servlet-api'//, version: '4.0.1'
// compile group: 'org.apache.tomcat', name: 'tomcat-jni', version: '9.0.33'
implementation group: 'de.codecentric', name: 'spring-boot-admin-starter-client', version: '2.2.2'
implementation group: 'de.codecentric', name: 'spring-boot-admin-server', version: '2.2.2'
implementation group: 'org.testng', name: 'testng', version: '7.1.0'
implementation group: 'org.codehaus.groovy', name: 'groovy-all', version: '3.0.0'
implementation group: 'com.google.inject', name: 'guice', version: '4.2.2'
implementation group: 'com.google.guava', name: 'guava', version: '28.1-jre'
implementation group: 'cglib', name: 'cglib', version: '3.3.0'
implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.10'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'io.projectreactor:reactor-test'
implementation "org.seleniumhq.selenium:selenium-support:${seleniumVersion}"
implementation group: 'io.appium', name: 'java-client', version: '7.3.0'
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: "${seleniumVersion}"
implementation group: 'org.seleniumhq.selenium', name: 'selenium-server', version: "${seleniumVersion}"
implementation group: 'org.seleniumhq.selenium', name: 'selenium-chrome-driver', version: "${seleniumVersion}"
testImplementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.0'
testImplementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.13.0'
testImplementation group: 'org.testng', name: 'testng', version: '7.1.0'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
}
And what Im sure is the class in question:
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry
import org.springframework.web.socket.server.support.DefaultHandshakeHandler;
#Configuration
#EnableWebSocketMessageBroker
class WebSocketDefaultConfig extends AbstractWebSocketMessageBrokerConfigurer {
#Override
void configureMessageBroker(MessageBrokerRegistry config) {
// config.enableStompBrokerRelay("/topic/", "/queue/");
config.enableSimpleBroker("/topic/", "/queue/");
config.setApplicationDestinationPrefixes("/app");
}
#Override
void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/tailfilesep")
// .setAllowedOrigins("*")
// .setHandshakeHandler(new DefaultHandshakeHandler())
.withSockJS()
}
}
Kindly assist me, this has passed frustration. Why is that class not in the jar?

The only thing that worked was creating a new project - copy and pasted all the code, build files everything... lol and its fine.
Intelij corruption somewhere along the line

Related

Show Results/Outcomes Failed Asserts Junit, Cucumber on Console

I found this similar Question but is related to Eclipse, I'm using Visual Studio Code Version: 1.72.2 on macOS.
Here my build.gradle file
plugins {
id 'java'
}
group 'CursoUdemy'
version '1.0-SNAPSHOT'
sourceCompatibility = 13
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.9.1'
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.5.0'
implementation group: 'io.cucumber', name: 'cucumber-java', version: '7.8.1'
testImplementation group: 'io.cucumber', name: 'cucumber-junit', version: '7.8.1'
testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.3'
}
I found that is possible to share... but I would like only to see the local Outcomes in my console.
Is this related to version of some dependency? In that case... Which?
Some clue in order to show the results in my console?
https://code.visualstudio.com/docs/languages/java#_testing
https://www.tapqa.com/html-tables-cucumber-datatables/

Building app with spring-boot + Cassandra, getting "Unable to load class 'com.datastax.oss.driver.api.mapper.entity.naming.GetterStyle'"

Facing isssue while integration with datastax with cassandra
gradle file :
plugins {
id 'org.springframework.boot' version '2.3.12.RELEASE'
id 'io.spring.dependency-management' version '1.0.13.RELEASE'
id 'java'
id 'org.sonarqube' version '3.2.0'
}
group = 'in.demo'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
def javaDriverVersion ='4.14.1'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
implementation ('org.springframework.boot:spring-boot-starter')
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation('org.springframework.boot:spring-boot-starter-web') {
exclude module: 'spring-boot-starter-tomcat'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
}
implementation('org.springframework.boot:spring-boot-starter-jetty')
implementation('org.springframework.boot:spring-boot-starter-webflux')
runtimeOnly('org.springframework.boot:spring-boot-devtools')
// datastax driver
implementation group: 'com.datastax.oss', name: 'java-driver-core', version: javaDriverVersion
implementation group: 'com.datastax.oss', name: 'java-driver-query-builder', version: javaDriverVersion
//implementation group: 'com.datastax.oss', name: 'java-driver-mapper-runtime', version: javaDriverVersion
implementation group: 'com.datastax.oss', name: 'native-protocol', version: '1.5.0'
annotationProcessor group: 'com.datastax.oss', name: 'java-driver-mapper-processor', version: javaDriverVersion
//compileOnly group: 'com.datastax.oss', name: 'java-driver-mapper-processor', version: '4.14.1'
compileOnly group: 'com.datastax.oss', name: 'java-driver-mapper-runtime', version: javaDriverVersion
implementation 'org.mapstruct:mapstruct:1.3.1.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.3.1.Final'
}
tasks.named('test') {
useJUnitPlatform()
}
#Data
#AllArgsConstructor
#NoArgsConstructor
#Entity(defaultKeyspace = "quest_test")
public class TestTable {
private UUID id;
private String name;
}
import com.datastax.oss.driver.api.mapper.annotations.Dao;
import com.datastax.oss.driver.api.mapper.annotations.Select;
#Dao
public interface TestTableDao {
#Select
TestTable findById();
}
import com.datastax.oss.driver.api.mapper.annotations.DaoFactory;
import com.datastax.oss.driver.api.mapper.annotations.Mapper;
#Mapper
public interface TestTableMapper {
#DaoFactory
TestTableDao testTableDao();
}
getting error
Unable to load class 'com.datastax.oss.driver.api.mapper.entity.naming.GetterStyle'.
i tried to interaction with different project also but still not able to solve issue
. for testing part i added library mappstruct which is generation code on compile time
With drivers 4x+, you need to declare an annotation processor for the mappers code to be generated at build time.
Gradle file
dependencies {
annotationProcessor group: 'com.datastax.oss', name: 'java-driver-mapper-processor', version: javaDriverVersion
compile group: 'com.datastax.oss', name: 'java-driver-mapper-runtime', version: javaDriverVersion
}
Documentation
Here more code to work with Driver 4x
You might be interested in the full-fledged Spring PetClinic application running with your technical stack.

Upgrade from oracle-r2dbc version 0.4.0 to 1.0.0 is resulting in class cast exception while update

I was trying to upgrade R2DBC from 0.4.0 to 1.0.0.
while doing that I am getting error in update which was working fine in version 0.4.0.
Build.gradle that I am using
plugins {
id 'org.springframework.boot' version '2.7.2'
id 'io.spring.dependency-management' version '1.0.12.RELEASE'
id 'java'
}
group = '<group>'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
maven {
url "https://nexus/repository/maven-public/"
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
dependencies {
implementation ('org.springframework.boot:spring-boot-starter-actuator:2.7.4') {
exclude group: 'org.springframework.boot', module: 'spring-boot'
}
implementation 'org.springframework.boot:spring-boot:2.7.4'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.7.4'
implementation ('org.springframework.boot:spring-boot-starter-data-r2dbc:2.7.4') {
exclude group: 'io.r2dbc', module: 'r2dbc-spi'
exclude group: 'io.r2dbc', module: 'r2dbc-pool'
exclude group: 'org.springframework.data', module: 'spring-data-r2dbc'
exclude group: 'io.projectreactor', module: 'reactor-core'
exclude group: 'org.springframework.boot', module: 'spring-boot-starter'
}
implementation 'io.r2dbc:r2dbc-spi:1.0.0.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter:2.7.4'
implementation ('io.r2dbc:r2dbc-pool:1.0.0.RC1') {
exclude group: 'io.projectreactor', module: 'reactor-core'
}
implementation ('org.springframework.data:spring-data-r2dbc:1.5.3') {
exclude group: 'org.springframework', module: 'spring-r2dbc'
exclude group: 'io.r2dbc', module: 'r2dbc-spi'
exclude group: 'io.projectreactor', module: 'reactor-core'
exclude group: 'org.springframework.data', module: 'spring-data-commons'
exclude group: 'org.springframework.data', module: 'spring-data-relational'
exclude group: 'org.springframework', module: 'spring-tx'
exclude group: 'org.springframework', module: 'spring-context'
exclude group: 'org.springframework', module: 'spring-beans'
exclude group: 'org.springframework', module: 'spring-core'
}
implementation 'org.springframework.data:spring-data-commons:2.7.3'
implementation 'org.springframework.data:spring-data-relational:2.4.3'
implementation 'org.springframework:spring-tx:5.3.23'
implementation 'org.springframework:spring-context:5.3.23'
implementation 'org.springframework:spring-beans:5.3.23'
implementation 'org.springframework:spring-core:5.3.23'
implementation ('org.springframework:spring-r2dbc:5.3.23') {
exclude group: 'io.r2dbc', module: 'r2dbc-spi'
exclude group: 'io.projectreactor', module: 'reactor-core'
}
implementation 'io.projectreactor:reactor-core:3.4.23'
implementation ('com.oracle.database.r2dbc:oracle-r2dbc:1.0.0') {
exclude group: 'com.oracle.database.jdbc', module: 'ojdbc11'
exclude group: 'io.projectreactor', module: 'reactor-core'
}
implementation ('org.springframework.boot:spring-boot-starter-webflux') {
exclude group: 'io.projectreactor', module: 'reactor-core'
exclude group: 'org.springframework.boot', module: 'spring-boot-starter'
}
implementation files('./lib/eagle_commons-0.0.1-SNAPSHOT-plain.jar')
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
implementation ('sg.com.gic:crypto-lib:1.0.5') {
exclude group: 'slf4j', module: 'slf4j-api'
exclude group: 'ch.qos.logback', module: 'logback-core'
exclude group: 'ch.qos.logback', module: 'logback-classic'
}
implementation group: 'com.oracle.database.jdbc', name: 'ojdbc11', version: '21.7.0.0'
implementation group: 'org.springdoc', name: 'springdoc-openapi-webflux-ui', version: '1.6.11'
implementation group: 'org.modelmapper', name: 'modelmapper', version: '3.1.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
}
tasks.named('test') {
useJUnitPlatform()
}
Below is the SQL Update Query from R2dbcRepository Repository:
#Modifying
#Query(value = "UPDATE <Table_name> SET PARAM_VALUE=:paramValue WHERE BATCH_ID=:batchId and PARAM_NAME=:paramName")
Mono<Integer> updateODADateParam(String paramValue, String batchId, String paramName);
Error Log:
2022-10-05 09:47:37,080 DEBUG [ForkJoinPool.commonPool-worker-3] org.springframework.r2dbc.core.DefaultDatabaseClient$DefaultGenericExecuteSpec: Executing SQL statement [UPDATE <table_name> SET PARAM_VALUE=:P0_paramValue WHERE BATCH_ID=:P1_batchId and PARAM_NAME=:P2_paramName]
2022-10-05 09:47:37,121 ERROR [ForkJoinPool.commonPool-worker-7] com.gic.eagle.txnHld.handler.RESIBatchDateHandler: Error [class java.lang.Long cannot be cast to class java.lang.Integer (java.lang.Long and java.lang.Integer are in module java.base of loader 'bootstrap')]
java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.Integer (java.lang.Long and java.lang.Integer are in module java.base of loader 'bootstrap')
at java.base/java.util.stream.Collectors.lambda$summingInt$19(Collectors.java:673)
at reactor.core.publisher.MonoStreamCollector$StreamCollectorSubscriber.onNext(MonoStreamCollector.java:132)
at reactor.core.publisher.FluxFlatMap$FlatMapMain.tryEmit(FluxFlatMap.java:543)
at reactor.core.publisher.FluxFlatMap$FlatMapInner.onNext(FluxFlatMap.java:984)
at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:200)
at reactor.core.publisher.FluxConcatArray$ConcatArrayDelayErrorSubscriber.onNext(FluxConcatArray.java:364)
at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.onNext(FluxFilterFuseable.java:118)
at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:299)
at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2398)
at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.request(FluxMapFuseable.java:360)
at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.request(FluxFilterFuseable.java:191)
at reactor.core.publisher.FluxConcatArray$ConcatArrayDelayErrorSubscriber.request(FluxConcatArray.java:461)
at reactor.core.publisher.FluxPeek$PeekSubscriber.request(FluxPeek.java:138)
at reactor.core.publisher.FluxFlatMap$FlatMapInner.onSubscribe(FluxFlatMap.java:964)
at reactor.core.publisher.FluxPeek$PeekSubscriber.onSubscribe(FluxPeek.java:171)
at reactor.core.publisher.FluxConcatArray$ConcatArrayDelayErrorSubscriber.onSubscribe(FluxConcatArray.java:350)
at reactor.core.publisher.FluxFilterFuseable$FilterFuseableSubscriber.onSubscribe(FluxFilterFuseable.java:87)
at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onSubscribe(FluxMapFuseable.java:265)
at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55)
at reactor.core.publisher.Flux.subscribe(Flux.java:8466)
at reactor.core.publisher.FluxConcatArray$ConcatArrayDelayErrorSubscriber.onComplete(FluxConcatArray.java:443)
at reactor.core.publisher.FluxConcatArray.subscribe(FluxConcatArray.java:73)
at reactor.core.publisher.Flux.subscribe(Flux.java:8466)
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:426)
at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:539)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:122)
at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onNext(MonoFlatMapMany.java:250)
at reactor.core.publisher.FluxUsingWhen$UsingWhenSubscriber.onNext(FluxUsingWhen.java:345)
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)
at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:200)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:122)
at reactor.core.publisher.FluxConcatArray$ConcatArraySubscriber.onNext(FluxConcatArray.java:201)
at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onNext(MonoFlatMapMany.java:250)
at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2398)
at reactor.core.publisher.MonoFlatMapMany$FlatMapManyMain.onSubscribeInner(MonoFlatMapMany.java:150)
at reactor.core.publisher.MonoFlatMapMany$FlatMapManyMain.onNext(MonoFlatMapMany.java:189)
at reactor.core.publisher.MonoCreate$DefaultMonoSink.success(MonoCreate.java:172)
at oracle.r2dbc.impl.AsyncLock.lambda$get$2(AsyncLock.java:167)
at oracle.r2dbc.impl.AsyncLock.unlock(AsyncLock.java:125)
at oracle.r2dbc.impl.AsyncLock$UsingConnectionSubscriber.terminate(AsyncLock.java:516)
at oracle.r2dbc.impl.AsyncLock$UsingConnectionSubscriber.onComplete(AsyncLock.java:502)
at reactor.core.publisher.StrictSubscriber.onComplete(StrictSubscriber.java:123)
at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onComplete(Operators.java:2058)
at org.reactivestreams.FlowAdapters$FlowToReactiveSubscriber.onComplete(FlowAdapters.java:221)
at oracle.jdbc.internal.CompletionStageUtil$IteratorSubscription.emitComplete(CompletionStageUtil.java:804)
at oracle.jdbc.internal.CompletionStageUtil$IteratorSubscription.emitItems(CompletionStageUtil.java:751)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Originally raised the issue here:
https://github.com/oracle/oracle-r2dbc/issues/97
Got the information from Oracle team that the issue could be same as
https://github.com/oracle/oracle-r2dbc/issues/89
If anybody can point out what is wrong with dependency version, would be helpful.
Thanks
Don't mess around with overrides and manually managing your dependencies. That will only lead to issues. Also using Spring Data R2DBC is tied to specific versions of R2DBC so you cannot simply upgrade, you have to wait for a version that supports that specific version.
If you want to override versions follow the documented approach instead of all the excludes and overrides.
plugins {
id 'org.springframework.boot' version '2.7.4'
id 'io.spring.dependency-management' version '1.0.12.RELEASE'
id 'java'
}
group = '<group>'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
maven {
url "https://nexus/repository/maven-public/"
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
ext['oracle-database.version']='21.7.0.0'
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-r2dbc'
implementation 'com.oracle.database.r2dbc:oracle-r2dbc'
implementation files('./lib/eagle_commons-0.0.1-SNAPSHOT-plain.jar')
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
implementation 'sg.com.gic:crypto-lib:1.0.5'
implementation group: 'com.oracle.database.jdbc', name: 'ojdbc11'
implementation group: 'org.springdoc', name: 'springdoc-openapi-webflux-ui', version: '1.6.11'
implementation group: 'org.modelmapper', name: 'modelmapper', version: '3.1.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
}
tasks.named('test') {
useJUnitPlatform()
}
This will fix all the excludes and incompatible versions. You cannot use R2DBC 1.0.0 with Spring BOot 2.7 (AFAIK) you would need to upgrade to Spring Boot 3.0.0 (as that includes the proper Spring Data version and R2DBC version which isn't compatible with Spring Boot 2.7 as it requires Spring Framework 6, java 17 etc.).
If you want to upgrade, modify the Spring Boot plugin version and everything else should be included automatically.
R2dbc 1.0.0 introduces several breaking changes, esp. some aggregate functions, eg. count returns Long instead of Integer.
I do not think the Spring Boot 2.7.x managed Spring Data R2dbc is ready for R2dbc 1.0.0. The latest Spring Data R2dbc(aligned to R2dbc 1.0.0) is upgraded to Spring Boot 3.0 code base.
Keep to use Spring Boot 2.7.5 and built-in Spring Data R2dbc.
if you want to use the latest R2dbc 1.0.0, consider Spring Boot 3.0.0-RC2, Spring Boot 3.0 is close to GA status.

What is the proper syntax of excluding transient dependencies in gradle, name or module?

I have come across two different variations of syntax to exclude a transient dependency in gradle
One uses name and another uses module. Which one is correct?
For eg:
name:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation group: 'org.springframework', name: 'spring-context', version: '5.3.19'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation('org.springframework.boot:sprin g-boot-starter-web') {
exclude group: 'org.springframework', name: 'spring-context'
}
}
OR module:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation group: 'org.springframework', name: 'spring-context', version: '5.3.19'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation('org.springframework.boot:sprin g-boot-starter-web') {
exclude group: 'org.springframework', module: 'spring-context'
}
}
The current documentation (7.4.2) shows module:
https://docs.gradle.org/7.4.2/userguide/dependency_downgrade_and_exclude.html
implementation('commons-beanutils:commons-beanutils:1.9.4') {
exclude group: 'commons-collections', module: 'commons-collections'
}
name is probably a legacy naming. Go with what the current documentation has, module.

WebApplicationInitializer is not launched on jetty+selenium

i am trying to run selenium test on jetty using gradle and my gradle configuration is as follows:
gradle.build:
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'
apply plugin: 'findbugs'
//apply from:'http://github.com/breskeby/gradleplugins/raw/master/emmaPlugin/emma.gradle'
apply from: 'emma.gradle'
apply plugin: 'jetty'
sourceCompatibility = 1.7
version = ''
sourceSets {
selenium
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.gradle.api.plugins:gradle-cargo-plugin:0.6'
}
}
repositories {
mavenCentral()
mavenRepo url: 'http://repository.primefaces.org'
mavenRepo url: 'http://repository.jboss.org/nexus/content/groups/public'
mavenRepo url: 'http://repository.jboss.org/maven2'
mavenRepo url: 'http://maven.springframework.org/release'
mavenRepo url: 'http://repo1.maven.org/maven2'
mavenRepo url: 'http://git.solutionstream.com/nexus/content/repositories/thirdparty'
}
dependencies {
//JSF
compile group: 'com.sun.faces', name: 'jsf-api', version: '2.1.22'
compile group: 'com.sun.faces', name: 'jsf-impl', version: '2.1.22'
compile 'org.ocpsoft.rewrite:rewrite-servlet:2.0.3.Final'
compile 'org.ocpsoft.rewrite:rewrite-config-prettyfaces:2.0.3.Final'
compile 'javax.el:el-api:2.2'
runtime 'org.glassfish.web:el-impl:2.2'
//Servlet
compile group: 'javax.servlet', name: 'jstl', version: '1.2'
providedCompile group: 'org.jboss.spec', name: 'jboss-javaee-6.0', version: '1.0.0.Final'
compile 'taglibs:standard:1.1.2'
compile group: 'org.springframework', name: 'spring-web', version: '3.2.2.RELEASE'
//Omnifaces
compile 'org.omnifaces:omnifaces:1.5'
//Prime Faces
compile group: 'org.primefaces', name: 'primefaces', version: '4.0-SNAPSHOT'
compile 'org.primefaces.themes:bootstrap:1.0.10'
// DB
compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.3.1.RELEASE'
compile group: 'org.springframework', name: 'spring-aspects', version: '3.2.2.RELEASE'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.9'
compile group: 'javax.inject', name: 'javax.inject', version: '1'
compile group: 'javax.enterprise', name: 'cdi-api', version: '1.0-SP4'
compile 'cglib:cglib-nodep:2.2.2'
//Hibernate / JPA
compile 'org.hibernate:hibernate-core:4.1.0.Final'
compile 'org.hibernate:hibernate-entitymanager:4.1.0.Final'
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final'
//JSR-303
compile 'org.hibernate:hibernate-validator:4.3.1.Final'
// Spring Security
compile 'org.springframework.security:spring-security-core:3.1.4.RELEASE'
compile 'org.springframework.security:spring-security-web:3.1.4.RELEASE'
compile 'org.springframework.security:spring-security-config:3.1.4.RELEASE'
//Utility
compile 'com.google.guava:guava:14.0.1'
compile 'commons-lang:commons-lang:2.6'
compile 'org.apache.commons:commons-email:1.3.1'
compile 'com.typesafe:config:1.0.0'
compile 'joda-time:joda-time:2.2'
compile 'org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:1.8.3'
compile 'org.slf4j:slf4j-api:1.7.2'
compile 'org.slf4j:jcl-over-slf4j:1.7.2'
compile 'org.slf4j:slf4j-log4j12:1.7.2'
//Mustache Templates
compile 'com.github.jknack:handlebars:1.0.0'
//Projects
//compile project(":ExtraValidators")
////TESTING DEPENDENCIES
testCompile 'com.googlecode.jmockit:jmockit:1.2'
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile 'com.h2database:h2:1.3.172'
//Spring Testing
testCompile 'org.springframework:spring-test:3.2.3.RELEASE'
/* Selenium */
seleniumCompile 'org.seleniumhq.selenium:selenium-java:2.33.0'
seleniumCompile 'junit:junit:4.11'
}
task wrapper(type: Wrapper){
gradleVersion = '1.5'
}
eclipse {
classpath {
downloadSources=true
plusConfigurations += configurations.seleniumCompile
}
}
task jettyDaemon(type: org.gradle.api.plugins.jetty.JettyRun) {
daemon = true
}
task selenium(type: Test, dependsOn: jettyDaemon) {
testClassesDir = sourceSets.selenium.output.classesDir
classpath = sourceSets.selenium.runtimeClasspath
}
WebApplicationInitializer:
package com.myapp.web.config;
import javax.faces.application.ProjectStage;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.request.RequestContextListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.filter.DelegatingFilterProxy;
import com.myapp.data.config.SpringConfig;
import com.myapp.data.config.SpringJNDIDataConfig;
import com.myapp.data.config.SpringJNDIJPAConfig;
import com.myapp.data.config.SpringSecurityConfig;
import com.myapp.data.config.SpringWebConfig;
import com.myapp.utils.configuration.ConfigurationUtil;
public class WebappConfig implements WebApplicationInitializer {
protected final Logger logger = LoggerFactory.getLogger(getClass());
#Override
public void onStartup(final ServletContext servletContext) throws ServletException {
if(logger.isDebugEnabled()) {
logger.debug("Starting web context configuration");
}
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
// rootContext.getEnvironment().setActiveProfiles("production");
rootContext.register(SpringConfig.class, SpringSecurityConfig.class, SpringWebConfig.class, SpringJNDIDataConfig.class, SpringJNDIJPAConfig.class);
servletContext.addListener(RequestContextListener.class);
new ContextLoader(rootContext).initWebApplicationContext(servletContext);
addFilters(servletContext, rootContext.getEnvironment());
servletContext.setInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME, ConfigurationUtil.config().getString("jsf.stage"));
servletContext.setInitParameter("javax.faces.FACELETS_REFRESH_PERIOD", ConfigurationUtil.config().getString("jsf.refreshPeriod"));
}
private void addFilters(final ServletContext servletContext, final ConfigurableEnvironment configurableEnvironment) {
FilterRegistration.Dynamic securityFilter = servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain"));
securityFilter.addMappingForUrlPatterns(null, false, "/*");
}
}
please advise how to make WebApplicationInitializer runs when running the selenium test on jetty.
WebApplicationInitializer requires a Servlet 3 container. However, Gradle's Jetty plugin is based on Jetty 6 which supports only Servlet 2.5.
You have a few options:
Configure your application with the web.xml file instead of WebApplicationInitializer
Use a newer Jetty version with Gradle. There are some workarounds in the comments of GRADLE-1956
Use an alternative container like Tomcat (gradle-tomcat-plugin)
Use an alternative plugin like gradle-cargo-plugin or arquillian-gradle-plugin. AFAIK there's a new gradle deployment plugin in the works that should be base on Arquillian.

Resources