play framework 打包 war 异常: Unknown constant tag 105 in class file Template_2043$_run_closure1
用play 框架开发web 工程,要部署在tomcat 上,使用 war 命令
play war E:\code_test --exclude .svn:logs:tmp:bin:.git -o E:\test_war
通过命令会生成 tomcat 结构的目录的文件。 但是在打包的过程中我遇到了问题。
完整的错误提示
~ _ _
~ _ __ | | __ _ _ _| |
~ | '_ \| |/ _' | || |_|
~ | __/|_|\____|\__ (_)
~ |_| |__/
~
~ play! 1.2.7, http://www.playframework.org
~
~ Excluding these directories :
~ .svn
~ logs
~ tmp
~ bin
~ .git
CompilerOracle: exclude jregex/Pretokenizer.next
Listening for transport dt_socket at address: 8000
04:58:01,542 INFO ~ Starting E:\java_code_to_war\cy_gr_code_test_2
04:58:03,378 INFO ~ Precompiling ...
05:02:47,353 ERROR ~ Cannot start in PROD mode with errors
java.lang.ClassFormatError: Unknown constant tag 105 in class file Template_2043$_run_closure1
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at play.templates.GroovyTemplate$TClassLoader.defineTemplate(GroovyTemplate.java:95)
at play.templates.GroovyTemplate.compile(GroovyTemplate.java:151)
at play.templates.TemplateLoader.getAllTemplate(TemplateLoader.java:212)
at play.Play.preCompile(Play.java:608)
at play.Play.init(Play.java:304)
at play.server.Server.main(Server.java:162)
~ Please fix compilation errors before packaging WAR
产生错误的原因是
route 路由里面的配置错了。可能存在中文的空格。 我是将路由的格式对齐,中间的空格删掉了一些,再打包就成功了。
调试过程中出现过
08:32:53,977 INFO ~ Precompiling ...
08:37:58,683 ERROR ~ Cannot start in PROD mode with errors
java.lang.ClassFormatError: Illegal UTF8 string in constant pool in class file Template_2043$_run_closure1
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at play.templates.GroovyTemplate$TClassLoader.defineTemplate(GroovyTemplate.java:95)
at play.templates.GroovyTemplate.compile(GroovyTemplate.java:151)
at play.templates.TemplateLoader.getAllTemplate(TemplateLoader.java:212)
at play.Play.preCompile(Play.java:608)
at play.Play.init(Play.java:304)
at play.server.Server.main(Server.java:162)
~ Please fix compilation errors before packaging WAR
期待已久的界面出现了。
09:42:52,604 INFO ~ Precompiling ...
09:47:50,009 INFO ~ Done.
~ Packaging current version of the framework and the application to E:\play_to_war\tcs_cy_gr_war ...
~ Done !
~
~ You can now load E:\play_to_war\tcs_cy_gr_war as a standard WAR into your servlet container
~ You can't use play standard commands to run/stop/debug the WAR application...
~ ... just use your servlet container commands instead
~
~ Have fun!