I am running neo4j-community-2.2.5 locally on my macbook. I am trying to connect to the code using the neo4j-ogm version : 1.1.2
Here is the session factory:
public class Neo4jSessionFactory {
private final static SessionFactory sessionFactory = new SessionFactory("com.readypulse.rpinfluencernetwork.ogm.model");
private static Neo4jSessionFactory factory = new Neo4jSessionFactory();
public static Neo4jSessionFactory getInstance() {
return factory;
}
private Neo4jSessionFactory() {
}
public Session getNeo4jSession() {
return sessionFactory.openSession("http://localhost:7474", "neo4j", "mypassword");
}
}
I have a entity class :
@NodeEntity(label="Hashtag")
public class Hashtag extends Entity {
@Property(name = "name")
String name;
...
Service :
public interface HashtagService extends Service<Hashtag>{
}
Generic Service:
public abstract class GenericService<T> implements Service<T> {
private static final int DEPTH_LIST = 0;
private static final int DEPTH_ENTITY = 1;
private Session session = Neo4jSessionFactory.getInstance().getNeo4jSession();
public Iterable<T> findAll() {
return session.loadAll(getEntityType(), DEPTH_LIST);
}
public T find(Long id) {
return session.load(getEntityType(), id, DEPTH_ENTITY);
}
public void delete(Long id) {
session.delete(session.load(getEntityType(), id));
}
public void createOrUpdate(T entity) {
session.save(entity, DEPTH_ENTITY);
}
public abstract Class<T> getEntityType();
}
Calling code :
public static void main(String args[]) {
Hashtag hashtag = new Hashtag("fun");
HashtagService service = new HashtagServiceImpl();
service.createOrUpdate(hashtag);
}
I am running the code on eclipse as simple java process, and not on any Application server.
Here is the full log with trace:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/lazywiz/.m2/repository/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/lazywiz/.m2/repository/org/slf4j/slf4j-jdk14/1.5.11/slf4j-jdk14-1.5.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/lazywiz/.m2/repository/ch/qos/logback/logback-classic/1.1.2/logback-classic-1.1.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
15/10/09 14:55:16 INFO info.ClassFileProcessor: Starting Post-processing phase
15/10/09 14:55:16 INFO info.ClassFileProcessor: Building annotation class map
15/10/09 14:55:16 INFO info.ClassFileProcessor: Building interface class map for 9 classes
15/10/09 14:55:16 INFO info.ClassFileProcessor: Registering default type converters...
15/10/09 14:55:16 INFO info.ClassFileProcessor: Post-processing complete
15/10/09 14:55:16 INFO info.ClassFileProcessor: 9 classes loaded in 16 milliseconds
15/10/09 14:55:17 WARN request.DefaultRequest: Caught response exception: No Host
Exception in thread "main" org.neo4j.ogm.session.result.ResultProcessingException: Failed to execute request: {"statements":[{"statement":"CREATE (_0:`Hashtag`{_0_props}) RETURN id(_0) AS _0","parameters":{"_0_props":{"name":"varun"}},"resultDataContents":["row"],"includeStats":false}]}
at org.neo4j.ogm.session.request.DefaultRequest.execute(DefaultRequest.java:105)
at org.neo4j.ogm.session.request.SessionRequestHandler.execute(SessionRequestHandler.java:99)
at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:68)
at org.neo4j.ogm.session.Neo4jSession.save(Neo4jSession.java:391)
at com.readypulse.rpinfluencernetwork.ogm.service.GenericService.createOrUpdate(GenericService.java:26)
at com.readypulse.rpinfluencernetwork.GraphManager.main(GraphManager.java:16)
Caused by: org.apache.http.client.HttpResponseException: No Host
at org.neo4j.ogm.session.request.DefaultRequest.execute(DefaultRequest.java:86)
... 5 more
Can someone please suggest where I am going wrong. Prior to this I was having a totally different code base where I was using
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath); and
But later I realized that this is not the right way when I want to connect to the neo4j server running in prod environment. I want to start the server and hence connect is via java and Ruby client concurrently.
Thanks!