要启动服务器,我在执行以下操作:
graphDb = (GraphDatabaseAPI) new GraphDatabaseFactory() .newEmbeddedDatabaseBuilder(CONF_DBMeta_LOCATION) .setConfig(ShellSettings.remote_shell_enabled,"true") .newGraphDatabase(); ServerConfigurator config; config = new ServerConfigurator(graphDb); // let the server endpoint be on a custom port srv = new WrappingNeoServerBootstrapper(graphDb,config); srv.start();
不幸的是,我得到:
> java.lang.RuntimeException: > org.neo4j.kernel.lifecycle.LifecycleException: Component > 'org.neo4j.kernel.logging.LogbackService@4c043845' Failed to > initialize. Please see attached cause exception.
我已经尝试从添加了neo4j-server的Build.scala中删除slf4j和logback依赖关系,但无济于事.看来,neo4j正在加载错误的logback.xml.此外,如果我将notTransitive()添加到neo4j服务器依赖项,则启动时的logback.xml警告将消失.我想象,neo4j特定的logback.xml嵌入在jar中并导致问题.我看到的一个潜在解决方案是通过代码编写自定义配置,但我不确定如何做到这一点.有什么想法吗?作为参考,我在启动时收到以下错误:
> 22:11:05,124 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find > resource [logback.groovy] > 22:11:05,125 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find > resource [logback-test.xml] > 22:11:05,125 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource > [logback.xml] at > [jar:file:/Users/steve/Code/play-2.1-RC1/repository/local/play/play_2.10/2.1-RC1/jars/play_2.10.jar!/logback.xml] > 22:11:05,126 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] > occurs multiple times on the classpath. > 22:11:05,126 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] > occurs at > [jar:file:/Users/steve/Code/play-2.1-RC1/framework/../repository/cache/org.neo4j.app/neo4j-server/jars/neo4j-server-1.9-SNAPSHOT.jar!/logback.xml] > 22:11:05,126 |-WARN in ch.qos.logback.classic.LoggerContext[default] - Resource [logback.xml] > occurs at > [jar:file:/Users/steve/Code/play-2.1-RC1/repository/local/play/play_2.10/2.1-RC1/jars/play_2.10.jar!/logback.xml] > 22:11:05,139 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@733b8bc1 - URL > [jar:file:/Users/steve/Code/play-2.1-RC1/repository/local/play/play_2.10/2.1-RC1/jars/play_2.10.jar!/logback.xml] > is not of type file > 22:11:05,265 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug > attribute not set > 22:11:05,614 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate > appender of type [ch.qos.logback.core.ConsoleAppender] > 22:11:05,625 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as > [STDOUT] > 22:11:05,657 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming > default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for > [encoder] property > 22:11:05,707 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level > of ROOT logger to ERROR > 22:11:05,707 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching > appender named [STDOUT] to Logger[ROOT] > 22:11:05,707 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of > configuration. > 22:11:05,709 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@4a546701 - Registering > current configuration as safe fallback point
完整例外情况见下文:
> play.api.UnexpectedException: Unexpected exception[RuntimeException: > org.neo4j.kernel.lifecycle.LifecycleException: Component > 'org.neo4j.kernel.logging.LogbackService@4c043845' Failed to > initialize. Please see attached cause exception.] at > play.core.ReloadableApplication$$anonfun$get$1$$anonfun$1.apply(ApplicationProvider.scala:134) > ~[play_2.10.jar:2.1-RC1] at > play.core.ReloadableApplication$$anonfun$get$1$$anonfun$1.apply(ApplicationProvider.scala:101) > ~[play_2.10.jar:2.1-RC1] at scala.Option.map(Option.scala:145) > ~[scala-library.jar:na] at > play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:101) > ~[play_2.10.jar:2.1-RC1] at > play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:99) > ~[play_2.10.jar:2.1-RC1] at > scala.util.Either$RightProjection.flatMap(Either.scala:523) > [scala-library.jar:na] Caused by: java.lang.RuntimeException: > org.neo4j.kernel.lifecycle.LifecycleException: Component > 'org.neo4j.kernel.logging.LogbackService@4c043845' Failed to > initialize. Please see attached cause exception. at > org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:258) > ~[neo4j-kernel-1.9.M03.jar:na] at > org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:88) > ~[neo4j-kernel-1.9.M03.jar:na] at > org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:83) > ~[neo4j-kernel-1.9.M03.jar:1.9.M03] at > org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:206) > ~[neo4j-kernel-1.9.M03.jar:1.9.M03] at > EmbeddedGraphDB.initializeDatabase(EmbeddedGraphDB.java:70) > ~[na:na] at > EmbeddedGraphDB.<init>(EmbeddedGraphDB.java:51) > ~[na:na] Caused by: org.neo4j.kernel.lifecycle.LifecycleException: > Component 'org.neo4j.kernel.logging.LogbackService@4c043845' Failed to > initialize. Please see attached cause exception. at > org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.init(LifeSupport.java:471) > ~[neo4j-kernel-1.9.M03.jar:1.9.M03] at > org.neo4j.kernel.lifecycle.LifeSupport.init(LifeSupport.java:62) > ~[neo4j-kernel-1.9.M03.jar:1.9.M03] at > org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:96) > ~[neo4j-kernel-1.9.M03.jar:1.9.M03] at > org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:245) > ~[neo4j-kernel-1.9.M03.jar:na] at > org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:88) > ~[neo4j-kernel-1.9.M03.jar:na] at > org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:83) > ~[neo4j-kernel-1.9.M03.jar:1.9.M03] Caused by: > org.neo4j.kernel.lifecycle.LifecycleException: Component > 'org.neo4j.kernel.logging.LogbackService$1@1955bd61' was successfully > initialized,but Failed to start. Please see attached cause exception. > at > org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:495) > ~[neo4j-kernel-1.9.M03.jar:1.9.M03] at > org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:105) > ~[neo4j-kernel-1.9.M03.jar:1.9.M03] at > org.neo4j.kernel.logging.LogbackService.init(LogbackService.java:106) > ~[neo4j-kernel-1.9.M03.jar:1.9.M03] at > org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.init(LifeSupport.java:465) > ~[neo4j-kernel-1.9.M03.jar:1.9.M03] at > org.neo4j.kernel.lifecycle.LifeSupport.init(LifeSupport.java:62) > ~[neo4j-kernel-1.9.M03.jar:1.9.M03] at > org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:96) > ~[neo4j-kernel-1.9.M03.jar:1.9.M03] Caused by: > java.lang.NoSuchMethodError: > org.codehaus.janino.ClassBodyEvaluator.setImplementedInterfaces([Ljava/lang/Class;)V > at > ch.qos.logback.core.joran.conditional.PropertyEvalScriptBuilder.build(PropertyEvalScriptBuilder.java:48) > ~[logback-core.jar:na] at > ch.qos.logback.core.joran.conditional.IfAction.begin(IfAction.java:67) > ~[logback-core.jar:na] at > ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:276) > ~[logback-core.jar:na] at > ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:148) > ~[logback-core.jar:na] at > ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:130) > ~[logback-core.jar:na] at > ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50) > ~[logback-core.jar:na]
EDIT1更多细节
我从play_2.10.jar中删除了logback.xml文件,并且在播放应用程序启动时不再收到来自logback的重复警告.
然后,我尝试将neo4j logback.xml和play2.1 logback.xml的内容放在我的播放项目根目录下的custom-logback.xml中.与Play.application()相同的路径path()也许这是neo4j接收的错误位置?
在检查依赖关系时,我有一个new4j服务器需要一个janino.此外,我没有看到罐子里有任何冲突,但也许我错过了一些事情.这是我从“播放依赖”的依赖关系层次:
https://gist.github.com/4559389
我还尝试将Play2.1维基上列出的默认配置复制到custom-logback.xml中,而不成功:
<configuration> <conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" /> <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>${application.home}/logs/application.log</file> <encoder> <pattern>%date - [%level] - from %logger in %thread %n%message%n%xException%n</pattern> </encoder> </appender> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%coloredLevel %logger{15} - %message%n%xException{5}</pattern> </encoder> </appender> <logger name="play" level="INFO" /> <logger name="application" level="INFO" /> <root level="ERROR"> <appender-ref ref="STDOUT" /> <appender-ref ref="FILE" /> </root> </configuration>
编辑2
肯定似乎是logback依赖关系的一个问题. Neo4j取决于0.9.30,玩依赖于1.0.7看起来.我猜这些版本之间有一个api的变化,当图书馆被加载?janino?它找不到合适的方法.仍然不确定如何在logback.xml中正确指定在运行时选择正确的依赖关系.
图由yed sbt-dependency-graph生成.
"ch.qos.logback" % "logback-core" % "1.0.3" force(),// this should override the Play version "ch.qos.logback" % "logback-classic" % "1.0.3" force(),
为了很好的措施,我还尝试排除通过设置SBT的ivyXML参数被拉入的任何log4j传递依赖关系:
ivyXML := <dependencies> <exclude module="log4j"/> </dependencies>
这显然是一个脆弱的修复,但至少对于Play 2.1-RC2,它似乎工作.我仍然有问题实际配置Neo4j的日志记录,所以我稍后尝试更新这个答案.
更新:由于我是新的回溯我有一个困难配置它与Play / Neo4j.为了防止Logback发生错误并将其淹没在状态消息中,我需要在我的Play应用程序的conf目录中放入一个名为custom-logback.xml的文件.我认为Neo4j日志记录配置需要这个.矿包含以下内容:
<included> <logger name="eu.mypackage" level="info"> </logger> <logger name="org.neo4j" level="warn"> </logger> <root level="warn"> </root> </included>
另外在我的conf目录中,我似乎需要一个名为logback.properties的文件(在我的例子中)只包含这一行:
CONSOLE_LEVEL=ERROR
(Logback专家,随时更正任何一个.)