我正在使用mint 17.2并拥有neo4j 3.06 Comunity Edition它在localhost:7474上正常运行。
我希望使用Eclipse Mars 2在Java 1.08中编程,但我无法使用它。
我正在使用maven项目并在我的pom.xml中有以下内容
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.geekcap.informit</groupId>
<artifactId>neo4j-sample-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>neo4j-sample-app</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies>
</project>
我的app.java文件中有以下内容
package com.geekcap.informit.neo4j_sample_app;
import org.neo4j.driver.v1.*;
public class App
{
public static void main( String[] args )
{
Driver driver = GraphDatabase.driver("bolt://localhost:7474", AuthTokens.basic("neo4j", "neo4j"));
Session session = driver.session();
session.run("CREATE (a:Person {name:'Arthur', title:'King'})" );
StatementResult result =
session.run("Match (a:Person) WHERE a.name = 'Arthur' RETURN a.name AS name, a.title AS title");
while (result.hasNext()) {
Record record = result.next();
System.out.println(record.get("title").asString() + " " +
record.get("name").asString());
}
session.close();
driver.close();
}
当我尝试将其作为java应用程序运行时,出现以下错误。
Exception in thread "main" org.neo4j.driver.v1.exceptions.ClientException: Unable to process request: Unrecognized SSL message, plaintext connection?
at org.neo4j.driver.internal.connector.socket.SocketClient.start(SocketClient.java:87)
at org.neo4j.driver.internal.connector.socket.SocketConnection.<init>(SocketConnection.java:63)
at org.neo4j.driver.internal.connector.socket.SocketConnector.connect(SocketConnector.java:52)
at org.neo4j.driver.internal.pool.InternalConnectionPool$1.allocate(InternalConnectionPool.java:191)
at org.neo4j.driver.internal.pool.InternalConnectionPool$1.allocate(InternalConnectionPool.java:180)
at org.neo4j.driver.internal.pool.ThreadCachingPool.allocate(ThreadCachingPool.java:212)
at org.neo4j.driver.internal.pool.ThreadCachingPool.acquireFromGlobal(ThreadCachingPool.java:164)
at org.neo4j.driver.internal.pool.ThreadCachingPool.acquire(ThreadCachingPool.java:118)
at org.neo4j.driver.internal.pool.InternalConnectionPool.acquire(InternalConnectionPool.java:109)
at org.neo4j.driver.internal.InternalDriver.session(InternalDriver.java:53)
at com.geekcap.informit.neo4j_sample_app.App.main(App.java:12)
Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at sun.security.ssl.EngineInputRecord.bytesInCompletePacket(EngineInputRecord.java:156)
at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:868)
at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
at org.neo4j.driver.internal.connector.socket.TLSSocketChannel.unwrap(TLSSocketChannel.java:186)
at org.neo4j.driver.internal.connector.socket.TLSSocketChannel.runHandshake(TLSSocketChannel.java:127)
at org.neo4j.driver.internal.connector.socket.TLSSocketChannel.<init>(TLSSocketChannel.java:95)
at org.neo4j.driver.internal.connector.socket.TLSSocketChannel.<init>(TLSSocketChannel.java:77)
at org.neo4j.driver.internal.connector.socket.TLSSocketChannel.<init>(TLSSocketChannel.java:70)
at org.neo4j.driver.internal.connector.socket.SocketClient$ChannelFactory.create(SocketClient.java:235)
at org.neo4j.driver.internal.connector.socket.SocketClient.start(SocketClient.java:74)
... 10 more
答案 0 :(得分:10)
7474
端口是HTTP端口。由于您使用的是bolt://
协议,因此您应该连接到7687
端口。或者实际上删除端口,因为它是默认值:
Driver driver = GraphDatabase.driver("bolt://localhost", AuthTokens.basic("neo4j", "neo4j"));
通过在conf/neo4j.conf
中取消注释(删除前面的#
),确保Bolt协议在Neo4j实例上实际处于活动状态:
dbms.connector.bolt.address=0.0.0.0:7687
或至少限制本地连接:
dbms.connector.bolt.address=127.0.0.1:7687
答案 1 :(得分:0)
SSL错误表明客户端期望加密通道,但服务器未加密(因此异常堆栈跟踪中的纯文本连接消息)。
查看Neo4j手册,您可能需要查看以下部分,了解如何为加密或&#39;明文&#39;
配置客户端和/或服务器。您可以通过在neo4j.conf中设置以下内容来禁用螺栓通道上的SSL(显然不建议在生产中使用,但对于诊断这是否是您的问题很有用):
dbms.connector.bolt.tls_level=DISABLED
然后重启你的neo4j实例