【问题标题】:CloudFoundry Grails - Unable to detect java compiler, make sure you're using a JDK not a JRECloudFoundry Grails - 无法检测到 java 编译器,请确保您使用的是 JDK 而不是 JRE
【发布时间】:2015-02-16 21:31:13
【问题描述】:

我遇到了一些非常奇怪的问题,当我将 grails 应用程序部署到 CloudFOundry (run.pivotal.io) 时,我遇到了奇怪的异常。

2015-02-16T11:12:18.000+00:00 [App/0] OUT at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:370)
2015-02-16T11:12:18.000+00:00 [App/0] OUT at org.vertx.java.platform.impl.java.JavaVerticleFactory.createVerticle(JavaVerticleFactory.java:51)
2015-02-16T11:12:18.000+00:00 [App/0] OUT java.lang.RuntimeException: Compilation failed
2015-02-16T11:12:18.000+00:00 [App/0] OUT vert.x-eventloop-thread-2] ERROR impl.DefaultContext - Unhandled exception
2015-02-16T11:12:18.000+00:00 [App/0] OUT ... 7 more
2015-02-16T11:12:18.000+00:00 [App/0] OUT Caused by: java.lang.RuntimeException: Unable to detect java compiler, make sure you're using a JDK not a JRE!
2015-02-16T11:12:18.000+00:00 [App/0] OUT at java.lang.Thread.run(Thread.java:745)
2015-02-16T11:12:18.000+00:00 [App/0] OUT at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
2015-02-16T11:12:18.000+00:00 [App/0] OUT at org.vertx.java.platform.impl.java.CompilingClassLoader.<init>(CompilingClassLoader.java:108)
2015-02-16T11:12:18.000+00:00 [App/0] OUT at org.vertx.java.platform.impl.DefaultPlatformManager$21.run(DefaultPlatformManager.java:1740)
2015-02-16T11:12:06.000+00:00 [App/0] OUT Configuring Spring Security Core ...
2015-02-16T11:12:00.000+00:00 [App/0] OUT [CONTAINER] udAutoReconfigurationApplicationContextInitializer INFO Adding cloud service auto-reconfiguration to ApplicationContext
2015-02-16T11:11:58.000+00:00 [App/0] OUT [CONTAINER] org.apache.tomcat.util.digester.Digester INFO TLD skipped. URI: http://www.springframework.org/tags/form is already defined
2015-02-16T11:11:58.000+00:00 [App/0] OUT [CONTAINER] org.apache.tomcat.util.digester.Digester INFO TLD skipped. URI: http://www.springframework.org/tags is already defined

那是什么? 在 BootStrap.groovy 我已经定义了 -

def init = { servletContext ->
vertxPlatformManager = PlatformLocator.factory.createPlatformManager()
URL[] classpath = [new File("src/java/pizzaVerticles/src/vertx/java/hello").toURI().toURL()]
vertxPlatformManager.deployVerticle("RateFetcherVerticleFirebase.java", null, classpath, 1, null, null)
vertxPlatformManager.deployVerticle("Server.java", null, classpath, 1, null, null)
vertxPlatformManager.deployVerticle("SocialTweety.java", null, classpath, 1, null, null)
}

还有一些其他的东西,但它们是数据库的记录,这是有效的。

首先我遇到了一些问题,比如 Resource not found: Server.java

三个 java 文件都出错了。然后我将这些 java 文件放在 web-app 文件夹中,在创建战争时它也会拾取它们。但现在我有这个奇怪的例外。谷歌搜索并找不到任何相关内容。非常感谢您的帮助,谢谢!

我对 CloudFoundry 很陌生。应用程序在 grails、vertx 上运行,并使用 gradle 构建并部署到 CF。在本地运行时效果很好。

【问题讨论】:

  • 嗯......您是使用 JDK 还是 JRE 运行 CloudFoundry?
  • 你是在上传war文件还是你的java源文件?
  • 我正在上传使用 gradle war 命令创建的 war 文件,这基本上是 grails war 命令。我在上传到 cloudfoundry github.com/cloudfoundry/java-buildpack#v2.4 时正在使用这个 buildpack,所以 @Stephen C 我不确定我使用的是 JDK 还是 JRE?
  • 通常当您收到此错误时,表示您上传的是 .java 源文件而不是编译的类文件。理想情况下,Cloud Foundry 喜欢使用 .class 文件而不是 .java 源文件进行编译后的战争。您可以尝试将您的 java 代码编译成 .class 文件,然后构建一个战争吗?
  • @JeffSloyer 我已经可以在我的 war 文件中看到那些 .java 文件类了。但从 BootStrap.groovy 看起来像 vertxPlatformManager.deployVerticle("Server.java", null, classpath, 1, null, null) 不知何故想要运行完全 .java 文件

标签: java grails groovy cloud-foundry


【解决方案1】:

尝试运行本教程 (http://docs.cloudfoundry.org/buildpacks/java/gsg-grails.html),看看它是否有效,然后尝试找出你的无效的地方。

【讨论】:

  • 问题是,我可以在 CF 上运行该应用程序并且可以浏览它。但也有诸如 btc rate 刷新和从 twitter 获取推文等功能。它们与 vertx 一起运行。因此这些功能没有在应用程序上运行。
  • 哦,所以看起来是 vertx 的问题......在上面的评论中你有vertxPlatformManager.deployVerticle("Server.java", null, classpath, 1, null, null)。自从寻找 .java 文件以来,这在 CF 中效果不佳。理想情况下,您需要获取已编译的 jar 或类文件...
  • @JeffSloyer 所以您建议以某种方式重新制作该命令行,使其不使用 .java 文件,而是使用 .jar 或 .class 文件? CF 能这样编译它们吗?
  • 是的,如果可以的话,最好使用 jar 文件或编译的类文件
  • 好的,谢谢,会调查的。现在被选为正确答案:)
猜你喜欢
  • 2013-06-22
  • 1970-01-01
  • 2013-10-10
  • 2013-08-02
  • 2019-06-02
  • 1970-01-01
  • 2012-12-06
  • 2015-07-29
  • 1970-01-01
相关资源
最近更新 更多