未知持久性实体错误
Unknown persistence entity error
我目前在生产中使用 SDN 3.0.1,但我想受益于 SDN 3.3.0 的最新改进(参见:http://jexp.de/blog/2014/12/spring-data-neo4j-improving-remoting-performance/)。为此,我必须将我的 grails 项目(使用 Spring 3)迁移到最新的 grails 版本(使用 spring boot 和 Spring 4)。
但它没有按预期工作。我在尝试从 Neo4J 2.1.8 服务器获取数据时遇到此错误:
Unknown persistent entity com.motards.nous.server.v1.dao.repository.relationship.domain.Ride. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0]
at java.lang.Thread.run(Thread.java:744) [na:1.8.0]
Caused by: org.springframework.data.mapping.model.MappingException: Unknown persistent entity com.motards.nous.server.v1.dao.repository.relationship.domain.Ride
at org.neo4j.helpers.collection.IterableWrapper$MyIteratorWrapper.underlyingObjectToObject(IterableWrapper.java:57) ~[neo4j-kernel-2.1.7.jar:2.1.7]
at org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47) ~[neo4j-kernel-2.1.7.jar:2.1.7]
at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:382) ~[neo4j-kernel-2.1.7.jar:2.1.7]
at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:461) ~[neo4j-kernel-2.1.7.jar:2.1.7]
at com.motards.nous.server.v1.RideService.$tt__getAllPublicRides(RideService.groovy:54) ~[main/:na]
at grails.transaction.GrailsTransactionTemplate.doInTransaction(GrailsTransactionTemplate.groovy:93) ~[grails-core-3.0.2.jar:3.0.2]
at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:90) ~[grails-core-3.0.2.jar:3.0.2]
at com.motards.nous.server.v1.PublicRideController.index(PublicRideController.groovy:29) ~[main/:na]
... 3 common frames omitted
这是我的 Neo4J 配置:
@Configuration
@EnableNeo4jRepositories(basePackages = "com.motards.nous.server.v1.dao", repositoryImplementationPostfix = "Repository")
static class MyNeo4jConfiguration extends Neo4jConfiguration {
MyNeo4jConfiguration() {
setBasePackage("com.motards.nous.server.v1.dao")
}
@Bean
GraphDatabaseService graphDatabaseService() {
return new SpringCypherRestGraphDatabase("http://neo4j:7474/db/data")
}
@Bean
Neo4jMappingContext neo4jMappingContext() {
return new Neo4jMappingContext()
}
}
我错过了什么吗?
-- 编辑--
这是我在将实体与存储库分开后更新的配置。
@Configuration
@EnableNeo4jRepositories(basePackages = "com.nousmotards.core.repositories.neo4j", repositoryImplementationPostfix = "Repository")
class MyNeo4jConfiguration extends Neo4jConfiguration {
@Resource
Environment environment
MyNeo4jConfiguration() {
setBasePackage("com.nousmotards.core.domains.neo4j")
}
@Bean
GraphDatabaseService graphDatabaseService() {
return new SpringCypherRestGraphDatabase("http://${environment.getProperty("nm.neo4j.host")}:${environment.getProperty("nm.neo4j.port")}/db/data")
}
}
这是我得到的完整堆栈跟踪:
https://gist.github.com/evoxmusic/615ac940186ec97d2e89
-- 编辑 2 --
当我添加
@Bean
Neo4jMappingContext neo4jMappingContext() {
return new Neo4jMappingContext()
}
应用程序正常启动,但是当我尝试查询 neo4j 实体时出现此错误:
2015-06-25 15:54:31.418 ERROR 42902 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.mapping.model.MappingException: Unknown persistent entity com.nousmotards.core.domains.neo4j.MyRootNode] with root cause
org.springframework.data.mapping.model.MappingException: Unknown persistent entity com.nousmotards.core.domains.neo4j.MyRootNode
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:177)
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:140)
at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.cacheType(Neo4jMappingContext.java:173)
at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.isNodeEntity(Neo4jMappingContext.java:167)
at org.springframework.data.neo4j.support.Neo4jTemplate.isNodeEntity(Neo4jTemplate.java:340)
at org.springframework.data.neo4j.support.conversion.EntityResultConverter.doConvert(EntityResultConverter.java:72)
at org.springframework.data.neo4j.conversion.DefaultConverter.convert(DefaultConverter.java:44)
at org.springframework.data.neo4j.support.conversion.EntityResultConverter.convert(EntityResultConverter.java:165)
at org.springframework.data.neo4j.conversion.QueryResultBuilder.underlyingObjectToObject(QueryResultBuilder.java:86)
at org.neo4j.helpers.collection.IterableWrapper$MyIteratorWrapper.underlyingObjectToObject(IterableWrapper.java:57)
at org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47)
at org.neo4j.helpers.collection.IteratorUtil.single(IteratorUtil.java:335)
at org.neo4j.helpers.collection.IteratorUtil.singleOrNull(IteratorUtil.java:128)
at org.neo4j.helpers.collection.IteratorUtil.singleOrNull(IteratorUtil.java:286)
at org.springframework.data.neo4j.conversion.QueryResultBuilder.singleOrNull(QueryResultBuilder.java:69)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:120)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.doWithGraph(GraphRepositoryQuery.java:90)
at org.springframework.data.neo4j.support.Neo4jTemplate.doExecute(Neo4jTemplate.java:465)
at org.springframework.data.neo4j.support.Neo4jTemplate.access[=14=]0(Neo4jTemplate.java:87)
at org.springframework.data.neo4j.support.Neo4jTemplate.doInTransaction(Neo4jTemplate.java:479)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.springframework.data.neo4j.support.Neo4jTemplate.exec(Neo4jTemplate.java:476)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:84)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:393)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:371)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy121.findNodeByUUID(Unknown Source)
at com.nousmotards.core.repositories.neo4j.MyRootNodeRepository$findNodeByUUID.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.nousmotards.core.services.MyService$_doCacheWithRedisByUUID_closure11.doCall(MyService.groovy:233)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:73)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.nousmotards.core.services.RedisService.withRedis(RedisService.groovy:21)
at com.nousmotards.core.services.RedisService$withRedis.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.nousmotards.core.services.MyService.doCacheWithRedisByUUID(MyService.groovy:230)
at com.nousmotards.core.services.RiderService.doCacheWithRedisByUUID(RiderService.groovy)
at com.nousmotards.core.services.MyService$doCacheWithRedisByUUID.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at com.nousmotards.core.services.MyService.getFromRedisByUUID(MyService.groovy:273)
at com.nousmotards.core.services.RiderService.getFromRedisByUUID(RiderService.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1206)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1120)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1015)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1151)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1120)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1015)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at com.nousmotards.core.services.MyService$_closure2.doCall(MyService.groovy:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1206)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1120)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1015)
at groovy.lang.Closure.call(Closure.java:423)
at com.nousmotards.core.services.MyService$_closure2.call(MyService.groovy)
at org.codehaus.groovy.runtime.metaclass.ClosureStaticMetaMethod.invoke(ClosureStaticMetaMethod.java:59)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:148)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.nousmotards.core.services.RiderService.get(RiderService.groovy:40)
at com.nousmotards.core.services.RiderService$get.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.nousmotards.core.controllers.TestController.show(TestController.groovy:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextHeaderFilter.doFilterInternal(EndpointWebMvcAutoConfiguration.java:295)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:85)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:57)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:102)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:68)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:744)
这是我的 "MyRootNode" 实体
@NodeEntity
abstract class MyRootNode implements RestPowered, Cacheable, NotificationObservable {
// internal id for Neo4J
@GraphId
Long id
// exposed API id
@Indexed(unique = true)
Long uuid = Math.abs(UUID.randomUUID().getMostSignificantBits())
@Indexed(indexType = IndexType.SIMPLE, indexName = MyIndexNames.NODE_CREATED_DATE)
Date createdDate = new Date()
@Fetch
@RelatedToVia(type = MyRelationshipTypes.IS_NOTIFICATION_OBSERVER, direction = Direction.INCOMING)
Set<IsNotificationObserver> notificationObservers
@Transient
Class<?> doLoadClass(final String name) {
this.getClass().getClassLoader().loadClass(name)
}
@Transient
String getType() {
getClass().name.split("\.")[-1]
}
@Transient
Map getShortPropertiesMap() {
if (id) {
final MyRootNode rootNode = this.class.getRedis(id)
return [
type : type,
id : rootNode.uuid,
id_str : rootNode.uuid.toString(),
displayed_name : rootNode.displayedName,
displayed_photo: rootNode.displayedPhoto
]
}
return [
type : type,
id : uuid,
id_str : uuid.toString(),
displayed_name : displayedName,
displayed_photo: displayedPhoto
]
}
@Override
Map<Object, Object> getPropertiesMap() {
if (id) {
final MyRootNode rootNode = this.class.getRedis(id)
return [
type : type,
id : rootNode.uuid,
id_str : rootNode.uuid.toString(),
created_date : rootNode.createdDate,
displayed_name : rootNode.displayedName,
displayed_photo: rootNode.displayedPhoto
]
}
return [
type : type,
id : uuid,
id_str : uuid.toString(),
created_date : createdDate,
displayed_name : displayedName,
displayed_photo: displayedPhoto
]
}
@Override
void setPropertiesMap(final Map map) {
this.propertiesMap = map
}
@Transient
Map<Object, Object> getPublicPropertiesMap() {
[
type : type,
id : uuid,
id_str : uuid.toString(),
created_date : createdDate,
displayed_name : displayedName,
displayed_photo: displayedPhoto
]
}
@Transient
Map<Object, Object> getElasticsearchPropertiesMap() {
propertiesMap
}
@Override
Map<Object, Object> getCacheablePropertiesMap() {
[
type : getClass().name,
id : id,
uuid : uuid,
createdDate : createdDate.time,
notificationObservers: notificationObservers.collect { it.id }
]
}
@Override
Object buildFromCacheableJsonString(String jsonString) {
final def j = new JsonSlurper().parseText(jsonString)
id = j.id as Long
uuid = j.uuid as Long
createdDate = new Date(j.createdDate as Long)
notificationObservers = j.notificationObservers.collect {
// a bit dirty but made its job !
try {
IsNotificationObserver?.getRedis(it)
} catch (Exception e) {
null
}
} - null
return this
}
}
所以我发现了问题..很奇怪Spring Data Neo4J...
我必须将所有 "Map" 对象更改为 "HashMap" 之类的具体对象,它现在可以工作了。
似乎是一个错误...
我目前在生产中使用 SDN 3.0.1,但我想受益于 SDN 3.3.0 的最新改进(参见:http://jexp.de/blog/2014/12/spring-data-neo4j-improving-remoting-performance/)。为此,我必须将我的 grails 项目(使用 Spring 3)迁移到最新的 grails 版本(使用 spring boot 和 Spring 4)。
但它没有按预期工作。我在尝试从 Neo4J 2.1.8 服务器获取数据时遇到此错误:
Unknown persistent entity com.motards.nous.server.v1.dao.repository.relationship.domain.Ride. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0]
at java.lang.Thread.run(Thread.java:744) [na:1.8.0]
Caused by: org.springframework.data.mapping.model.MappingException: Unknown persistent entity com.motards.nous.server.v1.dao.repository.relationship.domain.Ride
at org.neo4j.helpers.collection.IterableWrapper$MyIteratorWrapper.underlyingObjectToObject(IterableWrapper.java:57) ~[neo4j-kernel-2.1.7.jar:2.1.7]
at org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47) ~[neo4j-kernel-2.1.7.jar:2.1.7]
at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:382) ~[neo4j-kernel-2.1.7.jar:2.1.7]
at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:461) ~[neo4j-kernel-2.1.7.jar:2.1.7]
at com.motards.nous.server.v1.RideService.$tt__getAllPublicRides(RideService.groovy:54) ~[main/:na]
at grails.transaction.GrailsTransactionTemplate.doInTransaction(GrailsTransactionTemplate.groovy:93) ~[grails-core-3.0.2.jar:3.0.2]
at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:90) ~[grails-core-3.0.2.jar:3.0.2]
at com.motards.nous.server.v1.PublicRideController.index(PublicRideController.groovy:29) ~[main/:na]
... 3 common frames omitted
这是我的 Neo4J 配置:
@Configuration
@EnableNeo4jRepositories(basePackages = "com.motards.nous.server.v1.dao", repositoryImplementationPostfix = "Repository")
static class MyNeo4jConfiguration extends Neo4jConfiguration {
MyNeo4jConfiguration() {
setBasePackage("com.motards.nous.server.v1.dao")
}
@Bean
GraphDatabaseService graphDatabaseService() {
return new SpringCypherRestGraphDatabase("http://neo4j:7474/db/data")
}
@Bean
Neo4jMappingContext neo4jMappingContext() {
return new Neo4jMappingContext()
}
}
我错过了什么吗?
-- 编辑--
这是我在将实体与存储库分开后更新的配置。
@Configuration
@EnableNeo4jRepositories(basePackages = "com.nousmotards.core.repositories.neo4j", repositoryImplementationPostfix = "Repository")
class MyNeo4jConfiguration extends Neo4jConfiguration {
@Resource
Environment environment
MyNeo4jConfiguration() {
setBasePackage("com.nousmotards.core.domains.neo4j")
}
@Bean
GraphDatabaseService graphDatabaseService() {
return new SpringCypherRestGraphDatabase("http://${environment.getProperty("nm.neo4j.host")}:${environment.getProperty("nm.neo4j.port")}/db/data")
}
}
这是我得到的完整堆栈跟踪: https://gist.github.com/evoxmusic/615ac940186ec97d2e89
-- 编辑 2 --
当我添加
@Bean
Neo4jMappingContext neo4jMappingContext() {
return new Neo4jMappingContext()
}
应用程序正常启动,但是当我尝试查询 neo4j 实体时出现此错误:
2015-06-25 15:54:31.418 ERROR 42902 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.mapping.model.MappingException: Unknown persistent entity com.nousmotards.core.domains.neo4j.MyRootNode] with root cause
org.springframework.data.mapping.model.MappingException: Unknown persistent entity com.nousmotards.core.domains.neo4j.MyRootNode
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:177)
at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:140)
at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.cacheType(Neo4jMappingContext.java:173)
at org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.isNodeEntity(Neo4jMappingContext.java:167)
at org.springframework.data.neo4j.support.Neo4jTemplate.isNodeEntity(Neo4jTemplate.java:340)
at org.springframework.data.neo4j.support.conversion.EntityResultConverter.doConvert(EntityResultConverter.java:72)
at org.springframework.data.neo4j.conversion.DefaultConverter.convert(DefaultConverter.java:44)
at org.springframework.data.neo4j.support.conversion.EntityResultConverter.convert(EntityResultConverter.java:165)
at org.springframework.data.neo4j.conversion.QueryResultBuilder.underlyingObjectToObject(QueryResultBuilder.java:86)
at org.neo4j.helpers.collection.IterableWrapper$MyIteratorWrapper.underlyingObjectToObject(IterableWrapper.java:57)
at org.neo4j.helpers.collection.IteratorWrapper.next(IteratorWrapper.java:47)
at org.neo4j.helpers.collection.IteratorUtil.single(IteratorUtil.java:335)
at org.neo4j.helpers.collection.IteratorUtil.singleOrNull(IteratorUtil.java:128)
at org.neo4j.helpers.collection.IteratorUtil.singleOrNull(IteratorUtil.java:286)
at org.springframework.data.neo4j.conversion.QueryResultBuilder.singleOrNull(QueryResultBuilder.java:69)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:120)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.doWithGraph(GraphRepositoryQuery.java:90)
at org.springframework.data.neo4j.support.Neo4jTemplate.doExecute(Neo4jTemplate.java:465)
at org.springframework.data.neo4j.support.Neo4jTemplate.access[=14=]0(Neo4jTemplate.java:87)
at org.springframework.data.neo4j.support.Neo4jTemplate.doInTransaction(Neo4jTemplate.java:479)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.springframework.data.neo4j.support.Neo4jTemplate.exec(Neo4jTemplate.java:476)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:84)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:393)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:371)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy121.findNodeByUUID(Unknown Source)
at com.nousmotards.core.repositories.neo4j.MyRootNodeRepository$findNodeByUUID.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.nousmotards.core.services.MyService$_doCacheWithRedisByUUID_closure11.doCall(MyService.groovy:233)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:73)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.nousmotards.core.services.RedisService.withRedis(RedisService.groovy:21)
at com.nousmotards.core.services.RedisService$withRedis.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.nousmotards.core.services.MyService.doCacheWithRedisByUUID(MyService.groovy:230)
at com.nousmotards.core.services.RiderService.doCacheWithRedisByUUID(RiderService.groovy)
at com.nousmotards.core.services.MyService$doCacheWithRedisByUUID.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at com.nousmotards.core.services.MyService.getFromRedisByUUID(MyService.groovy:273)
at com.nousmotards.core.services.RiderService.getFromRedisByUUID(RiderService.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1206)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1120)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1015)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1151)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1120)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1015)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at com.nousmotards.core.services.MyService$_closure2.doCall(MyService.groovy:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1206)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1120)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1015)
at groovy.lang.Closure.call(Closure.java:423)
at com.nousmotards.core.services.MyService$_closure2.call(MyService.groovy)
at org.codehaus.groovy.runtime.metaclass.ClosureStaticMetaMethod.invoke(ClosureStaticMetaMethod.java:59)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:148)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.nousmotards.core.services.RiderService.get(RiderService.groovy:40)
at com.nousmotards.core.services.RiderService$get.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.nousmotards.core.controllers.TestController.show(TestController.groovy:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfiguration$ApplicationContextHeaderFilter.doFilterInternal(EndpointWebMvcAutoConfiguration.java:295)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:85)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:57)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:102)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:85)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.boot.actuate.autoconfigure.MetricsFilter.doFilterInternal(MetricsFilter.java:68)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:744)
这是我的 "MyRootNode" 实体
@NodeEntity
abstract class MyRootNode implements RestPowered, Cacheable, NotificationObservable {
// internal id for Neo4J
@GraphId
Long id
// exposed API id
@Indexed(unique = true)
Long uuid = Math.abs(UUID.randomUUID().getMostSignificantBits())
@Indexed(indexType = IndexType.SIMPLE, indexName = MyIndexNames.NODE_CREATED_DATE)
Date createdDate = new Date()
@Fetch
@RelatedToVia(type = MyRelationshipTypes.IS_NOTIFICATION_OBSERVER, direction = Direction.INCOMING)
Set<IsNotificationObserver> notificationObservers
@Transient
Class<?> doLoadClass(final String name) {
this.getClass().getClassLoader().loadClass(name)
}
@Transient
String getType() {
getClass().name.split("\.")[-1]
}
@Transient
Map getShortPropertiesMap() {
if (id) {
final MyRootNode rootNode = this.class.getRedis(id)
return [
type : type,
id : rootNode.uuid,
id_str : rootNode.uuid.toString(),
displayed_name : rootNode.displayedName,
displayed_photo: rootNode.displayedPhoto
]
}
return [
type : type,
id : uuid,
id_str : uuid.toString(),
displayed_name : displayedName,
displayed_photo: displayedPhoto
]
}
@Override
Map<Object, Object> getPropertiesMap() {
if (id) {
final MyRootNode rootNode = this.class.getRedis(id)
return [
type : type,
id : rootNode.uuid,
id_str : rootNode.uuid.toString(),
created_date : rootNode.createdDate,
displayed_name : rootNode.displayedName,
displayed_photo: rootNode.displayedPhoto
]
}
return [
type : type,
id : uuid,
id_str : uuid.toString(),
created_date : createdDate,
displayed_name : displayedName,
displayed_photo: displayedPhoto
]
}
@Override
void setPropertiesMap(final Map map) {
this.propertiesMap = map
}
@Transient
Map<Object, Object> getPublicPropertiesMap() {
[
type : type,
id : uuid,
id_str : uuid.toString(),
created_date : createdDate,
displayed_name : displayedName,
displayed_photo: displayedPhoto
]
}
@Transient
Map<Object, Object> getElasticsearchPropertiesMap() {
propertiesMap
}
@Override
Map<Object, Object> getCacheablePropertiesMap() {
[
type : getClass().name,
id : id,
uuid : uuid,
createdDate : createdDate.time,
notificationObservers: notificationObservers.collect { it.id }
]
}
@Override
Object buildFromCacheableJsonString(String jsonString) {
final def j = new JsonSlurper().parseText(jsonString)
id = j.id as Long
uuid = j.uuid as Long
createdDate = new Date(j.createdDate as Long)
notificationObservers = j.notificationObservers.collect {
// a bit dirty but made its job !
try {
IsNotificationObserver?.getRedis(it)
} catch (Exception e) {
null
}
} - null
return this
}
}
所以我发现了问题..很奇怪Spring Data Neo4J... 我必须将所有 "Map" 对象更改为 "HashMap" 之类的具体对象,它现在可以工作了。
似乎是一个错误...