Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use project SDK when staging App Engine apps for deploy #2195

Closed
NicolaSpreafico opened this issue Jul 25, 2017 · 15 comments
Closed

Use project SDK when staging App Engine apps for deploy #2195

NicolaSpreafico opened this issue Jul 25, 2017 · 15 comments
Assignees

Comments

@NicolaSpreafico
Copy link

  • Eclipse version: Oxygen Release (4.7.0)
  • Cloud Tools for Eclipse version: 1.2.0.201706082053
  • Google Cloud SDK version: 163.0.0
  • OS: Windows 10 v1703
  • Java version: jdk1.8.0_111

I have a Maven App Engine standard project which contains jsp files (and this is the reason I think that the project is looking for JDK)

If I deploy the project with appengine:deploy works fine
If I deploy with the plugin I get

Unable to stage:
java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE.
	at com.google.appengine.tools.admin.Application.compileJspJavaFiles(Application.java:1201)
	at com.google.appengine.tools.admin.Application.compileJsps(Application.java:1178)
	at com.google.appengine.tools.admin.Application.populateStagingDirectory(Application.java:901)
	at com.google.appengine.tools.admin.Application.createStagingDirectory(Application.java:809)
	at com.google.appengine.tools.admin.AppAdminImpl.stageApplication(AppAdminImpl.java:539)
	at com.google.appengine.tools.admin.AppAdminImpl.stageApplicationWithDefaultResourceLimits(AppAdminImpl.java:492)
	at com.google.appengine.tools.admin.AppCfg$StagingAction.execute(AppCfg.java:2510)
	at com.google.appengine.tools.admin.AppCfg.executeAction(AppCfg.java:393)
	at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:216)
	at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:116)
	at com.google.appengine.tools.admin.AppCfg.main(AppCfg.java:112)
com.google.appengine.tools.admin.AdminException: Unable to stage app: Cannot get the System Java Compiler. Please use a JDK, not a JRE.
	at com.google.appengine.tools.admin.AppAdminImpl.stageApplication(AppAdminImpl.java:543)
	at com.google.appengine.tools.admin.AppAdminImpl.stageApplicationWithDefaultResourceLimits(AppAdminImpl.java:492)
	at com.google.appengine.tools.admin.AppCfg$StagingAction.execute(AppCfg.java:2510)
	at com.google.appengine.tools.admin.AppCfg.executeAction(AppCfg.java:393)
	at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:216)
	at com.google.appengine.tools.admin.AppCfg.<init>(AppCfg.java:116)
	at com.google.appengine.tools.admin.AppCfg.main(AppCfg.java:112)
Caused by: java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE.
	at com.google.appengine.tools.admin.Application.compileJspJavaFiles(Application.java:1201)
	at com.google.appengine.tools.admin.Application.compileJsps(Application.java:1178)
	at com.google.appengine.tools.admin.Application.populateStagingDirectory(Application.java:901)
	at com.google.appengine.tools.admin.Application.createStagingDirectory(Application.java:809)
	at com.google.appengine.tools.admin.AppAdminImpl.stageApplication(AppAdminImpl.java:539)
	... 6 more

I don't think it is a project or OS error because using directly Maven the deploy works fine

Here is my Java installation
image

Eclipse configuration
image

Project configuration
image

@chanseokoh
Copy link
Contributor

I suspect that JRE was used to start your Eclipse. Can you try changining it to JDK to see if that works? I believe you can configure it through eclipse.ini.

@NicolaSpreafico
Copy link
Author

I found the JRE indeed
image

And I changed it to JDK
image

And the deploy worked.
Thanks for the tip

@patflynn
Copy link

The bug really needs to be that the staging jsp compiler needs to use the project configured jdk. We've seen this problem in other plugins as well.

@patflynn
Copy link

@loosebazooka Does this bug get filed against App Engine SDK?

@chanseokoh
Copy link
Contributor

Maybe it's the fault of CT4E that does not use the project JDK. I'll take a look first.

@loosebazooka
Copy link

It probably isn't the App Engine SDK's fault. I think we need to trigger "staging" or whatever using the project sdk, since it's just using the configuration that launched staging in the first place.

@briandealwis
Copy link
Member

I think @chanseokoh's right: CT4E isn't configuring javaHome() on the CloudSdk instance.

@briandealwis briandealwis reopened this Jul 25, 2017
@chanseokoh chanseokoh self-assigned this Jul 25, 2017
@chanseokoh chanseokoh changed the title Cannot get the System Java Compiler while deploying with plugin Use project SDK when deploying App Engine apps Jul 25, 2017
@chanseokoh
Copy link
Contributor

chanseokoh commented Jul 25, 2017

@NicolaSpreafico I think it's possible that your JSPs will be complied with Java 8 (although it will be compiled with the '--source 1.7' option) and this might cause a problem if deploying to App Engine standard Java 7. If so, please double-check you don't have any problem.

@NicolaSpreafico
Copy link
Author

After updating Eclipse configuration from JRE to SDK the deploy problem is solved and I can confirm that the JSP are working fine

@chanseokoh chanseokoh changed the title Use project SDK when deploying App Engine apps Use project SDK when staging App Engine apps for deploy Jul 26, 2017
@briandealwis
Copy link
Member

It's odd that AppCfg is wanting to use the JDK compiler where as Jasper at runtime uses an embedded ECJ (#590).

@chanseokoh
Copy link
Contributor

chanseokoh commented Jul 27, 2017

Had an offline discussion with @briandealwis. We believe as long as it's not a JRE, using higher versions of Java compilers won't be a problem for compiling JSPs during staging (which is done through -source 1.7, although it shows a warning warning: [options] bootstrap class path not set in conjunction with -source 1.7).

So, the strategy to find any usable JDK will be like this:

  1. get the project's JRE and check if it is a JDK (resolve the compiler class)
  2. if not, cycle through the other installed JREs of that type and see if any of them are JDKs
  3. if none, raise an error

@patflynn
Copy link

patflynn commented Jul 27, 2017 via email

@chanseokoh
Copy link
Contributor

Why not just raise an error immediately after step 1?

I think that's a simple and good idea. Users should have a JDK, and making them to set it to their project sounds right.

@chanseokoh
Copy link
Contributor

chanseokoh commented Jul 31, 2017

Didn't expect this to be closed. (Striking words doesn't seem to work.)

@chanseokoh chanseokoh reopened this Jul 31, 2017
@chanseokoh
Copy link
Contributor

On second thought, I think we can close this now. If a project's JRE is not a JDK (which will be very unlikely anyway) or if it can't find a JDK anywhere, it will fail with the message that it's not a JDK. Users will then naturally configure the project's JRE to be a JDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants