问题
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);
...
}
The exception is
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)
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?
回答1:
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.
来源:https://stackoverflow.com/questions/4608883/problem-with-classes-not-found-during-playplugin-enhance