ns does not exist, com.mongodb.MongoCommandException - java

Using mongock to perform the data migration but end up with below error.
Gradle
plugins {
id 'java'
}
group 'fete.bird'
version '0.0.1-SNAPSHOT'
repositories {
mavenCentral()
}
ext {
set('mongockVersion', "4.1.14")
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb:2.3.1.RELEASE'
implementation "com.github.cloudyrock.mongock:mongock-standalone:${mongockVersion}"
implementation "com.github.cloudyrock.mongock:mongodb-sync-v4-driver:${mongockVersion}"
implementation 'org.mongodb:mongodb-driver-sync:4.1.0'
compile project(':Data')
}
Standalone approach
public class main {
public static void main(String[] args) {
MongockStandalone();
}
private static void MongockStandalone(){
var mongoUri = Configuration.getMongoUri();
MongoClient mongoClient = MongoClients.create("mongodb://127.0.1:27017/");
MongockStandalone.builder()
.setDriver(MongoSync4Driver.withDefaultLock(mongoClient,"FeteBird-Product"))
.addChangeLogsScanPackage("db.migration")
.buildRunner().execute();
}
}
Changelog
#ChangeLog(order = "001")
public class DbChangeLog001 {
#ChangeSet(order = "001", id = "seedProduct", author = "San")
public void seedProduct(MongoDatabase mongoDatabase) {
mongoDatabase.createCollection("Product");
}
}
Error
02:04:52.060 [main] DEBUG org.mongodb.driver.operation - Unable to retry operation listIndexes due to error "com.mongodb.MongoCommandException: Command failed with error 26 (NamespaceNotFound): 'ns does not exist: FeteBird-Product.mongockChangeLog' on server 127.0.1:27017. The full response is {"ok": 0.0, "errmsg": "ns does not exist: FeteBird-Product.mongockChangeLog", "code": 26, "codeName": "NamespaceNotFound"}"
02:04:52.061 [main] DEBUG com.github.cloudyrock.mongock.driver.mongodb.sync.v4.repository.MongoSync4RepositoryBase - Removing residual uniqueKeys for collection [mongockChangeLog]
02:04:52.063 [main] DEBUG org.mongodb.driver.protocol.command - Sending command '{"listIndexes": "mongockChangeLog", "cursor": {}, "$db": "FeteBird-Product", "lsid": {"id": {"$binary": {"base64": "2Ki32rm4RAacZEcl0iUR0A==", "subType": "04"}}}}' with request id 17 to database FeteBird-Product on connection [connectionId{localValue:3, serverValue:20}] to server 127.0.1:27017
02:04:52.069 [main] DEBUG org.mongodb.driver.protocol.command - Execution of command with request id 17 failed to complete successfully in 6.26 ms on connection [connectionId{localValue:3, serverValue:20}] to server 127.0.1:27017
com.mongodb.MongoCommandException: Command failed with error 26 (NamespaceNotFound): 'ns does not exist: FeteBird-Product.mongockChangeLog' on server 127.0.1:27017. The full response is {"ok": 0.0, "errmsg": "ns does not exist: FeteBird-Product.mongockChangeLog", "code": 26, "codeName": "NamespaceNotFound"}
at com.mongodb.internal.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:175)
at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:359)
at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:280)
at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:100)
at com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:490)
at com.mongodb.internal.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:71)
at com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:255)
at com.mongodb.internal.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:202)
at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:118)
at com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:110)
at com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:345)
at com.mongodb.internal.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:336)
at com.mongodb.internal.operation.CommandOperationHelper.executeCommandWithConnection(CommandOperationHelper.java:222)
at com.mongodb.internal.operation.ListIndexesOperation$1.call(ListIndexesOperation.java:171)
at com.mongodb.internal.operation.ListIndexesOperation$1.call(ListIndexesOperation.java:165)
at com.mongodb.internal.operation.OperationHelper.withReadConnectionSource(OperationHelper.java:582)
at com.mongodb.internal.operation.ListIndexesOperation.execute(ListIndexesOperation.java:165)
at com.mongodb.internal.operation.ListIndexesOperation.execute(ListIndexesOperation.java:73)
at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:178)
at com.mongodb.client.internal.MongoIterableImpl.execute(MongoIterableImpl.java:135)
at com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:92)
at com.mongodb.client.internal.MongoIterableImpl.forEach(MongoIterableImpl.java:121)
at com.github.cloudyrock.mongock.driver.mongodb.sync.v4.repository.MongoSync4RepositoryBase.getResidualKeys(MongoSync4RepositoryBase.java:73)
at com.github.cloudyrock.mongock.driver.mongodb.sync.v4.repository.MongoSync4RepositoryBase.cleanResidualUniqueKeys(MongoSync4RepositoryBase.java:66)
at com.github.cloudyrock.mongock.driver.mongodb.sync.v4.repository.MongoSync4RepositoryBase.ensureIndex(MongoSync4RepositoryBase.java:52)
at com.github.cloudyrock.mongock.driver.mongodb.sync.v4.repository.MongoSync4RepositoryBase.initialize(MongoSync4RepositoryBase.java:39)
at io.changock.driver.core.driver.ConnectionDriverBase.initialize(ConnectionDriverBase.java:43)
at io.changock.runner.core.MigrationExecutor.initializationAndValidation(MigrationExecutor.java:189)
at io.changock.runner.core.MigrationExecutor.executeMigration(MigrationExecutor.java:61)
at io.changock.runner.core.ChangockBase.execute(ChangockBase.java:44)
at main.MongockStandalone(main.java:18)
at main.main(main.java:9)

This is probably because you are using a quite new version of MongoDB. Mongock used that field, but it's not needed anymore.
Since version 4.1.14, this 'ns' field is not used, so you should stop seeing this issue.
You can take a look to Mongock's documentation.

Related

AWS XRay service map components are disconnected

I'm using open telemetry to export trace information of the following application:
A nodejs kafka producer sends messages to input-topic. It uses kafkajs instrumented with opentelemetry-instrumentation-kafkajs library. I'm using the example from AWS OTEL for NodeJS example. Here is my tracer.js:
module.exports = () => {
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.ERROR);
// create a provider for activating and tracking with AWS IdGenerator
const attributes = {
'service.name': 'nodejs-producer',
'service.namespace': 'axel'
}
let resource = new Resource(attributes)
const tracerConfig = {
idGenerator: new AWSXRayIdGenerator(),
plugins: {
kafkajs: { enabled: false, path: 'opentelemetry-plugin-kafkajs' }
},
resource: resource
};
const tracerProvider = new NodeTracerProvider(tracerConfig);
// add OTLP exporter
const otlpExporter = new CollectorTraceExporter({
url: (process.env.OTEL_EXPORTER_OTLP_ENDPOINT) ? process.env.OTEL_EXPORTER_OTLP_ENDPOINT : "localhost:55680"
});
tracerProvider.addSpanProcessor(new SimpleSpanProcessor(otlpExporter));
tracerProvider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
// Register the tracer with X-Ray propagator
tracerProvider.register({
propagator: new AWSXRayPropagator()
});
registerInstrumentations({
tracerProvider,
instrumentations: [new KafkaJsInstrumentation({})],
});
// Return a tracer instance
return trace.getTracer("awsxray-tests");
}
A Java application that reads from input-topic and produces to final-topic. Also instrumented with AWS OTEL java agent. Java app is launched like below:
export OTEL_TRACES_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
export OTEL_PROPAGATORS=xray
export OTEL_RESOURCE_ATTRIBUTES="service.name=otlp-consumer-producer,service.namespace=axel"
export OTEL_METRICS_EXPORTER=none
java -javaagent:"${PWD}/aws-opentelemetry-agent.jar" -jar "${PWD}/target/otlp-consumer-producer.jar"
I'm using otel/opentelemetry-collector-contrib that has AWS XRay exporter:
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
exporters:
awsxray:
region: 'eu-central-1'
max_retries: 10
service:
pipelines:
traces:
receivers: [otlp]
exporters: [awsxray]
I can see from log messages and also from XRay console that traces are being published (with correct parent trace ids). NodeJS log message:
{
traceId: '60d0c7d4cfc2d86b2df8624cb4bccead',
parentId: undefined,
name: 'input-topic',
id: '3e289f00c4499ae8',
kind: 3,
timestamp: 1624295380734468,
duration: 3787,
attributes: {
'messaging.system': 'kafka',
'messaging.destination': 'input-topic',
'messaging.destination_kind': 'topic'
},
status: { code: 0 },
events: []
}
and Java consumer with headers:
Headers([x-amzn-trace-id:Root=1-60d0c7d4-cfc2d86b2df8624cb4bccead;Parent=3e289f00c4499ae8;Sampled=1])
As you see parent and root ids match each other. However the service map is constructed in a disconnected way:
What other configuration I'm missing here to compile a correct service map?

Micronaut - No bean of type [io.micronaut.transaction.SynchronousTransactionManager] exists

I'm migrating one of my Microservices from Spring to Micronaut and this is a problem I'm facing while calling a controller to load one entity. The error I get is:
{
"message": "Internal Server Error: No bean of type [io.micronaut.transaction.SynchronousTransactionManager] exists. Make sure the bean is not disabled by bean requirements (enable trace logging for 'io.micronaut.context.condition' to check) and if the bean is enabled then ensure the class is declared a bean and annotation processing is enabled (for Java and Kotlin the 'micronaut-inject-java' dependency should be configured as an annotation processor)."
}
I already enabled the io.micronaut.context.condition logger, setting it to TRACE level, but I see no reference of the class SynchronousTransactionManager in the logs.
This is my build.gradle:
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
url 'https://jitpack.io'
}
}
dependencies {
classpath "org.hibernate:hibernate-gradle-plugin:5.4.12.Final"
}
}
plugins {
id("com.github.johnrengelman.shadow") version "6.1.0"
id("io.micronaut.application") version "1.3.3"
id('com.google.protobuf') version '0.8.11'
id('java')
id('idea')
}
apply plugin: 'org.hibernate.orm'
hibernate {
enhance {
enableLazyInitialization = true
enableDirtyTracking = true
enableAssociationManagement = true
}
}
version = "0.1"
group = "com.elevenstars.service"
repositories {
mavenCentral()
jcenter()
}
micronaut {
runtime("netty")
testRuntime("junit5")
processing {
incremental(true)
annotations("com.elevenstars.service.*")
}
}
dependencies {
// Annotation processors - Order does matter!!
annotationProcessor("org.mapstruct:mapstruct-processor:1.4.1.Final")
annotationProcessor("org.projectlombok:lombok")
annotationProcessor("io.micronaut.data:micronaut-data-processor")
annotationProcessor('io.micronaut:micronaut-inject-java')
annotationProcessor("io.micronaut:micronaut-graal")
annotationProcessor("io.micronaut.security:micronaut-security-annotations")
// Micronaut libs
implementation("io.micronaut:micronaut-validation")
implementation("io.micronaut:micronaut-runtime")
implementation("io.micronaut:micronaut-inject")
implementation("io.micronaut.xml:micronaut-jackson-xml")
implementation("javax.annotation:javax.annotation-api")
compileOnly("org.graalvm.nativeimage:svm")
// Kafka
implementation("io.micronaut.kafka:micronaut-kafka")
// Consul
implementation("io.micronaut:micronaut-discovery-client")
// Security
implementation("io.micronaut.security:micronaut-security-annotations")
implementation("io.micronaut.security:micronaut-security-jwt")
// Database access
implementation("io.micronaut.data:micronaut-data-hibernate-jpa")
implementation("io.micronaut.beanvalidation:micronaut-hibernate-validator")
implementation('com.vladmihalcea:hibernate-types-52:2.9.7')
implementation "org.hibernate:hibernate-graalvm:5.4.12.Final"
runtimeOnly('org.postgresql:postgresql')
//Mapping
implementation 'org.mapstruct:mapstruct:1.4.1.Final'
// gRPC
implementation 'io.grpc:grpc-protobuf:1.33.0'
implementation 'io.grpc:grpc-stub:1.33.0'
implementation 'io.grpc:grpc-netty:1.33.0'
implementation 'io.grpc:grpc-core:1.33.0'
implementation('io.grpc:grpc-netty-shaded:1.33.0') {
version {
strictly "1.33.0"
}
because "fails to run"
}
// Protobuf
implementation 'com.google.protobuf:protobuf-java-util:3.11.4'
// Dev tools
compileOnly 'org.projectlombok:lombok'
// Other stuff
implementation("io.micronaut:micronaut-http-client")
runtimeOnly("ch.qos.logback:logback-classic")
}
application {
mainClass.set("com.elevenstars.service.facilities.Application")
}
java {
sourceCompatibility = JavaVersion.toVersion("11")
targetCompatibility = JavaVersion.toVersion("11")
}
task mapStruct() {
sourceSets.main.java.srcDir file("${buildDir}/mappers")
tasks.withType(JavaCompile) {
options.setAnnotationProcessorGeneratedSourcesDirectory(file("${buildDir}/mappers"))
options.compilerArgs << "-Amapstruct.defaultComponentModel=jsr330"
}
}
compileJava.dependsOn(mapStruct)
This is my application.yml
micronaut:
application:
name: facilities
security:
authentication: bearer
token:
jwt:
signatures:
secret:
generator:
secret: my-secret
bearer:
enabled: true
enabled: true
redirect:
unauthorized:
enabled: false
server:
context-path: /v1/facilities
port: 8080
cors:
enabled: true
kafka:
bootstrap:
servers: localhost:9092
embedded:
enabled: false
jackson:
# time-zone: UTC
serialization:
write-dates-as-timestamps: false
deserialization:
fail-on-unknown-properties: false
generator:
write-numbers-as-strings: false
time-zone: UTC
consul:
client:
registration:
enabled: true
defaultZone: "${CONSUL_HOST:localhost}:${CONSUL_PORT:8500}"
jpa:
default:
entity-scan:
packages: 'com.elevenstars.service.facilities.domain.entity'
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
format_sql: true
jdbc:
time_zone: UTC
# ddl-auto: update
show-sql: false
open-in-view: false
datasource:
default:
url: jdbc:postgresql://localhost:5432/facilities
username: *hidden*
password: *hidden*
Controller:
#Controller
#Secured(SecurityRule.IS_AUTHENTICATED)
public class GymController extends BaseController
{
private final GymReconstructionService gymReconstructionService;
private final PatrimonyMapper patrimonyMapper;
#Inject
public GymController(
GymReconstructionService gymReconstructionService,
PatrimonyMapper patrimonyMapper
) {
this.gymReconstructionService = gymReconstructionService;
this.patrimonyMapper = patrimonyMapper;
}
#Get("/gym/upgrade/estimation")
public HttpResponse<ReconstructionEstimation> getUpgradeReconstructionEstimation() {
return HttpResponse.ok(gymReconstructionService.getUpgradeEstimations());
}
}
Application Service
#Singleton
#Transactional
public class GymReconstructionService extends ApplicationService
{
private final GymRepository gymRepository;
private final DebitMoneyClient debitMoneyClient;
private final LoggedUser loggedUser;
#Inject
public GymReconstructionService(
GymRepository gymRepository,
DebitMoneyClient debitMoneyClient,
LoggedUser loggedUser
) {
this.loggedUser = loggedUser;
this.gymRepository = gymRepository;
this.debitMoneyClient = debitMoneyClient;
}
public ReconstructionEstimation getUpgradeEstimations() {
var gym = getGym(loggedUser.getClubId());
return gym.getUpgradeReconstructionEstimation();
}
private Gym getGym(UUID clubId) throws GymNotFoundException {
return gymRepository
.findById(clubId)
.orElseThrow(GymNotFoundException::new);
}
}
One thing I've realized was if I remove the #Transactional annotation, this error doesn't happen anymore, but I end up with another error:
{
"message": "Internal Server Error: No backing RepositoryOperations configured for repository. Check your configuration and try again"
}
Any clue here about what's going on?
I have solved a similar problem.
Try adding the following to your application.yml
jpa.default.properties.hibernate.hbm2ddl.auto: update

Connecting to local MySQL database doesnt work after creating an .exe with jLink + jPackage

Enivronment:
OpenJDK 11, JavaFX 11, MySQL 8.0, Gradle 6.2.2, IntellijIDEA ,Windows 8.1
Problem:
When I run my program inside the IDE it works fine and connects to the database without problems, but once I try to run the .exe built with jLink and jPackage it shows an error.
Some code from the class "ConnectionManager" used to connect to the local MySQL database:
final String url = "jdbc:mysql://localhost:3306/", user = "root", password = "password", databaseName = "sifana";
final String databaseNameWithTimezone = databaseName + "?zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=UTC";
public static Connection connection;
private Connection createDatabase() throws SQLException {
String sql = "create database if not exists sifana";
Connection connection = DriverManager.getConnection(url + "?zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=UTC", user, password);
Statement statement = connection.createStatement();
statement.executeUpdate(sql);
statement.close();
return connection;
}
build.gradle:
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.8'
id 'com.github.johnrengelman.shadow' version "5.0.0"
id 'org.beryx.jlink' version '2.17.2'
}
group 'yayarh'
version '1.0'
sourceCompatibility = '11'
targetCompatibility = '11'
mainClassName = "$moduleName/yayarh.Launcher"
repositories {
mavenCentral()
}
dependencies {
testImplementation group: 'junit', name: 'junit', version: '4.12'
implementation group: 'com.jfoenix', name: 'jfoenix', version: '9.0.9'
implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.19'
implementation group: 'org.controlsfx', name: 'controlsfx', version: '11.0.0'
}
application {
'yayarh.Launcher'
applicationDefaultJvmArgs = ["--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix",
"--add-exports=javafx.controls/com.sun.javafx.scene.control=com.jfoenix",
"--add-exports=javafx.base/com.sun.javafx.binding=com.jfoenix",
"--add-exports=javafx.graphics/com.sun.javafx.stage=com.jfoenix",
"--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=com.jfoenix",
"--add-exports=javafx.base/com.sun.javafx.event=com.jfoenix"]
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
jlink {
launcher {
name = 'Sifana'
jvmArgs = applicationDefaultJvmArgs
}
jpackage {
installerOptions = [
'--description', 'Place a description here',
'--copyright', 'All copyrights to...',
'--vendor', 'vendor',
]
installerType = project.findProperty('installerType')
if (installerType == 'msi') {
imageOptions += ['--icon', 'src/main/resources/yayarh/images/sifana_ico.ico']
installerOptions += [
'--win-per-user-install', '--win-dir-chooser',
'--win-menu', '--win-shortcut'
]
}
}
}
jpackage {
doFirst {
project.getProperty('installerType') // throws exception if its missing
}
}
jar {
manifest {
attributes "Main-Class": 'yayarh.Launcher'
}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
javafx {
version = '11'
modules = ['javafx.controls', 'javafx.fxml']
}
The error stacktrace:
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at yayarh.merged.module/com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) at yayarh.merged.module/com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
at yayarh.merged.module/com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
at yayarh.merged.module/com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at yayarh.merged.module/com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
at yayarh.merged.module/com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
at sifana/yayarh.classes.ConnectionManager.createDatabase(ConnectionMana
ger.java:25)
at sifana/yayarh.classes.ConnectionManager.initiateConnection(ConnectionManager.java:18)
at sifana/yayarh.Main.start(Main.java:25)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at yayarh.merged.module/com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
at yayarh.merged.module/com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
at yayarh.merged.module/com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
at yayarh.merged.module/com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
at yayarh.merged.module/com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:338)
at yayarh.merged.module/com.mysql.cj.protocol.a.NativeAuthenticationProvider.negotiateSSLConnection(NativeAuthenticationProvider.java:777)
at yayarh.merged.module/com.mysql.cj.protocol.a.NativeAuthenticationProvider.proceedHandshakeWithPluggableAuthentication(NativeAuthenticationProvider.ja
va:486)
at yayarh.merged.module/com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:202)
at yayarh.merged.module/com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1340)
at yayarh.merged.module/com.mysql.cj.NativeSession.connect(NativeSession.java:157)
at yayarh.merged.module/com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:956)
at yayarh.merged.module/com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826)
... 17 more
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:128)
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
at java.base/sun.security.ssl.Alert$AlertConsumer.consume(Alert.java:279)
at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:181)
at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:164)
at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152)
at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402)
at yayarh.merged.module/com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:336)
at yayarh.merged.module/com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:188)
at yayarh.merged.module/com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:99)
at yayarh.merged.module/com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:329)
... 24 more
Please note that it works perfectly when running from the IDE.
I had this error when using JPackage as well, I received SSLHandshakeExceptions after exporting but not within the IDE itself. This error occurs because of the way Java 11 uses TLSv1.3 which works unexpectedly when jpackage has exported. Here's how I fixed it. When creating a SSL connection, you need to force TLSv1.2.
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(null, null, new SecureRandom());
SocketFactory socketFactory = sslContext.getSocketFactory();
/* Use the socketFactory to initialize your SSL connection */
I realize the OP had his problem solved, but I was led to this thread with the exact same problem. And, I didn't see any other similar threads. The two suggestions above didn't help me.
I was able to solve my problem. It turned out I was missing the statement " requires mysql.connector.java;" in the modules-info manifest file. That was causing jpackage not to include the driver in the final build.
I could successfully run the program with the Gradle "run" task. However, the connection would fail running the installed version I'd made using jpackage.

H2 Driver not found when configuring JOOQ Codegen through gradle

I am trying to configure a project using h2, jooq and flyway. However, once the nu.studer.jooq plugin generates the config.xml it's unable to find the org.h2.driver I have the depedency in my build.gradle which is shown below along with the error I keep getting.
plugins {
id 'java'
id 'application'
id 'org.springframework.boot' version '2.2.4.RELEASE'
id 'nu.studer.jooq' version '4.0'
id 'org.flywaydb.flyway' version '6.2.3'
}
ext['jooq.version'] = '3.12.3'
sourceCompatibility = 11.0
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.2.4.RELEASE'
implementation group: 'org.jooq', name: 'jooq', version: '3.12.3'
implementation group: 'com.h2database', name: 'h2', version: '1.4.199'
}
application {
mainClassName = 'exampleapp.App'
}
jooq {
version = '3.12.3'
edition = 'OSS'
sample(sourceSets.main) {
jdbc {
driver = 'org.h2.Driver'
url = 'jdbc:h2:~/test'
user = 'sa'
password = ''
schema = 'public'
}
generator {
name = 'org.jooq.util.DefaultGenerator'
strategy {
name = 'org.jooq.util.DefaultGeneratorStrategy'
}
database {
name = 'org.jooq.meta.h2.H2Database'
}
generate {
relations = true
deprecated = false
records = true
immutablePojos = true
fluentSetters = true
}
target {
packageName = 'generated.jooq'
directory = '$projectDir/src/generated/jooq'
}
}
}
}
flyway {
url = 'jdbc:h2:~/test'
user = 'sa'
password = ''
schemas = ['public']
}
generateSampleJooqSchemaSource.dependsOn flywayMigrate
The error I receive when I run gradle clean build is as follows:
java.lang.ClassNotFoundException: org.h2.Driver
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at org.jooq.codegen.GenerationTool.loadClass0(GenerationTool.java:925)
at org.jooq.codegen.GenerationTool.loadClass(GenerationTool.java:869)
at org.jooq.codegen.GenerationTool.run0(GenerationTool.java:334)
at org.jooq.codegen.GenerationTool.run(GenerationTool.java:221)
at org.jooq.codegen.GenerationTool.generate(GenerationTool.java:216)
at org.jooq.codegen.GenerationTool.main(GenerationTool.java:188)
Not sure why it can't find h2 in the classpath, any ideas?
Figured it out, I needed to add
jooqRuntime {
dependecies: 'com.h2database:h2:1.4.199'
}
To allow the task to find org.h2.Driver in the classpath

org.apache.wicket.markup.MarkupNotFoundException: Can not determine Markup. Component is not yet connected to a parent

I run gradle script with dependecy to jupiter,wicket spring boot start and springboot starter
buildscript {
repositories {
mavenCentral()
// The following is only necessary if you want to use SNAPSHOT releases.
// maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.2'
}
}
apply plugin: 'org.junit.platform.gradle.plugin'
// Apply the java-library plugin to add support for Java Library
apply plugin: 'java'
junitPlatform {
reportsDir file('build/test-results/junit-platform') // this is the default
enableStandardTestTask true
// selectors (optional)
// filters (optional)
}
// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
dependencies {// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter
compile group: 'org.springframework.boot', name: 'spring-boot-starter', version: '1.5.9.RELEASE'
// https://mvnrepository.com/artifact/com.giffing.wicket.spring.boot.starter/wicket-spring-boot-starter
compile group: 'com.giffing.wicket.spring.boot.starter', name: 'wicket-spring-boot-starter', version: '2.0.4'
}
dependencies {
testCompile("org.junit.jupiter:junit-jupiter-api:5.0.2")
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.0.2")
}
dependencies {
testCompile("junit:junit:4.12")
testRuntime("org.junit.vintage:junit-vintage-engine:4.12.2")
}
On the test
package steinKo.ATM.Web.test.unit;
import org.apache.wicket.util.tester.WicketTester;
import org.junit.jupiter.api.Test;
class HomePageTest {
private WicketTester tester;
#Test
public void shouldRender() {
tester = new WicketTester();
tester.startPage(HomePage.class);
tester.assertRenderedPage(HomePage.class);
}
}
On the class
package steinKo.ATM.Web;
import org.apache.wicket.markup.html.WebPage;
public class HomePage extends WebPage{
/**
*
*/
private static final long serialVersionUID = 1L;
}
With the html
Insert
title here
I recive folloing error message
2:57:15.185 [main] DEBUG
org.apache.wicket.core.util.resource.locator.ResourceStreamLocator -
Attempting to locate resource 'org/apache/wicket/Page.html' using
finder'[webapppath: /]' 22:57:15.185 [main] DEBUG
org.apache.wicket.core.util.resource.locator.ResourceStreamLocator -
Attempting to locate resource 'org/apache/wicket/Page.html' using
finder'[classpath: META-INF/resources/]' 22:57:15.186 [main] DEBUG
org.apache.wicket.markup.MarkupCache - Markup not found:
steinKo.ATM.Web.HomePage_nb_NO.html 22:57:15.195 [main] DEBUG
org.apache.wicket.page.PageAccessSynchronizer - 'main' attempting to
acquire lock to page with id '0' 22:57:15.195 [main] DEBUG
org.apache.wicket.page.PageAccessSynchronizer - main acquired lock to
page 0 22:57:15.229 [main] WARN RequestCycleExtra -
******************************** 22:57:15.232 [main] WARN RequestCycleExtra - Handling the following exception
org.apache.wicket.markup.MarkupNotFoundException: Can not determine
Markup. Component is not yet connected to a parent. [Page class =
steinKo.ATM.Web.HomePage, id = 0, render count = 1]
I think the erreor is cause by lack of link between Homepage.java and HomePage.hlml in Gradle
How could I fixed this error?
The solution
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
resources {
srcDirs = ['src/main/java','src/main/resources']
}
}
}

Categories

Resources