Spring Data Neo4j 4,独立Tomcat 8.5并且无法实例化[org.neo4j.ogm.session.SessionFactory]异常

时间:2017-02-03 13:30:28

标签: eclipse spring spring-boot spring-data-neo4j-4

我已将Spring Data Neo4j 4个应用程序移植到Spring Boot 1.5.1。在Embedded Tomcat 8.5.11,一切正常但在Standalone Tomcat 8.5.11失败,但有以下异常:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/example/domain/api/configuration/Neo4jConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
    ... 117 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
    ... 126 common frames omitted
Caused by: java.lang.NullPointerException: null
    at org.neo4j.ogm.metadata.DomainInfo.registerDefaultMethodConverters(DomainInfo.java:379)
    at org.neo4j.ogm.metadata.DomainInfo.postProcessMethods(DomainInfo.java:215)
    at org.neo4j.ogm.metadata.DomainInfo.finish(DomainInfo.java:159)
    at org.neo4j.ogm.scanner.ClassPathScanner.scan(ClassPathScanner.java:148)
    at org.neo4j.ogm.metadata.DomainInfo.load(DomainInfo.java:338)
    at org.neo4j.ogm.metadata.DomainInfo.<init>(DomainInfo.java:62)
    at org.neo4j.ogm.MetaData.<init>(MetaData.java:48)
    at org.neo4j.ogm.session.SessionFactory.<init>(SessionFactory.java:62)
    at com.example.domain.api.configuration.Neo4jConfig.sessionFactory(Neo4jConfig.java:26)
    at com.example.domain.api.configuration.Neo4jConfig$$EnhancerBySpringCGLIB$$59f65b77.CGLIB$sessionFactory$0(<generated>)
    at com.example.domain.api.configuration.Neo4jConfig$$EnhancerBySpringCGLIB$$59f65b77$$FastClassBySpringCGLIB$$f50f6aaa.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
    at com.example.domain.api.configuration.Neo4jConfig$$EnhancerBySpringCGLIB$$59f65b77.sessionFactory(<generated>)
    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:498)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    ... 127 common frames omitted

这是我的Neo4Config:

@Configuration
@EnableNeo4jRepositories(basePackages = "com.example.domain.repository")
@EnableTransactionManagement
public class Neo4jConfig {

    final static Logger logger = LoggerFactory.getLogger(Neo4jConfig.class);

    @Bean
    public Neo4jTransactionManager transactionManager() throws Exception {
        return new Neo4jTransactionManager(sessionFactory());
    }

    @Bean
    public SessionFactory sessionFactory() {
        return new SessionFactory("com.example.domain.model");
    }

}

这可能是什么原因以及如何解决?

已更新

看起来这是Eclipse增量构建问题。从控制台(通过Maven命令)一切正常。

0 个答案:

没有答案