larusba / neo4j-jdbc

Neo4j JDBC driver for Neo4j 3.x with BOLT protocol
Apache License 2.0
12 stars 10 forks source link

3.4 jdbc driver bolt+routing with causal cluster (multiple IP Addresses) #12

Closed aosle closed 5 years ago

aosle commented 5 years ago

We are currently using the 3.4 neo4j jdbc driver to connect from our tomcat application to a neo4j 3.4.0 cluster made up of 3 core nodes.

When configuring the tomcat “context.xml” file as below:

Resource name="jdbc/ipbackboneNeo4J" url="jdbc:neo4j:bolt+routing://:7687,:7687,:7687" username="***" password="****" accessToUnderlyingConnectionAllowed="true" type="javax.sql.DataSource" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" driverClassName="org.neo4j.jdbc.bolt.BoltDriver"

Tomcat fails to connect to neo4j with the error below:

18-Jan-2019 21:18:39.550 WARNING [main] org.apache.naming.NamingContext.lookup Unexpected exception resolving reference java.sql.SQLException: Driver:org.neo4j.jdbc.bolt.BoltDriver@7d76ed7f returned null for URL:jdbc:neo4j:bolt+routing://:7687,:7687,:7687

However, if instead of using bolt+routing, we connect through just bolt to just the leader (as per the configuration below), the connection is successful and all runs fine.

Resource name="jdbc/ipbackboneNeo4J" url="jdbc:neo4j:bolt://:7687" username="**" password=***** accessToUnderlyingConnectionAllowed="true" type="javax.sql.DataSource" factory="org.apache.tomcat.jdbc.pool.DataSourceFactory" driverClassName="org.neo4j.jdbc.bolt.BoltDriver"

How we need to configure bolt+routing on the context.xml file in tomcat (what do we need to change on the red text above) so our application running in Tomcat can connect to the causal cluster appropriately using the 3 IP addresses of the 3xcore nodes in our cluster (using the bolt+routing protocol)?

From the little documentation available online – it looks like it should be as above, but it does not seem to work.

Many thanks

inserpio commented 5 years ago

Hi @aosle, you've configured the Resourse with driverClassName="org.neo4j.jdbc.bolt.BoltDriver".

Can you try with org.neo4j.jdbc.boltrouting.BoltRoutingNeo4jDriver instead?

bolt+routing protocol is managed by the specific class org.neo4j.jdbc.boltrouting.BoltRoutingNeo4jDriver.

aosle commented 5 years ago

Thanks @inserpio for your quick response.

can it be an issue with the parameter driverClassName="org.neo4j.jdbc.bolt.BoltDriver" on the context.xml file? should it be set to something else then?

inserpio commented 5 years ago

indeed... just changed my above comment asking to try with org.neo4j.jdbc.boltrouting.BoltRoutingNeo4jDriver instaed

aosle commented 5 years ago

Thank you very much @inserpio . That has resolved the issue and now I can connect to the causal cluster using the bolt+routing protocol against multiple IP Addresses and properly provide High Availability.

inserpio commented 5 years ago

Cool!