spring boot embedded neo4j: not able to connect from client when in docker container - spring

I upgraded one of my spring boot application from java 8 . I was using spring boot version 2.1.5.RELEASE previously with these all dependencies:
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<neo4j.version>3.5.20</neo4j.version>
<neo4j-ogm-core.version>3.1.9</neo4j-ogm-core.version>
<neo4j-ogm-api.version>3.1.8</neo4j-ogm-api.version>
<neo4j-ogm-embedded-driver.version>3.1.9</neo4j-ogm-embedded-driver.version>
<liquigraph.version>3.1.2</liquigraph.version>
<lombok.version>1.18.8</lombok.version>
<spring-data-neo4j.version>5.3.1.RELEASE</spring-data-neo4j.version>
<spring-boot-starter.version>2.1.5.RELEASE</spring-boot-starter.version>
<spring-boot-starter-test.version>2.1.5.RELEASE</spring-boot-starter-test.version>
Now upgraded that to java 11 with spring boot version 2.3.3.RELEASE with these dependencies:
<java.version>11</java.version>
<neo4j.version>4.2.4</neo4j.version>
<neo4j-ogm-core.version>3.2.32</neo4j-ogm-core.version>
<neo4j-ogm-api.version>3.2.32</neo4j-ogm-api.version>
<liquigraph.version>4.0.2</liquigraph.version>
<lombok.version>1.18.8</lombok.version>
<spring-data-neo4j.version>5.3.3.RELEASE</spring-data-neo4j.version>
<spring-boot-starter.version>2.3.3.RELEASE</spring-boot-starter.version>
<spring-boot-starter-test.version>2.3.3.RELEASE</spring-boot-starter-test.version>
I am running embedded neo4j on spring-boot application. It's working fine when running in local. I am not able to connect to database from client server and I am getting this error when server is running on docker container:
Connection to the database terminated. Please ensure that your database is listening on the correct host and port and that you have compatible encryption settings both on Neo4j server and driver. Note that the default encryption setting has changed in Neo4j 4.0.
It was working fine with previous dependency tree with java 8 version. To add on , I am getting this error on neo4j desktop:
ServiceUnavailable: WebSocket connection failure. Due to security constraints in your web browser, the reason for the failure is not available to this Neo4j Driver. Please use your browsers development console to determine the root cause of the failure. Common reasons include the database being unavailable, using the wrong connection URL or temporary network problems. If you have enabled encryption, ensure your browser is configured to trust the certificate Neo4j is configured to use. WebSocket readyState is: 3
In client side this is my code snippet:
Config config = Config.builder()
.withoutEncryption()
.build();
driver = GraphDatabase.driver( uri, config );
In server module: 
DatabaseManagementService managementService = new DatabaseManagementServiceBuilder(databaseDirectory.getCanonicalFile())
.setConfig(GraphDatabaseSettings.allow_upgrade, true)
.setConfig(GraphDatabaseSettings.default_database, neo4jProperties.getDbName())
.setConfig(BoltConnector.encryption_level, BoltConnector.EncryptionLevel.DISABLED)
.setConfig(BoltConnector.enabled, true)
.setConfig(BoltConnector.listen_address,
new SocketAddress(neo4jProperties.getListeningAddress()))
.build();

Related

how to configure axon server client with remote server host? (without localhost)

I'm new to Axon server. I tried to work with Axon server with spring boot.
I installed the axon server on one of my cloud instances. when I run the spring boot application, the application finds the local Axon server. but there is no local one in my case.
I couldn't find a method to configure the IP address in the property file. if you know how to configure the remote host of the Axon server in Spring boot application please help me to do it.
The error like below,
Requesting connection details from localhost:8124
Connecting to AxonServer node [localhost:8124] failed: UNAVAILABLE: io exception
Failed to get connection to AxonServer. Scheduling a reconnect in 2000ms
Thanks.
To configure the location of Axon Server, add the following property to the application.properties file:
axon.axonserver.servers=<hostname/ip address>:<port>
If you are running Axon Server on the default port, you can omit the port number.

Is it possible to disable a Spring Boot datasource configuration based on unavailability of a connection to a DB

We have an application that uses several data sources. A DB underlying one of those data sources is down at the moment: IOError. Network adapter couldn't establish the connection & Socket read timed out.
Is there an annotation (or other means) of configuring Spring Boot such that it bypasses the culprit data source and still starts up: the DB is not essential in current development work. spring.datasource.continue-on-error=true doesn't seem to work. This is Spring 2.2.2.RELEASE.
using multiple datasource, so when your apps fail at start up your apps still work, i mean using memory db / sqlite to handle fail at connection error...

Spring boot microservices doesn't work with Intelij IDEA

I am creating a spring boot microservice project with intelij IDEA.
Currently I have developed three seperate spring boot rest services as customer service, vehicle service and spring cloud config server. Spring cloud config server is pointing to a github repository.
The issue is sometimes above projects take more than 10 minutes to run and sometimes does't run and give an error message as "failed to check application readystate intellij attached provider for the vm is not found". I have no idea why this happens ?
There are two possible causes:
1. IntelliJ IDEA and the Spring application are running in different JVMs.
There is a bug for IntelliJ IDEA regarding that:
https://youtrack.jetbrains.com/issue/IDEA-210665
Here is short summary:
IntelliJ IDEA uses local JMX connector for retrieving Spring Boot actuator endpoint's data by default. However, it could be impossible to get local JMX connector address via attach api if Spring Boot application and IntelliJ IDEA are run by different JVMs. In this case, add the following lines to VM options of your Spring Boot run configuration:
-Dcom.sun.management.jmxremote.port={some_port}
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
As mentioned in the official Oracle documentation, this configuration is insecure. Any remote user who knows (or guesses) your port number and host name will be able to monitor and control your Java applications and platform.
2. Prolonged time to retrieve local hostname
You can check that time using inetTester. Normally it should take only several milliseconds to complete. If it takes a long time then you can add the hostname returned by inetTester to /etc/hosts file like this:
127.0.0.1 localhost winsky
::1 localhost winsky

spring boot startup failure if mongo host not reachable

I have Spring boot mongo db app, when i start running this application if mongo host is alive, am able to see the my app is up and running successfully,
if my mongo host is down when i start my application my app failed to start.
is there any way even thought if mongo host is down my application should be up and running.
could someone please help me on this?
am using spring boot mongo properties in my application
spring.data.mongodb.repositories.enabled=true
spring.data.mongodb.port=27017
spring.data.mongodb.database=db
spring.data.mongodb.uri=mongodb://mongo-node-1.ballu/db
have same problem with spring boot kafka also.
Sorry for the previous comment. It was for excluding auto config beans, anyway
Is there any way even though if mongo host is down my application
should be up and running.
Yes,
spring.datasource.continue-on-error=true #Whether to stop if an error occurs while initializing the database.
as per spring doc
By default, Spring Boot enables the fail-fast feature of the Spring
JDBC initializer. This means that, if the scripts cause exceptions,
the application fails to start. You can tune that behavior by setting
spring.datasource.continue-on-error.
and as of spring kafka try this(i'm not sure if this meets your requirement)
spring.kafka.admin.fail-fast=true # Whether to fail fast if the broker is not available on startup.

HSQL Server Issue with jdbc

I have HSQL server 2.3.4 and I am trying to use hsql jdbc connectivity jar 2.2.9 to aceess the HSQL database but I am getting End of file exception.
The Servr is working pretty fine when I am using hsql jdbc connectivity jar 2.3.4 with hSQL Server 2.3.4.
Can somebody explain the reason for no backward compatibility
New features are introduced in each new version of the database engine. Sometimes the addition of new features requires changes to the network protocol used for exchanging data between the client and server. These changes break backward compatibility.
It is recommended to use jars of the same version on client and server.

Resources