spring data neo4j无法将事务标记为仅回滚

时间:2015-04-07 06:15:23

标签: neo4j spring-data-neo4j

我使用存储库来查询,但我抛出异常,我使用spring-data-neo4j-3.2.2

org.neo4j.graphdb.TransactionFailureException: Failed to mark transaction as rollback only. at       org.neo4j.kernel.TopLevelTransaction.markAsRollbackOnly(TopLevelTransaction.java:97) ~[neo4j-kernel-2.1.5.jar:2.1.5]
at org.neo4j.kernel.TopLevelTransaction.failure(TopLevelTransaction.java:86) ~[neo4j-kernel-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.spi.v2_1.TransactionBoundQueryContext.close(TransactionBoundQueryContext.scala:65) ~[neo4j-cypher-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.spi.DelegatingQueryContext.close(DelegatingQueryContext.scala:38) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext.org$neo4j$cypher$internal$compiler$v2_1$spi$ExceptionTranslatingQueryContext$$super$close(ExceptionTranslatingQueryContext.scala:34) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext$$anonfun$close$1.apply$mcV$sp(ExceptionTranslatingQueryContext.scala:34) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext$$anonfun$close$1.apply(ExceptionTranslatingQueryContext.scala:34) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext$$anonfun$close$1.apply(ExceptionTranslatingQueryContext.scala:34) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext.org$neo4j$cypher$internal$compiler$v2_1$spi$ExceptionTranslatingQueryContext$$translateException(ExceptionTranslatingQueryContext.scala:152) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.spi.ExceptionTranslatingQueryContext.close(ExceptionTranslatingQueryContext.scala:34) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.spi.DelegatingQueryContext.close(DelegatingQueryContext.scala:38) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionWorkflowBuilder$$anonfun$runWithQueryState$1.apply(ExecutionPlanBuilder.scala:164) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionWorkflowBuilder$$anonfun$runWithQueryState$1.apply(ExecutionPlanBuilder.scala:164) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.TaskCloser$$anonfun$1.apply(TaskCloser.scala:43) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.TaskCloser$$anonfun$1.apply(TaskCloser.scala:41) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251) ~[scala-library-2.10.4.jar:na]
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251) ~[scala-library-2.10.4.jar:na]
at scala.collection.immutable.List.foreach(List.scala:318) ~[scala-library-2.10.4.jar:na]
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:251) ~[scala-library-2.10.4.jar:na]
at scala.collection.AbstractTraversable.flatMap(Traversable.scala:105) ~[scala-library-2.10.4.jar:na]
at org.neo4j.cypher.internal.compiler.v2_1.TaskCloser.close(TaskCloser.scala:40) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$close$1.apply$mcV$sp(ClosingIterator.scala:67) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$close$1.apply(ClosingIterator.scala:67) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$close$1.apply(ClosingIterator.scala:67) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$translateException$1.apply(ClosingIterator.scala:72) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.decoratedCypherException(ClosingIterator.scala:102) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.translateException(ClosingIterator.scala:70) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.close(ClosingIterator.scala:66) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator$$anonfun$failIfThrows$1.apply(ClosingIterator.scala:96) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.decoratedCypherException(ClosingIterator.scala:102) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.failIfThrows(ClosingIterator.scala:91) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.ClosingIterator.hasNext(ClosingIterator.scala:34) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.cypher.internal.compiler.v2_1.PipeExecutionResult.hasNext(PipeExecutionResult.scala:167) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:327) ~[scala-library-2.10.4.jar:na]
at scala.collection.convert.Wrappers$IteratorWrapper.hasNext(Wrappers.scala:29) ~[scala-library-2.10.4.jar:na]
at org.neo4j.cypher.internal.compiler.v2_1.PipeExecutionResult$$anon$1.hasNext(PipeExecutionResult.scala:75) ~[neo4j-cypher-compiler-2.1-2.1.5.jar:2.1.5]
at org.neo4j.helpers.collection.IteratorWrapper.hasNext(IteratorWrapper.java:42) ~[neo4j-kernel-2.1.5.jar:2.1.5]
at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:380) ~[neo4j-kernel-2.1.5.jar:2.1.5]
at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:461) ~[neo4j-kernel-2.1.5.jar:2.1.5]
at org.neo4j.helpers.collection.IteratorUtil.asCollection(IteratorUtil.java:560) ~[neo4j-kernel-2.1.5.jar:2.1.5]
at com.oberon.fm.controller.MovieController.findMovies(MovieController.java:79) ~[MovieController.class:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_05]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_05]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_05]
at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_05]
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:177) ~[spring-web-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:446) ~[spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:434) ~[spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) ~[spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) ~[spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:618) [servlet-api.jar:na]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) [spring-webmvc-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) [servlet-api.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) [catalina.jar:8.0.15]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.15]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-websocket.jar:8.0.15]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.15]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.15]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) [spring-web-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.1.5.RELEASE.jar:4.1.5.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) [catalina.jar:8.0.15]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:8.0.15]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) [catalina.jar:8.0.15]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [catalina.jar:8.0.15]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) [catalina.jar:8.0.15]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) [catalina.jar:8.0.15]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [catalina.jar:8.0.15]
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610) [catalina.jar:8.0.15]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [catalina.jar:8.0.15]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537) [catalina.jar:8.0.15]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085) [tomcat-coyote.jar:8.0.15]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658) [tomcat-coyote.jar:8.0.15]
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222) [tomcat-coyote.jar:8.0.15]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556) [tomcat-coyote.jar:8.0.15]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513) [tomcat-coyote.jar:8.0.15]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_05]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_05]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-util.jar:8.0.15]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_05]
Caused by: java.lang.NullPointerException: null
at   org.neo4j.kernel.TopLevelTransaction.markAsRollbackOnly(TopLevelTransaction.java:93) ~[neo4j-kernel-2.1.5.jar:2.1.5]
... 80 common frames omitted

我的资料库

package com.oberon.fm.repository;
public interface MovieRepository extends GraphRepository<Movie> {
Movie findById(String id);
 @Query("MATCH (movie:Movie) WHERE movie.title =~ '(?i).*{0}.*' RETURN movie")
Iterable<Movie> findByTitleLike(String title);
@Query("start user=node({0}) " + " match user-[r:RATED]->movie<-[r2:RATED]-other-[r3:RATED]->otherMovie "
        + " where r.stars >= 3 and r2.stars >= r.stars and r3.stars >= r.stars "
        + " return otherMovie, avg(r3.stars) as rating, count(*) as cnt" + " order by rating desc, cnt desc"
        + " limit 10")
List<MovieRecommendation> getRecommendations(User user);

} 我的控制器

 @RequestMapping(value = "/movies", method = RequestMethod.GET, headers = "Accept=text/html")
    public String findMovies(Model model, @RequestParam("q") String query) {
        if (query != null && !query.isEmpty()) {
            //Page<Movie> movies = movieRepository.findByTitleLike(query, new PageRequest(0, 20));
            Iterable<Movie> movies = movieRepository.findByTitleLike(query);
            log.debug("===== query result ======" + movies);
            model.addAttribute("movies", IteratorUtil.asCollection(movies));
        } else {
            model.addAttribute("movies", Collections.emptyList());
        }
        model.addAttribute("query", query);
        //addUser(model);
        return "/movies/list";
    }

我的电影实体

@NodeEntity
public class Movie {
@GraphId
Long nodeId;

@Indexed(indexType = IndexType.FULLTEXT, indexName = "id")
String id;

@Indexed(indexType = IndexType.FULLTEXT, indexName = "search")
String title;

哪里错了?我需要服务来调用存储库,我尝试使用@Transactional,但它也不能正常工作。谢谢你的帮助,如果你有一些想法,请告诉我!“

 09:49:36.895 [http-nio-8080-exec-2] DEBUG      o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'context' processing GET request for [/Web/movies]
09:49:36.901 [http-nio-8080-exec-2] DEBUG o.s.w.s.m.a.DefaultAnnotationHandlerMapping - Mapping [/movies] to HandlerExecutionChain with handler [com.oberon.fm.controller.MovieController@14591b7] and 1 interceptor
09:49:36.904 [http-nio-8080-exec-2] DEBUG o.s.web.servlet.DispatcherServlet - Last-Modified value for [/Web/movies] is: -1
09:49:36.927 [http-nio-8080-exec-2] DEBUG o.s.w.b.a.s.HandlerMethodInvoker - Invoking request handler method: public java.lang.String com.oberon.fm.controller.MovieController.findMovies(org.springframework.ui.Model,java.lang.String)

09:49:36.938 [http-nio-8080-exec-2] DEBUG o.s.t.jta.JtaTransactionManager - Creating new transaction with name [null]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT
09:49:36.942 [http-nio-8080-exec-2] DEBUG o.s.d.n.s.q.CypherQueryEngineImpl - Executing cypher query: MATCH (movie:Movie) WHERE movie.title =~ '(?i).*{0}.*' RETURN movie params {0=sky}
09:49:37.006 [http-nio-8080-exec-2] DEBUG o.s.t.jta.JtaTransactionManager - Initiating transaction commit
09:49:37.007 [http-nio-8080-exec-2] DEBUG c.o.fm.controller.MovieController - ===== query  result======org.springframework.data.neo4j.conversion.QueryResultBuilder@10c2631
09:49:37.036 [http-nio-8080-exec-2] DEBUG o.s.w.s.m.a.AnnotationMethodHandlerExceptionResolver - Resolving exception from handler [com.oberon.fm.controller.MovieController@14591b7]: org.neo4j.graphdb.TransactionFailureException: Failed to mark transaction as rollback only.
09:49:37.039 [http-nio-8080-exec-2] DEBUG o.s.w.s.m.a.ResponseStatusExceptionResolver - Resolving exception from handler [com.oberon.fm.controller.MovieController@14591b7]: org.neo4j.graphdb.TransactionFailureException: Failed to mark transaction as rollback only.
09:49:37.039 [http-nio-8080-exec-2] DEBUG o.s.w.s.m.s.DefaultHandlerExceptionResolver - Resolving exception from handler [com.oberon.fm.controller.MovieController@14591b7]: org.neo4j.graphdb.TransactionFailureException: Failed to mark transaction as rollback only.
09:49:37.047 [http-nio-8080-exec-2] DEBUG o.s.web.servlet.DispatcherServlet - Could not complete request

这是我的日志,当我调用电影?q =天空,(我有三部电影天空,sky1,sky2,我想搜索天空它显示所有三个),我在调用cypher后添加了一个log.debug excute cypher,它retunrn org.springframework.data.neo4j.conversion.QueryResultBuilder @ 10c2631,这是问题吗?

0 个答案:

没有答案