I was facing the issue with Postgres Driver which was 9.1-901.jdbc4 and my database server was Postgres 10.I was getting issue in bulk update so I tried to change the driver to version 42.2.5.Following is the dependency:-
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
</dependency>
Its working fine now but I am getting infinite logs and I also do have Schedulars in my code:-
2019-06-04 06:48:33,358 FINE [org.postgresql.jdbc.PgConnection] (DefaultQuartzScheduler_Worker-9) setAutoCommit = false
2019-06-04 06:48:33,359 FINE [org.postgresql.jdbc.PgConnection] (DefaultQuartzScheduler_Worker-9) setAutoCommit = true
How I disable these logs.I am using Wildfly 10 as application server.
It looks like you have debug logging turned on. The simplest way would be with the web console or CLI. An example CLI command would look like:
/subsystem=logging/logger=org.postgresql.jdbc.PgConnection:remove
Note you can use tab complete as you may not have that logger specifically added.
Related
I have an old RDS database that was on 5.6_MySql_1.23.0, being used by a Java application running:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
<scope>compile</scope>
</dependency>
I've been refactoring old code, and part of that is upgrading from java 8 to 11. According to this post Java 11 doesn't support TLS=v1.0 & v1.1 anymore.
So I upgraded the cluster instance to 5.6_MySql_1.23.1 which does support TLS=v1.2 And I upgraded mysql connector to:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.49</version>
<scope>compile</scope>
</dependency>
Running SHOW GLOBAL VARIABLES LIKE 'tls_version'; seems to return a TLSv1.2 enabled cluster:
TLSv1,TLSv1.1,TLSv1.2
However, since the upgrade my username and password are constantly getting rejected:
Caused by: java.sql.SQLSyntaxErrorException: Access denied for user 'user'#'%' to database 'dba'
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:828)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:448)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:241)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:251)
at medispan.foundation.dataaccess.providers.sql.SQLProvider.createProviderConnection(SQLProvider.java:227)
at medispan.foundation.dataaccess.providers.sql.SQLProvider.createConnection(SQLProvider.java:205)
at medispan.foundation.dataaccess.providers.sql.SQLProvider.openConnection(SQLProvider.java:841)
at medispan.foundation.dataaccess.providers.sql.SQLProvider.executeForResults(SQLProvider.java:1489)
at medispan.foundation.dataaccess.providers.sql.SQLDataAccessProvider.innerExecuteForCollection(SQLDataAccessProvider.java:515)
... 120 common frames omitted
Here's my JDBC string that worked in my java 8 service:
jdbc:mysql://test-aurora-sdt-c1-0.cpdk4xuooxvm.us-east-1.rds.amazonaws.com:3306?user=[user]&password=[password]&verifyServerCertificate=false&useSSL=true&sslca=rds-combined-ca-bundle.pem&serverTimezone=PST
Here's my updated url for all the errors I've had to fix with the mysql changes since the two versions:
jdbc:mysql://test-aurora-sdt-c1-0.cpdk4xuooxvm.us-east-1.rds.amazonaws.com:3306/dba?user=[user]&password=[password]&verifyServerCertificate=false&useSSL=true&enabledTLSProtocols=TLSv1.2&sslca=rds-combined-ca-bundle.pem&serverTimezone=America/Los_Angeles
Did I miss a step database version migration to enable tls? Do I have to do something with my cert bundle that I'm just not aware of coming from a dynamo background?
I have a Spring boot application running with maven. I can successfully run my app locally, but when I run an image in the local docker swarm: docker stack deploy --compose-file docker-compose.yml compose I get the following error: Caused by: java.lang.IllegalStateException: Cannot load driver class: org.postgresql.Driver
I've checked env.getPropertySources():
compose_service#debian| spring.datasource.driver-class-name=org.postgresql.Driver
compose_service#debian| spring.datasource.url=jdbc:postgresql://localhost:5432/service
compose_service#debian| spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
These props work fine with local running.
I've checked, the built jar contains the Postgres lib; maven dependency in my project:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.1</version>
</dependency>
I recently ran the app with docker-compose up and it also worked, so it seems like a problem with running in swarm. Any ideas?
I shouldn't add secrets to docker swarm by echo,
which adds \n to each string (that's why my driver name wasn't valid).
Instead, I should use printf:
printf "org.postgresql.Driver" | docker secret create db-driver -
Hope it will save time for someone
When i run my spring boot contextLoads test, the code broken becouse liquibase is trying running
Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP
my pom just has the property
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
how should i do to my liquibase stop running in the test context?
Thanks.
You can disable liquibase with property spring.liquibase.enabled=false.
If you are using #SpringBootTest you can add properties to it.
#SpringBootTest(properties = { "spring.liquibase.enabled=false" })
I have a Java Spring app and I'm using Amazon Keyspaces (for Apache Cassandra). I'm using the sigv4 plugin , (version 4.0.2), the cassandra java-driver-core (version 4.4.0) and have followed the official documentation on how to connect my java app with MCS. The app connects just fine but I'm getting a weird warning at start up:
WARN 1 --- [ s0-admin-0] .o.d.i.c.m.t.DefaultTokenFactoryRegistry : [s0] Unsupported partitioner 'com.amazonaws.cassandra.DefaultPartitioner', token map will be empty.
Everything looks good but after a few minutes that warning comes back and my queries start to fail. This is how the logs look after a few minutes:
WARN 1 --- [ s0-admin-0] .o.d.i.c.m.t.DefaultTokenFactoryRegistry : [s0] Unsupported partitioner 'com.amazonaws.cassandra.DefaultPartitioner', token map will be empty.
WARN 1 --- [ s0-io-1] c.d.o.d.i.c.m.SchemaAgreementChecker : [s0] Unknown peer xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, excluding from schema agreement check
WARN 1 --- [ s0-io-0] c.d.o.d.i.c.control.ControlConnection : [s0] Unexpected error while refreshing schema after a successful reconnection, keeping previous version (CompletionException: com.datastax.oss.driver.api.core.connection.ClosedConnectionException: Channel was force-closed)
WARN 1 --- [ s0-io-1] c.d.o.d.i.c.m.DefaultTopologyMonitor : [s0] Control node ec2-x-xx-xxx-xx.us-east-2.compute.amazonaws.com/x.xx.xxx.xxx:xxxx has an entry for itself in system.peers: this entry will be ignored. This is likely due to a misconfiguration; please verify your rpc_address configuration in cassandra.yaml on all nodes in your cluster.
I have debugged a little and it looks like that partitioner comes from the actual node metadata, so I don't really know if there's an actual way to fix it.
I've seen there's a similar question asked recently here, but no solution has been posted yet. Any ideas? Thanks so much in advance
These are all warnings and not errors. Your connection should work just fine. They are logged due to how Amazon Keyspaces is slightly different from an actual Cassandra cluster. Try setting these to get rid of the noise:
datastax-java-driver.advanced {
metadata {
schema.enabled = false
token-map.enabled = false
}
connection.warn-on-init-error = false
}
Problem the same with me.
The above problems encountered when using a Spring boot version 2.3.x
Because is a Spring boot version 2.3.x
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra-reactive</artifactId>
</dependency>
OR
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
</dependency>
When creating a Maven / Gradle will get "datastax-java-driver-core 4.6.1" and I think this is another reason that Amazon Keyspaces are not supported.
Okay, Clear.....
Back to the subject of AWS library aws-sigv4-auth-cassandra-java-driver-plugin 4.0.2
When creating a Maven / Gradle will get "datastax-java-driver-core 4.4.0"
Now I am starting to see that Amazon Keyspaces
Maybe not supported "datastax-java-driver-core" with version greater than 4.4.0
Okay, it's been very long.
If you want Application Spring Boot 2 to work
You try following the solutions follows.
look at pom.xml
remove aws-sigv4-auth-cassandra-java-driver-plugin
downgrade Spring boot version 2.3.x to 2.2.9
add dependency below,
spring-boot-starter-data-cassandra-reactive
OR
spring-boot-starter-data-cassandra
create Amazon digital certificate and download
If you used InteljiJ IDEA Edit Configurations
Goto Edit Configurations -> next VM Options add below,
-Djavax.net.ssl.trustStore=path_to_file/cassandra_truststore.jks
-Djavax.net.ssl.trustStorePassword=my_password
Reference: https://docs.aws.amazon.com/keyspaces/latest/devguide/using_java_driver.html
application-dev.yml add config below,
spring:
data:
cassandra:
contact-points:
- "cassandra.ap-southeast-1.amazonaws.com"
port: 9142
ssl: true
username: "cassandra-username"
password: "cassandra-password"
keyspace-name: keyspace-name
request:
consistency: local_quorum
Run Test Program
Pass.
Work for me.
Tech Stack
Spring Boot WebFlux 2.2.9.RELEASE
Cassandra Reactive
JDK 13
Cassandra Database with Amazon Keyspaces
Maven 3.6.3
Have fun with programming.
I am working on enabling spring boot health check using actuator. Since our app is dependent on Spring 1.5.21, so I have to use actuator 1.5.21 release. I read some configurations on their online documentation shows that you can apply the following to only allow "/health" endpoint to expose.
By default, all endpoints except for shutdown are enabled. If you prefer to specifically “opt-in” endpoint enablement you can use the endpoints.enabled property. For example, the following will disable all endpoints except for info:
endpoints.enabled=false
endpoints.info.enabled=true
Since I need to disable all endpoints except "/health" endpoint, so I configured it in application.properties file like below. However, it is not working for me.
endpoints.enabled=false
endpoints.health.enabled=true
Here is the result:
http://localhost:8080/health
{"message":"This endpoint is disabled"}
Environments:
Spring boot: 1.5.21 release
JDK: 1.8
Application: web application
Any thoughts on this? Thanks in advance!
UPDATES:
After I started a new project using the same spring boot 1.5.21.RELEASE, below settings worked.
endpoints.enabled=false
endpoints.health.enabled=true
2020-03-29 19:29:15.541 INFO 9796 --- [ restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/health || /health.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(javax.servlet.http.HttpServletRequest,java.security.Principal)
UPDATE on 3/30:
HOWEVER, when I used it with SDL Tridion 8.5, it stopped working. Any ideas?
<dependency>
<groupId>com.sdl.dxa</groupId>
<artifactId>dxa-common-api</artifactId>
<version>${dxaversion}</version>
</dependency>
<dependency>
<groupId>com.sdl.dxa</groupId>
<artifactId>dxa-common</artifactId>
<version>${dxaversion}</version>
</dependency>
<dependency>
<groupId>com.sdl.dxa</groupId>
<artifactId>dxa-tridion-provider</artifactId>
<version>${dxaversion}</version>
</dependency>
<dependency>
<groupId>com.sdl.dxa.modules</groupId>
<artifactId>dxa-module-core</artifactId>
<version>${dxaversion}</version>
</dependency>
endpoints.enabled=false
endpoints.health.enabled=true
Result:
http://localhost:8080/health
{"message":"This endpoint is disabled"}
No need to use disable. Use only below properties:
management.endpoints.web.exposure.include='health'