2016-07-29 2 views
0

Neo4j 데이터베이스를 포함하여 Spring MVC (4.2.0.RELEASE)로 Java Rest Service를 개발 중입니다. 따라서 Spring Data Neo4j (4.1.1.RELEASE)가 사용됩니다.Tomcat에 여러 버전을 배포 할 때 Neo4j NullPointerException이 발생했습니다.

SDN 구성은 다음과 같습니다

@Configuration 
@ComponentScan(basePackages = { "com.xxx.yyy" }) 
@EnableNeo4jRepositories(basePackages = "com.xxx.yyy.dao.repo") 
@EnableTransactionManagement 
public class Neo4jConfig extends Neo4jConfiguration { 

    @Autowired 
    private ApplicationProperties properties; 

    @Bean 
    public SessionFactory getSessionFactory() { 
     return new SessionFactory(getConfiguration(), "com.xxx.yyy.dao.beans"); 
    } 

    @Bean 
    public Neo4jOperations neo4jTemplate() throws Exception { 
     return new Neo4jTemplate(getSession()); 
    } 

    @Bean 
    public org.neo4j.ogm.config.Configuration getConfiguration() { 
     org.neo4j.ogm.config.Configuration config = new org.neo4j.ogm.config.Configuration(); 

     config.driverConfiguration().setDriverClassName(this.properties.getNeo4jDriver()) 
       .setURI(this.properties.getNeo4jEndpoint()) 
       .setCredentials(this.properties.getNeo4jUser(), this.properties.getNeo4jPassword()); 

     return config; 
    } 

    @Bean 
    @Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS) 
    public Session getSession() throws Exception { 
     return super.getSession(); 
    } 

} 

응용 프로그램은 생산 환경에서 Tomcat7에 배포됩니다. 응용 프로그램이 하나만 배포되고 버전 플래그가 채워져 있지 않은 경우 모든 기능이 매력적입니다.

중단 시간 배포가 필요없는 경우 tomcat에서 버전 플래그를 사용하여 여러 버전을 배포하고 싶습니다. 그렇게하면 org.neo4j.ogm.context.RestModelMapper에있는 NullPointerException 때문에 응용 프로그램이 더 이상 작동하지 않습니다.

스택 트레이스 :

java.lang.NullPointerException 
    at org.neo4j.ogm.context.RestModelMapper.mapEntity(RestModelMapper.java:153) ~[neo4j-ogm-core-2.0.1.jar:?] 
    at org.neo4j.ogm.context.RestModelMapper.map(RestModelMapper.java:76) ~[neo4j-ogm-core-2.0.1.jar:?] 
    at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:94) ~[neo4j-ogm-core-2.0.1.jar:?] 
    at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:73) ~[neo4j-ogm-core-2.0.1.jar:?] 
    at org.neo4j.ogm.session.Neo4jSession.query(Neo4jSession.java:313) ~[neo4j-ogm-core-2.0.1.jar:?] 

이 문제는 내가 바람둥이에 버전 플래그를 사용하는 경우에만 발생합니다. anyboby는 여기서 문제가 무엇인지 압니까?

답변

0

마지막으로 OGM HTTP 드라이버 및 Spring Data Neo4j 종속성의 버전을 변경하여이 문제를 해결했습니다.

<dependency> 
    <groupId>org.springframework.data</groupId> 
    <artifactId>spring-data-neo4j</artifactId> 
    <version>4.1.4.RELEASE</version> 
</dependency> 

<dependency> 
    <groupId>org.neo4j</groupId> 
    <artifactId>neo4j-ogm-http-driver</artifactId> 
    <version>2.0.5</version> 
</dependency> 

이 설정을 사용하면 Tomcat 버전 플래그 https://tomcat.apache.org/tomcat-7.0-doc/config/context.html이있는 배포가 작동합니다.

관련 문제