Intellij Idea:使用IBM JDK 7构建项目的问题

时间:2015-12-22 14:04:14

标签: java intellij-idea groovy gradle

我有一个需要与IBM JDK 7一起使用的项目。我在Windows 7上使用Intellij Idea 15.0.2。我的项目是多模块maven项目并使用一些groovy脚本并且还使用gradle来压扁使用maven org.fortasoft:gradle-maven-plugin的POM。现在,当我尝试构建我的应用程序(Build -> Rebuild Project)时,我在消息窗口

中出现了一个单行错误
  

错误:显示java.lang.NullPointerException

当我检查build.log(C:\ Users \ .IntelliJIdea15 \ system \ log \ build-log \ build.log)时,我看到以下异常。一旦我将项目SDK更改为Oracle JDK 7,一切正常。关于这里出错的任何想法?

[更新1:]我也尝试使缓存失效并重新启动想法,只是为了排除缓存正在玩这里犯规。

2015-12-22 14:16:23,343 [   4126]   INFO - .incremental.IncProjectBuilder - java.lang.NullPointerException
org.jetbrains.jps.incremental.ProjectBuildException: java.lang.NullPointerException
     at org.jetbrains.jps.incremental.groovy.GroovyBuilder.build(GroovyBuilder.java:142)
     at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1230)
     at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:904)
     at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:976)
     at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:870)
     at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:695)
     at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:386)
     at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:193)
     at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:137)
     at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:294)
     at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:125)
     at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:232)
     at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:42)
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:482)
     at java.util.concurrent.FutureTask.run(FutureTask.java:273)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1176)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
     at java.lang.Thread.run(Thread.java:795)
Caused by: java.lang.NullPointerException
     at java.lang.ClassLoader.loadClass(ClassLoader.java:731)
     at java.lang.ClassLoader.loadClass(ClassLoader.java:707)
     at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.createCompilationClassLoader(InProcessGroovyc.java:179)
     at org.jetbrains.jps.incremental.groovy.InProcessGroovyc.runGroovyc(InProcessGroovyc.java:76)
     at org.jetbrains.jps.incremental.groovy.GroovyBuilder.runGroovycOrContinuation(GroovyBuilder.java:201)
     at org.jetbrains.jps.incremental.groovy.GroovyBuilder.build(GroovyBuilder.java:117)
     ... 17 more

2 个答案:

答案 0 :(得分:0)

  

关于这里出错的任何想法?

如果我们查看InProcessGroovyc.createCompilationClassLoader,我们就可以看到代码

 private JointCompilationClassLoader createCompilationClassLoader(Collection<String> compilationClassPath) throws Exception {
    ClassLoader parent = obtainParentLoader(compilationClassPath);

    ClassLoader groovyClassLoader = null;
    try {
      ClassLoader auxiliary = parent != null ? parent : buildCompilationClassLoader(compilationClassPath, null).get();
      Class<?> gcl = auxiliary.loadClass("groovy.lang.GroovyClassLoader"); // 179 line, we throw NullPointer Exception

在ClassLoader.loadClass中

public Class<?> loadClass(String name) throws ClassNotFoundException {
    return loadClass(name, false); // 131 line
}


protected Class<?> loadClass(String name, boolean resolve)
        throws ClassNotFoundException
    {
        synchronized (getClassLoadingLock(name)) {
            // First, check if the class has already been loaded
            Class<?> c = findLoadedClass(name); // return null if class not found 

IBM JDK 7无法找到groovy.lang.GroovyClassLoader的主要问题,请检查groovy安装是否正确,IBM JDK可以看到groovy lib(groovy已下载,GROOVY_HOME环境变量已正确设置并GROOVY_HOME/bin已添加到您的PATH环境变量中。

答案 1 :(得分:0)

所以看起来这实际上是v15.0.2的一个错误。解决方法是在-Didea.parallel.class.loader=false

下添加Settings | Build, Execution, Deployment | Compiler | User-local build process VM options

enter image description here

更多详情here。修复程序应该适用于v15.0.3。直到那个时候这个解决方法有效(至少对我而言)。