Play 1.2.5.4 上的 LocalvariablesNamesEnhancer 异常 - 我该如何调试(或解决它)?
Posted
技术标签:
【中文标题】Play 1.2.5.4 上的 LocalvariablesNamesEnhancer 异常 - 我该如何调试(或解决它)?【英文标题】:LocalvariablesNamesEnhancer exception on Play 1.2.5.4 - How can I debug this (or workaround it)? 【发布时间】:2015-07-30 12:59:15 【问题描述】:我有一个控制器,它接收异步生成 CSV 的请求,这给了我一个异常:
Oops: UnexpectedException
An unexpected error occured caused by exception UnexpectedException:
While applying class play.classloading.enhancers.LocalvariablesNamesEnhancer on
controllers.Productions
我已设法将问题缩小到等待行。如果我删除它,我不会得到例外。谁能帮助我如何进一步调试问题或提出解决方法?
生产控制器:
@Check("user")
public static void exportz(int iDisplayStart, int sEcho, String sSearch,
String searchFields)
ObjectType ztype = ObjectType.get(getControllerClass());
Triple<String,String,String> triplet = parseListJSON(iDisplayStart, sEcho, sSearch, searchFields);
String where = triplet.getLeft();
String orderField = triplet.getMiddle();
String orderDir = triplet.getRight();
ExportCSV csvGen = new ExportCSV( ztype, where, orderField,orderDir,sSearch,searchFields);
response.contentType = "text/csv";
do
Promise<String> csvGeneration =csvGen.now();
String someCsvData = await(csvGeneration);
response.writeChunk(someCsvData);
while(csvGen.moreData());
例外:
Oops: UnexpectedException
An unexpected error occured caused by exception UnexpectedException: While applying class play.classloading.enhancers.LocalvariablesNamesEnhancer on controllers.Productions
play.exceptions.UnexpectedException: While applying play.CorePlugin@7e6b9547 on controllers.Productions
at play.plugins.PluginCollection.enhance(PluginCollection.java:556)
at play.classloading.ApplicationClasses$ApplicationClass.enhance(ApplicationClasses.java:235)
at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:167)
at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:431)
at play.Play.preCompile(Play.java:593)
at play.Play.init(Play.java:299)
at play.server.Server.main(Server.java:159)
Caused by: play.exceptions.UnexpectedException: While applying class play.classloading.enhancers.LocalvariablesNamesEnhancer on controllers.Productions
at play.CorePlugin.enhance(CorePlugin.java:302)
at play.plugins.PluginCollection.enhance(PluginCollection.java:551)
... 6 more
Caused by: javassist.CannotCompileException: by javassist.bytecode.BadBytecode: invalid opcode address
at javassist.CtBehavior.insertAfter(CtBehavior.java:777)
at play.classloading.enhancers.LocalvariablesNamesEnhancer.enhanceThisClass(LocalvariablesNamesEnhancer.java:269)
at play.CorePlugin.enhance(CorePlugin.java:297)
... 7 more
Caused by: javassist.bytecode.BadBytecode: invalid opcode address
at javassist.bytecode.CodeIterator.nextOpcode(CodeIterator.java:586)
at javassist.bytecode.CodeIterator.next(CodeIterator.java:157)
at javassist.bytecode.stackmap.Liveness.analyze(Liveness.java:237)
at javassist.bytecode.stackmap.Liveness.computeUsage(Liveness.java:216)
at javassist.bytecode.stackmap.Liveness.compute(Liveness.java:38)
at javassist.bytecode.stackmap.TypedBlock.makeBlocks(TypedBlock.java:54)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:91)
at javassist.bytecode.MethodInfo.rebuildStackMap(MethodInfo.java:404)
at javassist.bytecode.MethodInfo.rebuildStackMapIf6(MethodInfo.java:389)
at javassist.CtBehavior.insertAfter(CtBehavior.java:768)
... 9 more
【问题讨论】:
【参考方案1】:好吧,我解决了将方法更改为新控制器的问题。我认为 LocalvariablesNamesEnhancer 有可能永远无法解决的 PlayFramework 上最古老的错误之一。
【讨论】:
我最终解决了这个问题,方法是将我想添加的代码移动到一个私有方法中并改为调用它。但即使这样也不是 100% 有效。我的实际建议是尽快离开 Play 1.x。以上是关于Play 1.2.5.4 上的 LocalvariablesNamesEnhancer 异常 - 我该如何调试(或解决它)?的主要内容,如果未能解决你的问题,请参考以下文章
iPad 上的 JS .play() 播放错误的文件...建议?