问题描述
我正在尝试在Play插件中使用基本的字节码增强功能,但是当它尝试在给定的ApplicationClasses.ApplicationClass
上进行操作时,找不到该类.
I'm experimenting with a basic bytecode enhancement in a Play plugin, but when it tries to operate on the ApplicationClasses.ApplicationClass
that it's given, the class can't be found.
public void enhance(ApplicationClasses.ApplicationClass applicationClass)
throws NotFoundException, IOException, CannotCompileException
{
ClassPool classPool = ClassPool.getDefault();
CtClass ctClass = classPool.get(applicationClass.name);
...
}
例外是
Oops: NotFoundException An unexpected error occured caused by exception NotFoundException: controllers.CRUD
play.exceptions.UnexpectedException: While applying AccessControlPlugin@1a5db4b on controllers.CRUD
at play.classloading.ApplicationClasses$ApplicationClass.enhance(ApplicationClasses.java:215)
...
Caused by: javassist.NotFoundException: controllers.CRUD
at javassist.ClassPool.get(ClassPool.java:436)
at AccessControlPlugin.enhance(AccessControlPlugin.java:19)
Play框架正在调用enhance
方法.它不应该比处理尚不可用的类更好吗?我该如何工作?
The Play framework is calling the enhance
method. Shouldn't it know better than to process classes that aren't available yet? How do I get this working?
推荐答案
如果将插件在play.plugins
中的加载顺序增加到1000(即在内置插件之后),是否有帮助?我还没有看到关于增强的问题,尽管我对于某些类没有调用该插件的增强方法有疑问.
Does it help if you increase the plug-in's load order in play.plugins
to 1000, i.e. after the built-in plug-ins? I haven't seen this problem with enhancement, although I have had problems with the plug-in's enhance method not being called for certain classes.
这篇关于在PlayPlugin.enhance中找不到类的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!