2

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?

Brad Mace
  • 27,194
  • 17
  • 102
  • 148

1 Answers1

0

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.

Peter Hilton
  • 17,211
  • 6
  • 50
  • 75
  • I tried a variety of values from 1 to 10000. Sometimes it changes which class it can't find, but none of them allowed it to work. – Brad Mace Jan 08 '11 at 19:25