Google App Engine - 无法编译生成的 JSP java 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14638655/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Google App Engine - Failed to compile the generated JSP java files
提问by theeggman85
My project works fine locally, but when trying to deploy it to the GAE servers, I get the following error message:
我的项目在本地运行良好,但是在尝试将其部署到 GAE 服务器时,我收到以下错误消息:
Unable to update app: Failed to compile the generated JSP java files.
This happened mainly when I switched from Java 7 to Java 6, since apparently GAE doesn't support that yet. I am using GAE 1.7.4, is this a known problem? What is wrong with the project? Is it syntax within the JSPs? They used to compile before I starting using GAE 1.7.4, but I don't know the exact cause of when this started.
这主要发生在我从 Java 7 切换到 Java 6 时,因为显然 GAE 还不支持。我使用的是 GAE 1.7.4,这是一个已知问题吗?项目有什么问题?它是 JSP 中的语法吗?他们过去常常在我开始使用 GAE 1.7.4 之前进行编译,但我不知道它何时开始的确切原因。
采纳答案by user1536633
I have been having the same problem and was convinced that there was a GAE problem. However, now I realize that I had changed the name of a .java file referenced by a couple of my .jsp files and the file name had not gotten changed in the .jsp. After I fixed the file name in the .jsp deployment worked normally again. Arrgh.
我一直有同样的问题,并确信存在 GAE 问题。但是,现在我意识到我已经更改了我的几个 .jsp 文件引用的 .java 文件的名称,并且文件名在 .jsp 中没有更改。在我修复 .jsp 部署中的文件名后,再次正常工作。啊。
I think before GAE started compiling the JSP files, JSP files with errors would deploy successfully. Also, when running locally, the JSP are apparently not compiled until they are accessed, so unless all the JSP files are tested locally, you may not know of the error. But if you try to deploy, the JSP compilation fails and the deploy is aborted. Unfortunately, there is no sensible error message to suggest where the problem was found.
我认为在 GAE 开始编译 JSP 文件之前,有错误的 JSP 文件会成功部署。此外,在本地运行时,JSP 显然在访问之前不会被编译,因此除非所有 JSP 文件都在本地进行测试,否则您可能不知道错误。但是如果您尝试部署,JSP 编译会失败并且部署被中止。不幸的是,没有合理的错误消息来建议发现问题的位置。
回答by nurinamu
I try to recompile java files on eclipse again and check the errors.
I think this is better way to check it.
我尝试再次在 eclipse 上重新编译 java 文件并检查错误。
我认为这是检查它的更好方法。
This is my blog for the detail.
http://nurinamu.tumblr.com/post/62384368766/how-to-detect-the-jsp-compile-error-when-deploy-to
这是我的博客的详细信息。
http://nurinamu.tumblr.com/post/62384368766/how-to-detect-the-jsp-compile-error-when-deploy-to
回答by Mark Scheel
I had this same issue. I had changed the method signature of a method that was called by a JSP I didn't normally go to. So when running locally everything worked fine because I never went to the problematic JSP.
我有同样的问题。我更改了由我通常不去的 JSP 调用的方法的方法签名。所以在本地运行时一切正常,因为我从未去过有问题的 JSP。
The way to resolve this is to run locally and go to every single JSP in your project. Eventually I got to a JSP that gave me a full stack trace locally in my browser window. When I fixed the error in that JSP I was again able to deploy to app engine production.
解决此问题的方法是在本地运行并转到项目中的每个 JSP。最终我找到了一个 JSP,它在我的浏览器窗口中为我提供了本地的完整堆栈跟踪。当我修复该 JSP 中的错误时,我再次能够部署到应用引擎生产。
It would be better if GAE was able to report which JSP is failing, but this technique will work.
如果 GAE 能够报告哪个 JSP 失败会更好,但这种技术会起作用。
回答by msm
I was running in the same issue. Yes the error your get in Eclipse and in the log is really unhelpful, but wanted to share that deploying to the local dev server instead gave a very helpful error message, e.g. in my case:
我在同一个问题上运行。是的,你在 Eclipse 和日志中得到的错误真的没有帮助,但想分享部署到本地开发服务器的错误信息,而不是给出了一个非常有用的错误消息,例如在我的情况下:
HTTP ERROR 500
HTTP 错误 500
Problem accessing /. Reason:
访问 / 时出现问题 原因:
Unable to compile class for JSP:
无法为 JSP 编译类:
An error occurred at line: 286 in the jsp file: /dashboard.jsp
在 jsp 文件中的第 286 行发生错误:/dashboard.jsp
Duplicate local variable datastore
重复的局部变量数据存储
283: </head>
284: <body onload="initialize()">
285: <%
286: DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
287:
288: UserService userService = UserServiceFactory.getUserService();
289: User user = userService.getCurrentUser();
Saved a big headache.
省了大麻烦。
回答by Emperorlou
nurinamu's answer is ok but it didn't work for me because my project was too complex and I wasn't able to resolve the errors I got from linking the source folder generated in the appengine staging area. However I did manage to fix my problem!
nurinamu 的回答是好的,但它对我不起作用,因为我的项目太复杂,我无法解决链接 appengine 暂存区中生成的源文件夹时出现的错误。但是我确实设法解决了我的问题!
This method is a bit of a pain but in a worst case scenario: move the JSPs out of your project and do a test deploy until you narrow down and find which JSP is causing the issue.
这种方法有点麻烦,但在最坏的情况下:将 JSP 从项目中移出并进行测试部署,直到缩小范围并找到导致问题的 JSP。
This was really the only way I could figure out what was causing the problem.
这确实是我找出导致问题的原因的唯一方法。
UPDATE
更新
For me the error was a rogue import that wasn't supported by appengine.
对我来说,错误是 appengine 不支持的恶意导入。
回答by murtaza.webdev
Just Make Sure that all jsp files run on local so for that you can
try to run and/or test all jsp files on your local
. Their must be error in any of the jsp file.
只需确保所有 jsp 文件都在本地运行,以便您可以尝试使用run and/or test all jsp files on your local
. 它们必须是任何jsp 文件中的错误。
I got solved this problem in this way.
我通过这种方式解决了这个问题。
I only have error in one jsp file but it show the same error for all jsp files so don't worry about all files.
我只在一个 jsp 文件中有错误,但它对所有 jsp 文件都显示相同的错误,所以不用担心所有文件。
回答by gnobal
If you use a JSP include you must make sure that the JSP file, which you include in other files, has all the proper imports, even if everything seems to work well in the test environment.
如果使用 JSP 包含,则必须确保包含在其他文件中的 JSP 文件具有所有正确的导入,即使在测试环境中一切似乎都运行良好。
For example, if you have a file called inc.jsp
and in other files you include it like so:
例如,如果您有一个名为的文件inc.jsp
并在其他文件中包含它,如下所示:
<%@include file="inc.jsp" %>
Then inside inc.jsp
you must make sure all the proper imports are there even if the compiler hasn't explicitly complained about it.
然后在内部inc.jsp
,即使编译器没有明确抱怨它,您也必须确保所有正确的导入都在那里。
An easy way to find the errors in an include JSP is to try and open it in a browser when running the development server. You'll see the JSP errors that the compiler didn't tell you about there.
在包含 JSP 中查找错误的一种简单方法是在运行开发服务器时尝试在浏览器中打开它。您会在那里看到编译器没有告诉您的 JSP 错误。
This is one reason I found for the error mentioned in the question.
这是我发现问题中提到的错误的原因之一。