Indrajit Singh
Indrajit Singh

Reputation: 31

Getting following error "org.neo4j.kernel.api.exceptions.TransactionFailureException: Transaction rolled back even if marked as successful" at neo4j

Wrote stored proc in neo4j and then added it in the neo4j plugins. When calling the stored proc getting the error"

org.neo4j.kernel.api.exceptions.TransactionFailureException: Transaction rolled back even if marked as successful

Below are some information regarding how I am doing.

@Procedure("example.search12")
public Stream<SearchHit> searchData(
    @Name("phoneNumber") String phoneNumber, 
    @Name("searchText") String searchText) throws InterruptedException, ExecutionException {

    List<SearchHit> resultList = new ArrayList<>();
    try {
        Node startNode = getStartNode(phoneNumber);
        if(null == startNode){
            System.out.println("Phone Number not found::"+ phoneNumber);
            return null;
        }
        final Set<Node> results = new LinkedHashSet<>();
        innerSeacrh(db, startNode, searchText, 1,results);
        List<Node> nodes = new ArrayList<Node>();

        for (Node node : results) {
            System.out.println(node.getProperty("fullname"));
            nodes.add(node);
            resultList.add(new SearchHit(node));
        }
    } catch(Exception ex) {
        ex.printStackTrace();
    }

    return resultList.stream();
}

public static class SearchHit {
    // This records contain a single field named 'nodeId'
    public long nodeId;

    public SearchHit(Node node) {
        this.nodeId = node.getId();
    }
}

I am calling the stored proc by below command:

call example.search12("919818131043","anu");

Getting below error.

org.neo4j.kernel.api.exceptions.TransactionFailureException: Transaction rolled back even if marked as successful

Please help i need to resolve it as soon as possible.

Upvotes: 1

Views: 586

Answers (1)

Indrajit Singh
Indrajit Singh

Reputation: 31

I have solved this issue. Actually when we hit the stored proc it implicitly opens a transaction so if you try to open another transaction in the same thread. it gives problems.

Upvotes: 1

Related Questions