Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 升级到Grails2.0后的NPE_Java_Spring_Grails_Grails 2.0 - Fatal编程技术网

Java 升级到Grails2.0后的NPE

Java 升级到Grails2.0后的NPE,java,spring,grails,grails-2.0,Java,Spring,Grails,Grails 2.0,我刚刚升级到Grails2.0,在运行应用程序时看到下面的错误。 它表示一行上的NPE,该行 return fileSpec; 我在互联网上搜索了一段时间,我发现一些人在各种插件方面有问题,但不是特别是这个NPE问题。使用组件扫描器加载我的SpringBean似乎有点问题,但我不明白为什么它不再工作了。在Grails1.3.7->2.0升级之前,一切进展顺利 如果有任何Grails或Spring3.1大师能为我指明正确的方向,我将不胜感激。谢谢 以下是错误: =============== D

我刚刚升级到Grails2.0,在运行应用程序时看到下面的错误。 它表示一行上的NPE,该行

return fileSpec;
我在互联网上搜索了一段时间,我发现一些人在各种插件方面有问题,但不是特别是这个NPE问题。使用组件扫描器加载我的SpringBean似乎有点问题,但我不明白为什么它不再工作了。在Grails1.3.7->2.0升级之前,一切进展顺利

如果有任何Grails或Spring3.1大师能为我指明正确的方向,我将不胜感激。谢谢

以下是错误:

=============== DEBUG MESSAGE: unimplemented bytecode ================
| Error 2012-01-17 21:21:42,273 [Thread-10] ERROR context.GrailsContextLoader  - Error executing bootstraps: Error creating bean with name 'fileSpec': Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public myproject.spec.FileSpec myproject.spec.MyFileSpecGenerator.createFileSpec()] threw exception; nested exception is java.lang.NullPointerException
Message: Error creating bean with name 'fileSpec': Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public myproject.spec.FileSpec myproject.spec.MyFileSpecGenerator.createFileSpec()] threw exception; nested exception is java.lang.NullPointerException
   Line | Method
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run      in     ''
^   680 | run . .  in java.lang.Thread
Caused by BeanDefinitionStoreException: Factory method [public myproject.spec.FileSpec myproject.spec.MyFileSpecGenerator.createFileSpec()] threw exception; nested exception is java.lang.NullPointerException
->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   138 | run      in java.util.concurrent.FutureTask
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run      in     ''
^   680 | run . .  in java.lang.Thread
Caused by NullPointerException: null
->> 2027 | createFileSpec in myproject.spec.MyFileSpecGenerator
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   303 | innerRun in java.util.concurrent.FutureTask$Sync
|   138 | run . .  in java.util.concurrent.FutureTask
|   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   908 | run . .  in     ''
^   680 | run      in java.lang.Thread
可能相关:myresources.groovy

beans = {
    fileSpec(fileSpecGenerator:"createFileSpec")
}

您的工厂方法正在将NPE抛出公共myproject.spec.FileSpec myproject.spec.MyFileSpecGenerator.createFileSpec()。你有什么?你试过做“grails清理”吗?Aravind a:就像我说的,只是:返回fileSpec;Manish:是的,grails清理、刷新依赖项、重新启动STS。问题仍然存在。我还对fileSpecGenerator.createFileSpec()运行了一个单元测试。很好。这是一个非常简单的方法。没有依赖关系。不返回null。我认为NPE来自fileSpecGenerator,而不是组件扫描中的bean。不知道为什么。