【问题标题】:Gpars withExistingPool Error jsr166y.ForkJoinPool not foundGpars with ExistingPool Error jsr166y.ForkJoinPool not found
【发布时间】:2013-08-01 11:38:45
【问题描述】:

我已从“org.codehaus.gpars:gpars:1.0.0”更新为“org.codehaus.gpars:gpars:1.1.0”。我的代码在 1.0.0 中运行良好,但在 1.1.0 版本中我找不到 jsr166y.ForkJoinPool 了。

如何获得正确的 ForkJoinPool?

我使用的代码是:

import groovyx.gpars.GParsPool
import jsr166y.ForkJoinPool

class Test {
   def pool = new ForkJoinPool()

   def executeAsync(args, closure = null) {
    if(!closure) {
        closure = args
        args = null
    }

    GParsPool.withExistingPool(pool) {
        closure.callAsync(args)
    }
   }
}

我必须导入 java.util.concurrent.ForkJoinPool 来获取 ForkJoinPool 类。但在运行时我收到以下错误:

| Error 2013-08-01 13:26:45,807 [http-nio-8080-exec-4] ERROR 
errors.GrailsExceptionResolver  - ClassNotFoundException occurred when processing   
request: [POST] /testpackage/test/saveAll - parameters:
jsr166y.ForkJoinPool. Stacktrace follows: 
Message: jsr166y.ForkJoinPool
Line | Method
->>  175 | findClass                 in org.codehaus.groovy.tools.RootLoader
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    423 | loadClass                 in java.lang.ClassLoader
|    147 | loadClass . . . . . . . . in org.codehaus.groovy.tools.RootLoader
|    356 | loadClass                 in java.lang.ClassLoader
|   2451 | privateGetDeclaredMethods in java.lang.Class
|   1810 | getDeclaredMethods        in     ''
|     46 | getLocked . . . . . . . . in org.codehaus.groovy.util.LazyReference
|     33 | get                       in     ''
|    318 | saveAll . . . . . . . . . in testpackage.UploadImageController
|    195 | doFilter                  in   
grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter . . . . . . . .  in grails.plugin.cache.web.filter.AbstractFilter
|   1145 | runWorker                 in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run                       in java.lang.Thread
| Compiling 1 source files.

【问题讨论】:

  • 如果我只是在 groovyConsole (v2.1.6) 中运行它,它可以正常工作...
  • 但是:jsr166y.ForkJoinPool 在 1.1.0 中不可用怎么办?
  • 它是org.codehaus.gpars:gpars:1.1.0 的依赖项... 我刚刚创建了一个新的grails 项目,将build 'org.codehaus.gpars:gpars:1.1.0' 添加到BuildConfig.groovydependencies 部分并尝试了上面的代码,它似乎为我工作:-/ 你使用的是什么版本的 grails?
  • 我使用最新的 grails 2.2.4。我在某处读到必须导入 compile 'org.codehaus.jsr166-mirror:jsr166y:1.7.0' 这可能是一个解决方案吗?

标签: multithreading grails groovy grails-2.0 gpars


【解决方案1】:

将您的 BuildConfog.groovy 更新为:

compile 'org.codehaus.gpars:gpars:1.1.0'
compile 'org.codehaus.jsr166-mirror:jsr166y:1.7.0'

这应该适合你。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-06-14
    • 1970-01-01
    • 2016-02-29
    • 2013-11-14
    • 1970-01-01
    • 2021-06-29
    • 2019-05-12
    • 1970-01-01
    相关资源
    最近更新 更多