5

I am trying to save an entity using Hibernate and Jersey.

The JSON that I try to send is:

{
"firstname":"Jon",
"middlename":"J",
"lastname":"Smith",
"dob":"10-10-1990",
"gender":"male"
}

When I send it with Postman, I get Status: 200 OK but the record is not saved in the database.

The database that I am using is Neo4j.

Here is my PersonDAO class:

package com.Neo4jRestAPI;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;

import org.hibernate.HibernateException;

import com.google.gson.Gson;

public class PersonDAO {

    public void addPerson(Person person){

        try {
            EntityManagerFactory emf = Persistence.createEntityManagerFactory("persistence");
            EntityManager em = emf.createEntityManager();
            EntityTransaction tx = em.getTransaction();
            tx.begin();

            Person p = new Person();

            p.setFirstname(person.getFirstname());
            p.setMiddlename(person.getMiddlename());
            p.setLastname(person.getLastname());
            p.setDob(person.getDob());
            p.setGender(person.getGender());

            em.persist(p);
            em.flush();     
            tx.commit();
            em.clear(); 
            em.close(); 
            emf.close();
            }
        catch ( Exception e ) {
            e.printStackTrace();
        }
    }
}

This is how I try to send the data:

@POST
@Path("/person")
@Consumes("application/json")
public Response addPerson(Person person){

     person.setFirstname(person.getFirstname());
     person.setMiddlename(person.getMiddlename());
     person.setLastname(person.getLastname());
     person.setDob(person.getDob());
     person.setGender(person.getGender());

     PersonDAO dao = new PersonDAO();

     dao.addPerson(person);

     return Response.ok().build();
}

Does anyone know what I am doing wrong here?

EDIT

I was able to save an entity using native query but that way, the id is not automatically generated. I am still unable to save an entity with the way described above

When I remove the @GeneratedValue and specify the id in the JSON, then I am able to save the entity, so I assume the problem is there. I have tried several strategies but none of them worked.

This is how I try to auto-generate the id:

@Entity
@Table(name="Person")
public class Person {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long id;

Also, when I print the method getId(), I get the auto-incremented value.

Here is the Cypher query that has been executed:

"{"statements":[{"statement":"CREATE (n:ENTITY:Person {props}) RETURN n","parameters":{"props":{"firstname":"Jon","gender":"male","dob":"10-10-1990","middlename":"J","id":99,"lastname":"Smith"}},"includeStats":false,"resultDataContents":["graph"]}]}"

I am also getting a transaction rollback error but it does not say why it has been rolled back:

"Neo.ClientError.Transaction.TransactionNotFound","message":"Unrecognized transaction id. Transaction may have timed out and been rolled back

Here is my persistence.xml file

<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
         version="2.0">

<persistence-unit name="persistence">
    <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
    <properties>
        <property name="hibernate.ogm.datastore.provider" value="neo4j_http"/>
        <property name="hibernate.ogm.neo4j.database_path" value="C://path//to//database"/>
        <property name="hibernate.ogm.datastore.host" value="localhost:7474"/>
        <property name="hibernate.ogm.datastore.username" value="neo4j"/>
        <property name="hibernate.ogm.datastore.password" value="root"/>
    </properties>
  </persistence-unit>
  </persistence>

EDIT

This is the stack trace that I am getting:

log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 

When I use log4j and add BasicConfiguratior.configure(), I get the following (it is quite big to post the whole log here, so I just posted a part of it where the error is thrown):

2342 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  >> "{"statements":[{"statement":"CREATE (n:ENTITY:Person {props}) RETURN n","parameters":{"props":{"firstname":"Anna","gender":"female","dob":"10-10-1990","middlename":"J","id":57,"lastname":"Smith"}},"includeStats":false,"resultDataContents":["graph"]}]}"
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "HTTP/1.1 200 OK[\r][\n]"
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "Date: Tue, 03 Oct 2017 09:01:10 GMT[\r][\n]"
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "Content-Type: application/json[\r][\n]"
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "Access-Control-Allow-Origin: *[\r][\n]"
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "Content-Length: 372[\r][\n]"
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "Server: Jetty(9.2.z-SNAPSHOT)[\r][\n]"
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "[\r][\n]"
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.impl.conn.DefaultClientConnection  - Receiving response: HTTP/1.1 200 OK
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - << HTTP/1.1 200 OK
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - << Date: Tue, 03 Oct 2017 09:01:10 GMT
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - << Content-Type: application/json
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - << Access-Control-Allow-Origin: *
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - << Content-Length: 372
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - << Server: Jetty(9.2.z-SNAPSHOT)
2345 [http-nio-8080-exec-4] DEBUG org.apache.http.impl.client.DefaultHttpClient  - Connection can be kept alive indefinitely
2346 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "{"commit":"http://localhost:7474/db/data/transaction/53/commit","results":[{"columns":["n"],"data":[{"graph":{"nodes":[{"id":"10","labels":["ENTITY","Person"],"properties":{"firstname":"Anna","gender":"female","dob":"10-10-1990","middlename":"J","id":57,"lastname":"Smith"}}],"relationships":[]}}]}],"transaction":{"expires":"Tue, 03 Oct 2017 09:02:10 +0000"},"errors":[]}"
2346 [http-nio-8080-exec-4] DEBUG org.apache.http.impl.conn.PoolingClientConnectionManager  - Connection [id: 1][route: {}->http://localhost:7474] can be kept alive indefinitely
2346 [http-nio-8080-exec-4] DEBUG org.apache.http.impl.conn.PoolingClientConnectionManager  - Connection released: [id: 1][route: {}->http://localhost:7474][total kept alive: 1; route allocated: 2 of 10; total allocated: 2 of 10]
2350 [http-nio-8080-exec-4] DEBUG org.hibernate.engine.transaction.internal.TransactionImpl  - committing
2350 [http-nio-8080-exec-4] DEBUG org.hibernate.event.internal.AbstractFlushingEventListener  - Processing flush-time cascades
2350 [http-nio-8080-exec-4] DEBUG org.hibernate.event.internal.AbstractFlushingEventListener  - Dirty checking collections
2350 [http-nio-8080-exec-4] DEBUG org.hibernate.event.internal.AbstractFlushingEventListener  - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
2350 [http-nio-8080-exec-4] DEBUG org.hibernate.event.internal.AbstractFlushingEventListener  - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2350 [http-nio-8080-exec-4] DEBUG org.hibernate.internal.util.EntityPrinter  - Listing entities:
2350 [http-nio-8080-exec-4] DEBUG org.hibernate.internal.util.EntityPrinter  - com.Neo4jRestAPI.Person{firstname=Anna, gender=female, relationship_type=null, dob=10-10-1990, middlename=J, id=57, relationship=null, lastname=Smith}
2350 [http-nio-8080-exec-4] DEBUG org.apache.http.impl.conn.PoolingClientConnectionManager  - Connection request: [route: {}->http://localhost:7474][total kept alive: 1; route allocated: 2 of 10; total allocated: 2 of 10]
2350 [http-nio-8080-exec-4] DEBUG org.apache.http.impl.conn.PoolingClientConnectionManager  - Connection leased: [id: 1][route: {}->http://localhost:7474][total kept alive: 0; route allocated: 2 of 10; total allocated: 2 of 10]
2350 [http-nio-8080-exec-4] DEBUG org.apache.http.impl.client.DefaultHttpClient  - Stale connection check
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.client.protocol.RequestAddCookies  - CookieSpec selected: best-match
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.client.protocol.RequestAuthCache  - Auth cache not set in the context
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.client.protocol.RequestProxyAuthentication  - Proxy auth state: UNCHALLENGED
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.impl.client.DefaultHttpClient  - Attempt 1 to execute request
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.impl.conn.DefaultClientConnection  - Sending request: POST /db/data/transaction/54/commit HTTP/1.1
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  >> "POST /db/data/transaction/54/commit HTTP/1.1[\r][\n]"
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  >> "Accept: application/json[\r][\n]"
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  >> "Accept-Encoding: gzip, deflate[\r][\n]"
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  >> "Authorization: Basic bmVvNGo6Z2VuaXZpdHk=[\r][\n]"
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  >> "X-Stream: true[\r][\n]"
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  >> "Content-Length: 0[\r][\n]"
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  >> "Host: localhost:7474[\r][\n]"
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  >> "Connection: Keep-Alive[\r][\n]"
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  >> "[\r][\n]"
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - >> POST /db/data/transaction/54/commit HTTP/1.1
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - >> Accept: application/json
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - >> Accept-Encoding: gzip, deflate
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - >> Authorization: Basic bmVvNGo6Z2VuaXZpdHk=
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - >> X-Stream: true
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - >> Content-Length: 0
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - >> Host: localhost:7474
2352 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - >> Connection: Keep-Alive
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "HTTP/1.1 404 Not Found[\r][\n]"
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "Date: Tue, 03 Oct 2017 09:01:10 GMT[\r][\n]"
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "Content-Type: application/json[\r][\n]"
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "Access-Control-Allow-Origin: *[\r][\n]"
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "Content-Length: 178[\r][\n]"
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "Server: Jetty(9.2.z-SNAPSHOT)[\r][\n]"
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "[\r][\n]"
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.impl.conn.DefaultClientConnection  - Receiving response: HTTP/1.1 404 Not Found
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - << HTTP/1.1 404 Not Found
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - << Date: Tue, 03 Oct 2017 09:01:10 GMT
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - << Content-Type: application/json
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - << Access-Control-Allow-Origin: *
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - << Content-Length: 178
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.headers  - << Server: Jetty(9.2.z-SNAPSHOT)
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.impl.client.DefaultHttpClient  - Connection can be kept alive indefinitely
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.wire  -  << "{"results":[],"errors":[{"code":"Neo.ClientError.Transaction.TransactionNotFound","message":"Unrecognized transaction id. Transaction may have timed out and been rolled back."}]}"
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.impl.conn.PoolingClientConnectionManager  - Connection [id: 1][route: {}->http://localhost:7474] can be kept alive indefinitely
2354 [http-nio-8080-exec-4] DEBUG org.apache.http.impl.conn.PoolingClientConnectionManager  - Connection released: [id: 1][route: {}->http://localhost:7474][total kept alive: 1; route allocated: 2 of 10; total allocated: 2 of 10]
2355 [http-nio-8080-exec-4] DEBUG org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl  - Initiating JDBC connection release from afterTransaction
18718 [Finalizer] DEBUG org.apache.http.wire  -  << "{"password_change_required":false,"password_change":"http://localhost:7474/user/neo4j/password","username":"neo4j"}"
18719 [Finalizer] DEBUG org.apache.http.impl.conn.PoolingClientConnectionManager  - Connection [id: 0][route: {}->http://localhost:7474] can be kept alive indefinitely
18719 [Finalizer] DEBUG org.apache.http.impl.conn.PoolingClientConnectionManager  - Connection released: [id: 0][route: {}->http://localhost:7474][total kept alive: 2; route allocated: 2 of 10; total allocated: 2 of 10]

Also, another thing that I noticed is that when I send the JSON for the first time, I get the log like above after I send it for the second time, every line gets printed twice when I send it for the third time, every line gets printed 3 times, and so on...

I am not sure what is causing that but it might be the cause of the problem

Farzad Karimi
  • 770
  • 1
  • 12
  • 31
Porjaz
  • 771
  • 1
  • 8
  • 28
  • Debug the person object in Response method and see what you are getting. – Vivek Singh Sep 27 '17 at 12:52
  • In your dao why you are creating a new Person object, you can just pass the person object from parameter and persist it. – Vivek Singh Sep 27 '17 at 12:55
  • @VivekSingh I was following this guide http://www.topjavatutorial.com/frameworks/hibernate/adding-hibernate-dao-layer-in-existing-maven-project/ and there it's done that way (with new object). I passed the `person` object from the parameter but I still get `Status: 200 OK` and the object is not saved – Porjaz Sep 27 '17 at 13:01
  • Also when I print the person's attribute like this: `System.out.println(person.getFirstname());` in the Response method, I get the `firstname` from the JSON – Porjaz Sep 27 '17 at 13:06
  • May be silly, but have you the database open and need to refresh it? – achAmháin Sep 27 '17 at 13:12
  • @pruntlar Yes I have refreshed the database and also restarted it several times. – Porjaz Sep 27 '17 at 13:15
  • Please remove the try-catch block in your DAO to get a meaningful error message/stack trace. – user3151902 Sep 27 '17 at 14:26
  • @user3151902 Thank you for the reply. I have updated my question with the error message – Porjaz Sep 27 '17 at 14:37
  • See the first part of the exception: `LockClient[6511] <-[:HELD_BY]- RWLock[SCHEMA(0), hash=110596439] <-[:WAITING_FOR]- LockClient[6495]`, which states that client 6495 is waiting for a lock held by client 6511. It seems that multiple clients are accessing the database in a way that cannot be resolved by neo4j. – user3151902 Sep 27 '17 at 14:47
  • Well try to move the 3 lines `em.clear(); em.close(); emf.close();` from the `try` block to the `finally` block of the `try..catch`, I think this will fix it. – cнŝdk Sep 27 '17 at 15:39
  • @chsdk I have moved them in the `finally` block but the error is still here. But, as I said in the post, that only happens when I send the request, then stop the request and try to resend it again. That doesn't concern me that much. What concerns me is that I am unable to save the entity to the database even though I get `Status: 200 OK` – Porjaz Sep 27 '17 at 15:53
  • @Porjaz is there any reason why you build and destroy every single time the EntityManagerFactory? Move the various clear and close ina finally block but just reuse the factory as creating it has a significant overhead... it's probably what is generating the problems and even if it's not, it's time consuming – Zeromus Sep 29 '17 at 15:28
  • @Zeromus Thank you for the tip. Unfortunately that is not the reason for the problem because I have a method for creating a relationship between two entities and that method is done the same way and I am able to save the relationship. Also as I mentioned in the post, when I remove the `@GeneratedValue` and specify the `id` in the json, the entity is saved. Same goes when I use native query to save the entity – Porjaz Sep 29 '17 at 16:06
  • There is no relation between getting HTTP code 200 and saving `Person` entity unless you check if `id` is null before sending `ok`! could you show us what query is generated by Hibernate after `tx.commit()` ? – O.Badr Sep 29 '17 at 22:41
  • You mean the only issue you are facing is that id is not generated automatically????? @Porjaz – Tahir Hussain Mir Oct 02 '17 at 09:55
  • Not really, the issue is that the entity is not saved in the database. If I print the id, I get the auto generated value, so that thing works fine. The problem is when I remove the `@GeneratedValue` annotation and specify the id in the JSON, then the entity gets saved. If I use the annotation, the entity is not saved. You can see from the log the the id gets automatically assigned. So, I am not really sure what is causing the problem – Porjaz Oct 02 '17 at 10:00
  • With neo4j the strategy in @GeneratedValue must be either table or sequence. See here: https://docs.jboss.org/hibernate/ogm/4.1/reference/en-US/html/ogm-neo4j.html#_auto_generated_values – mwhs Oct 02 '17 at 10:34
  • Do you have a constraint violation, like not null or unique ? please show us your received `Person` object in your API – Halayem Anis Oct 02 '17 at 11:18
  • @HalayemAnis these are the object's properties, printer after `em.flush`: `firstname: Jon middlename: J lastname: Smith gender: male dob: 10-10-1990 id: 6` – Porjaz Oct 02 '17 at 11:30
  • Why does your log show the id=99? Are you assigning that value in the constructor? That would not work well with `@GeneratedValue`. – yegodm Oct 02 '17 at 12:19
  • @yegodm I am not assigning the ID. It shows id=99 because I have sent the post request a lot of times and the id gets generated automatically, so eventually it got to 99 – Porjaz Oct 02 '17 at 12:22
  • Can you show us your hibernate configuration file ? your problem is that the transaction has reached the time out – Halayem Anis Oct 02 '17 at 12:25
  • @HalayemAnis I have updated my answer with the persistence.xml file but I don't think that is the problem because other operations (retrieve a person, create a relationship between two people, update a person) work fine – Porjaz Oct 02 '17 at 12:30
  • This is the only solution i can found, update your neo4j configuration file by adding/updating this configuration `dbms.transaction.timeout=60`, restart your neo4j server and retry – Halayem Anis Oct 02 '17 at 12:54
  • @HalayemAnis unfortunately, that is not the problem. I have added that to the configuration but the result is the same. Also, the transaction doesn't seem to run that long. It only takes few seconds – Porjaz Oct 02 '17 at 13:00
  • @Porjaz and have you restarted your neo4j server ? because in the official doc they say that the default transaction timeout is 0s http://neo4j.com/docs/operations-manual/current/reference/configuration-settings/#config_dbms.transaction.timeout – Halayem Anis Oct 02 '17 at 13:04
  • @HalayemAnis I have restarted the server. According to this https://neo4j.com/docs/operations-manual/current/monitoring/query-management/#transaction-timeout, the default time 0s means that it has no timeout limit – Porjaz Oct 02 '17 at 13:12
  • can you please post the exception that is being thrown? the response may be OK for the service but there is that printstacktrace output that you have not posted – Zeromus Oct 03 '17 at 07:30

4 Answers4

2

I was able to solve my problem by changing from tomcat 8.5 to wildfly 9. I am still not sure what was the problem with tomcat though, since all the other operations worked fine, just the insertion of people was causing problems.

Porjaz
  • 771
  • 1
  • 8
  • 28
0

I presume, that the problem is

@GeneratedValue(strategy = GenerationType.AUTO)

cannot find appropriate method for creating a key. I suggest trying something like this:

@SequenceGenerator(name = "sequence_generator_name", sequenceName = "sequence_name", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequence_generator_name")

to use a database sequence for creating key. If you don't use schema autoupdate, sequence must be created manually. Syntax specifics depend on your database.

Stas Shafeev
  • 606
  • 6
  • 8
  • That is not the problem. I have tried with the way you suggested but the end result is the same. In both ways, a SEQUENCE object gets created in the database and has the properties: `sequence_name` and `next_val`. So, even if I just use `@GeneratedValue(strategy = GenerationType.AUTO)`, it automatically uses the SEQUENCE strategy and creates the SEQUENCE object – Porjaz Oct 02 '17 at 12:45
  • Sorry for misleading. – Stas Shafeev Oct 02 '17 at 12:49
0

I think i found the error, change these lines:

em.persist(p);
em.flush();     
tx.commit();
em.clear(); 
em.close(); 
emf.close();

by these lines:

em.persist(p);
em.flush();
em.close();
tx.commit();
emf.close();
Halayem Anis
  • 7,654
  • 2
  • 25
  • 45
  • I changed them and unfortunately the entity is still not saved. If it's helpful, I can provide the whole code? – Porjaz Oct 02 '17 at 14:21
  • i forget `emf.close()`, try again, never give up :) – Halayem Anis Oct 02 '17 at 14:33
  • Tried that, still nothing. I assume the problem is with the auto generated id. As mentioned in the post, if I remove the annotation and specify the id myself, then the entity gets saved. Also when I use native query to save the entity (and specify the id in the query), the entity also gets saved – Porjaz Oct 02 '17 at 14:42
  • have you created a sequence in your database ? – Halayem Anis Oct 02 '17 at 14:46
  • Yes, when I use `@GeneratedValue(strategy = GenerationType.AUTO)`, the sequence gets created automatically in the database and has properties: `sequence_name` and `next_val`. So, I assume that that works fine because the log shows the query that has been executed and the generated id is also there – Porjaz Oct 02 '17 at 14:51
0

Replace this:

catch ( Exception e ) {
    e.printStackTrace();
}

with this:

catch ( Exception e ) {
    throw new RuntimeException(e);
}

The exception is not being re-thrown, so as far as your REST layer is concerned, PersonDAO.addPerson was successfull, and it will generate an OK response.

Martín Straus
  • 558
  • 4
  • 7
  • When I replace the catch block, in the stack trace in get only this: `log4j:WARN No appenders could be found for logger (org.jboss.logging). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.` – Porjaz Oct 03 '17 at 08:54
  • Well, it looks like the original problem you reported (the one about status 200) was solved with my suggestion. Now you detected another problem; you should post another question, in order not to pollute this one. – Martín Straus Oct 03 '17 at 14:16
  • Actually the problem hasn't been solved. I am still unable to save an object to the database. I am getting the same stack trace with my catch block and the one that you suggested – Porjaz Oct 03 '17 at 14:41
  • Well, you edited your question and added the other half of the problem afterwards, so... In any case, I cannot help you with Neo4j. The stack trace you added does not seem to have any error message from Neo4j, besides the one about the transaction, and that one seems to be a consequence, not a cause. You might need to add more logging, in case the root error is hidden away. – Martín Straus Oct 03 '17 at 17:03