如何诊断这个neo4j-ogm / mvn spring-boot:run问题?

时间:2015-09-24 19:15:36

标签: maven spring-boot maven-plugin neo4j-ogm

我希望有人可以建议我可以用来诊断这个的策略。我认为这可能是spring-boot maven插件中的一个错误。

我正在使用neo4j-ogm进行持久性的应用程序。

当我在eclipse中启动它或作为可执行jar时,应用程序启动并运行正常。

当我使用mvn spring-boot:run启动它时,它不起作用并抛出以下堆栈跟踪。

关于spring-boot maven插件可能做错的任何指针?

21:05:56.553 [nz.co.********.console.main.Application.main()] INFO  o.s.b.a.l.AutoConfigurationReportLoggingInitializer -

Error starting ApplicationContext. To display the auto-configuration report enable debug logging (start with --debug)


21:05:56.602 [nz.co.********.console.main.Application.main()] ERROR o.s.boot.SpringApplication - Application startup failed
java.lang.IllegalStateException: Failed to execute CommandLineRunner
        at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:676) ~[spring-boot-1.2.6.RELEASE.jar:1.2.6.RELEASE]
        at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:691) ~[spring-boot-1.2.6.RELEASE.jar:1.2.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) ~[spring-boot-1.2.6.RELEASE.jar:1.2.6.RELEASE]
        at nz.co.********.console.main.Application.main(Application.java:15) [classes/:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25]
        at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
        at org.springframework.boot.maven.RunMojo$LaunchRunner.run(RunMojo.java:418) [spring-boot-maven-plugin-1.2.6.RELEASE.jar:1.2.6.RELEASE]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]
Caused by: java.lang.NullPointerException: null
        at org.neo4j.ogm.session.response.SessionResponseHandler.lookup(SessionResponseHandler.java:158) ~[neo4j-ogm-1.1.2.jar:na]
        at org.neo4j.ogm.session.response.SessionResponseHandler.loadById(SessionResponseHandler.java:152) ~[neo4j-ogm-1.1.2.jar:na]
        at org.neo4j.ogm.session.delegates.LoadOneDelegate.load(LoadOneDelegate.java:45) ~[neo4j-ogm-1.1.2.jar:na]
        at org.neo4j.ogm.session.Neo4jSession.load(Neo4jSession.java:104) ~[neo4j-ogm-1.1.2.jar:na]
        at nz.co.********.core.MemberAccountService.loadMemberByEmailAddressPasswordAccount(MemberAccountService.java:126) ~[********-core-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at nz.co.********.console.menu.Menu.login(Menu.java:33) ~[classes/:na]
        at nz.co.********.console.menu.Menu.login(Menu.java:95) ~[classes/:na]
        at nz.co.********.console.menu.MainMenu.processUserInput(MainMenu.java:110) ~[classes/:na]
        at nz.co.********.console.menu.Menu.processUserInput(Menu.java:79) ~[classes/:na]
        at nz.co.********.console.main.ConsoleUI.run(ConsoleUI.java:65) ~[classes/:na]
        at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:673) ~[spring-boot-1.2.6.RELEASE.jar:1.2.6.RELEASE]
        ... 9 common frames omitted
21:05:56.604 [nz.co.********.console.main.Application.main()] INFO  o.s.c.a.AnnotationConfigApplicationContext - Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@327b0992: startup date [Thu Sep 24 21:05:40 CEST 2015]; root of context hierarchy
21:05:56.642 [nz.co.********.console.main.Application.main()] INFO  o.s.j.e.a.AnnotationMBeanExporter - Unregistering JMX-exposed beans on shutdown
[WARNING]
java.lang.reflect.InvocationTargetException
        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.springframework.boot.maven.RunMojo$LaunchRunner.run(RunMojo.java:418)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Failed to execute CommandLineRunner
        at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:676)
        at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:691)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:322)
        at nz.co.********.console.main.Application.main(Application.java:15)
        ... 6 more
Caused by: java.lang.NullPointerException
        at org.neo4j.ogm.session.response.SessionResponseHandler.lookup(SessionResponseHandler.java:158)
        at org.neo4j.ogm.session.response.SessionResponseHandler.loadById(SessionResponseHandler.java:152)
        at org.neo4j.ogm.session.delegates.LoadOneDelegate.load(LoadOneDelegate.java:45)
        at org.neo4j.ogm.session.Neo4jSession.load(Neo4jSession.java:104)
        at nz.co.********.core.MemberAccountService.loadMemberByEmailAddressPasswordAccount(MemberAccountService.java:126)
        at nz.co.********.console.menu.Menu.login(Menu.java:33)
        at nz.co.********.console.menu.Menu.login(Menu.java:95)
        at nz.co.********.console.menu.MainMenu.processUserInput(MainMenu.java:110)
        at nz.co.********.console.menu.Menu.processUserInput(Menu.java:79)
        at nz.co.********.console.main.ConsoleUI.run(ConsoleUI.java:65)
        at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:673)
        ... 9 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.938 s
[INFO] Finished at: 2015-09-24T21:05:56+01:00
[INFO] Final Memory: 34M/594M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.2.6.RELEASE:run (default-cli) on project ********-console: An exception occured while running. null: InvocationTargetException: Failed to execute CommandLineRunner: NullPointerException -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

其他信息

从可执行jar开始打印出来:

16:50:54.854 [main] INFO  o.n.o.m.info.ClassFileProcessor - 34 classes loaded in 1927 milliseconds 

mvn spring-boot:run打印出来:

17:02:02.250 [nz.co.********.console.main.Application.main()] INFO  o.n.o.m.info.ClassFileProcessor - 0 classes loaded in 3 milliseconds

会话工厂代码

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;

@Component
public class Neo4jSessionFactory implements FactoryBean<Session> {

    private final static SessionFactory sessionFactory = new SessionFactory("nz.co.*****.pojos");

    @Inject private CoreProperties config;

    private Logger logger = Logger.getLogger(this.getClass);

    @Override
    public Session getObject() {
        return sessionFactory.openSession(config.getHost(), config.getUsername(), config.getPassword());
    }

    @Override
    public Class<?> getObjectType() {
        return Session.class;
    }

    @Override
    public boolean isSingleton() {
        return false;
    }

    @PostConstruct
    public void printInfo() { 
        logger.info("DbLocation: " + config.getHost());
    }
}

1 个答案:

答案 0 :(得分:1)

失败的代码(fixed curl figure)是第158行 `

u =Y.*X.^2+3*Y.^2;

` 这意味着typeInfo或typeInfo.annotationsInfo()都为null,仅在从Maven运行的情况下。

假设其他条件相同,155 private <T> T lookup(Class<T> type, Long id) { 156 Object ref; 157 ClassInfo typeInfo = metaData.classInfo(type.getName()); 158 if (typeInfo.annotationsInfo().get(RelationshipEntity.CLASS) == null) { 159 ref = mappingContext.getNodeEntity(id); 160 } else { 161 ref = mappingContext.getRelationshipEntity(id); 162 } 163 try { 164 return type.cast(ref); 165 } 166 catch (ClassCastException cce) { 167 return null; 168 } 必须使用与eclipse不同的类路径。按照输出中的建议尝试mvn spring-boot:run。首先检查classpath,查找jar版本的差异以及Eclipse正在拾取的顺序与mvn --debug -e -X spring-boot:run正在拾取的内容。