当drools尝试加载我的pom.properties时出现此错误:
2014-02-25 11:14:06,251 ERROR org.springframework.web.context.ContextLoader.initWebApplicationContext(318): - Context initialization failed
java.lang.NullPointerException
at java.io.File.<init>(Unknown Source)
at org.drools.compiler.kie.builder.impl.ClasspathKieProject.getPomProperties(ClasspathKieProject.java:228)
at org.kie.spring.KModuleBeanFactoryPostProcessor.postProcessBeanFactory(KModuleBeanFactoryPostProcessor.java:93)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:265)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:177)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:609)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:381)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:293)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
特别是它尝试以递归方式查找pom.properties文件,但是当它调用file.isDirectly()时,确定它的目录并抛出NPE时会出现问题。我已经验证了实际上目录存在且权限正确...
public static File recurseToPomProperties(File file) {
if( file.isDirectory() ) {
for ( java.io.File child : file.listFiles() ) {
if ( child.isDirectory() ) {
File returnedFile = recurseToPomProperties( child );
if ( returnedFile != null ) {
return returnedFile;
}
} else if ( child.getName().endsWith( "pom.properties" ) ) {
return child;
}
}
}
return null;
}
答案 0 :(得分:2)
在我的情况下,此错误与drools项目相关联,而不是在Windows上的默认驱动器上运行,如下所述:https://issues.jboss.org/browse/DROOLS-354
我的tomcat服务器在驱动器上运行&#34; D:&#34;我的工作区在&#34; C:&#34;。当我把它全部移动到#C;&#34;时,工作得很好。也许它会有所帮助。