1

By using findAll() from GraphRepository<Account>:

    context = new ClassPathXmlApplicationContext("spring/spring-config.xml");
    accountService = (AccountService) context.getBean("accountService");

    //getAll(){return accountRepository.findAll()}

    accountService.getAll().forEach(account -> System.out.println(account));

(btw. all other functions from my accountService works)

I getting this error:

 Exception in thread "main" org.neo4j.graphdb.TransactionFailureException: 
 Failed to mark transaction as rollback only.

I try to fix the problem with: Spring Data Neo4J repository findAll() results in a nullpointerexception , so i add <tx:annotation-driven mode="proxy"/> in my spring-config.xml but it doesn't fix my problem.

here my github repo: https://github.com/mzober/springContextWorld/tree/CollectorManager_ErrorBranch

Here my spring-config.xml:

 <beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation=
           "http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context.xsd
   http://www.springframework.org/schema/data/neo4j
    http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd">
<context:annotation-config/>
<context:spring-configured/>

<context:component-scan base-package="com.mz.springContextWorld.domain"/>
<context:component-scan base-package="com.mz.springContextWorld.repositories"/>
<context:component-scan base-package="com.mz.springContextWorld.gui.listener"/>
<context:component-scan base-package="com.mz.springContextWorld.gui.components"/>
<context:component-scan base-package="com.mz.springContextWorld.gui.creational"/>
<context:component-scan base-package="com.mz.springContextWorld.services"/>

<neo4j:config storeDirectory="target/neo4j-db-plain"
              base-package="com.mz.springContextWorld.domain"/>
<neo4j:repositories base-package="com.mz.springContextWorld.repositories"/>

<tx:annotation-driven mode="proxy"/>

If i should post more code pls write a comment.

ty for helping.

Community
  • 1
  • 1
mzober
  • 91
  • 7

1 Answers1

0

This is probably related to the issue: https://jira.spring.io/browse/DATAGRAPH-531. If that's the case, you need to change

service.findAll()

to:

service.findAll().as(Collection.class)

... and the rollback exception should go away.