title: playframework Uncompiled class while enhancing
body: <p>for some reason my play eclipse app cannot run a bootstrap job and throws below exception.
  it seems the Model class User is not compiled and stored in tmp/classes directory. i'm not sure what is wrong that makes my play eclipse app not correctly compiling and generating classes in dev mode.
  any solution is much appreciated.</p>
  
  <p>----UPDATE-------</p>
  
  <p>below is the models.User class. this class seems to cause problems. each time i change the source code of this class then play can't compile and raise the error below.</p>
  
  <p>----------models.User.java-------------------------</p>
  
      
  
  <pre class="lang-java prettyprint-override"><code>package models;
      import java.util.ArrayList;
      import java.util.Arrays;
      import java.util.Date;
      import java.util.List;
  
      import javax.persistence.CascadeType;
      import javax.persistence.Entity;
      import javax.persistence.FetchType;
      import javax.persistence.ManyToOne;
      import javax.persistence.OneToMany;
  
      import controllers.Secure;
      import controllers.Secure.Security;
  
      import models.deadbolt.RoleHolder;
      import play.data.binding.As;
      import play.data.validation.CheckWith;
      import play.data.validation.Email;
      import play.data.validation.Equals;
      import play.data.validation.Match;
      import play.data.validation.MinSize;
      import play.data.validation.Password;
      import play.data.validation.Required;
      import play.db.jpa.Model;
      import play.libs.Codec;
      import play.mvc.Scope.RenderArgs;
      import util.UniqueObjectCheck;
  
      @Entity
      public class User extends Model implements RoleHolder {
  
          private static final long serialVersionUID = 1L;
  
          @Required
          public String firstname;
          @Required
          public String lastname;
  
          public String gender;
  
          @As("yyyy")
          public Date dob;
  
          @ManyToOne
          public Country country;
  
          @Required
          @MinSize(8)
          @Match("^[a-zA-Z0-9_]*$")
          @CheckWith(UniqueUserCheck.class)
          public String username;
  
          @Required
          @Equals("confirmPassword")
          @MinSize(8)
          @Password
          public String password;
  
          @Password
          public String confirmPassword;
  
          @Required
          @Email
          @Equals("confirmEmail")
          @CheckWith(UniqueEmailCheck.class)
          public String email;
  
          public String confirmEmail;
  
          public String passwordHash;
  
          public Boolean active;
  
          //@Required
          //@OneToMany (cascade=CascadeType.ALL)
          @ManyToOne (cascade=CascadeType.ALL)
          public UserRole role;
  
  
          /**
           * 
           */
          public User() {
              // init();
              //if(role == null)
                  //role= new ArrayList&lt;UserRole&gt;();
          }
  
          public User(final String firstname, final String lastname,
                  final String gendre, final Date yob, final Country country,
                  final String username, final String password, final String email) {
              super();
              this.firstname = firstname;
              this.lastname = lastname;
              this.gender = gendre;
              dob = yob;
              this.country = country;
              this.username = username;
              this.password = password;
              this.email = email;
  
              init();
  
          }
  
          public User(final String firstname, final String lastname,
                  final String gendre, final Date yob, final Country country,
                  final String username, final String password,
                  final String confirmPassword, final String email,
                  final String confirmEmail) {
              super();
              this.firstname = firstname;
              this.lastname = lastname;
              this.gender = gendre;
              dob = yob;
              this.country = country;
              this.username = username;
              this.password = password;
              this.confirmPassword = confirmPassword;
              this.email = email;
              this.confirmEmail = confirmEmail;
  
              init();
          }
  
          public User(final String email, final String password) {
  
              if (email == null || email.isEmpty())
                  throw new RuntimeException("User must have an email");
              if (password == null || email.isEmpty())
                  throw new RuntimeException("User must have a password");
              this.email = email;
              // init();
  
          }
  
          private void init() {
              passwordHash = Codec.hexMD5(password);
  
              // BCrypt.hashpw(password, BCrypt.gensalt(saltFactor));
  
          }
  
          public void addRole(String name) {
              if(name == null || name.isEmpty())
                  return;
  
              if(hasRole(name)){
                  System.out.println( "user already has role: "+ name);
                  return;
  
              }
              this.save();
              new UserRole(this,name).save();     
              this.save();
              System.out.println( "added user role: "+ name);
  
          }
  
          public void encodePassword(final String password) {
  
              passwordHash = Codec.hexMD5(password);
              // BCrypt.hashpw(password, BCrypt.gensalt(saltFactor));
  
          }
  
          public boolean checkPassword(final String plainTextPassword) {
              // BCrypt.checkpw(plainTextPassword, passwordHash);
              //System.out.println(Codec.hexMD5(plainTextPassword));
              return Codec.hexMD5(plainTextPassword).equals(passwordHash);
  
          }
  
          public static User getUserByEmail(final String email) {
              return User.find("byEmail", email).first();
          }
  
          public static User getByUserName(String userName) {
              return find("byUserName", userName).first();
          }
  
          public List&lt;? extends models.deadbolt.Role&gt; getRoles() {
  
              List&lt;UserRole&gt; roles=UserRole.find("byUser", this).fetch();
              System.out.println("getRoles="+roles);
              return roles;
          }
  
          public boolean hasRole(final String name) {
              this.save();
              UserRole userRole=UserRole.getByName(name);
              List&lt;UserRole&gt; roles=UserRole.find("byUser", this).fetch();
              //System.out.print("userRole=");
              //System.out.println(userRole);
              return (roles.contains(userRole));
  
  
          }
  
          class UniqueEmailCheck extends UniqueObjectCheck&lt;User&gt; {
              @Override
              protected List loadExistingUniqueObjects(final User user) {
                  setMessage("validation.emailUsed", user.email);
                  return User.find("byEmail", user.email).fetch();
  
              }
          }
  
          class UniqueUserCheck extends UniqueObjectCheck&lt;User&gt; {
              @Override
              protected List loadExistingUniqueObjects(final User user) {
                  setMessage("validation.used", user.username);
                  return User.find("byUsername", user.username).fetch();
              }
          }
  
          public String toString() {
              return this.username;
          }
  
      }
  </code></pre>
  
  <p>------models.UserRole.java-------------------------</p>
  
  <pre class="lang-java prettyprint-override"><code>package models;
  
  import javax.persistence.Entity;
  import javax.persistence.ManyToOne;
  
  import models.deadbolt.Role;
  import play.data.validation.Required;
  import play.db.jpa.Model;
  
  /**
   * 
   */
  @Entity
  public class UserRole extends Model implements Role {
      @Required
      public String name;
      @ManyToOne
      public User user;
  
      public UserRole(User user,String name) {
          this.user=user;
          this.name = name;
      }
  
      public String getRoleName() {
          return name;
      }
  
      public static UserRole getByName(String name) {
          return UserRole.find("byName", name).first();
      }
  
      @Override
      public String toString() {
          return this.name;
      }
  }
  </code></pre>
  
  <p>----------------Error Exception--------------------</p>
  
  <pre class="lang-java prettyprint-override"><code>    Oops: UnexpectedException
  An unexpected error occured caused by exception UnexpectedException: While applying class play.classloading.enhancers.PropertiesEnhancer on Bootstrap
  
  play.exceptions.UnexpectedException: While applying play.CorePlugin@496614e7 on Bootstrap
      at play.plugins.PluginCollection.enhance(PluginCollection.java:511)
      at play.classloading.ApplicationClasses$ApplicationClass.enhance(ApplicationClasses.java:235)
      at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:165)
      at play.classloading.ApplicationClassloader.loadClass(ApplicationClassloader.java:84)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      at play.classloading.ApplicationClasses.getAssignableClasses(ApplicationClasses.java:67)
      at play.classloading.ApplicationClassloader.getAssignableClasses(ApplicationClassloader.java:455)
      at play.classloading.ApplicationClassloader$getAssignableClasses.call(Unknown Source)
      at {module:crud}/app/views/tags/crud/types.tag.(line:3)
      at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:232)
      at play.templates.GroovyTemplate$ExecutableTemplate.invokeTag(GroovyTemplate.java:379)
      at {module:crud}/conf/routes.(line:4)
      at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:232)
      at play.templates.Template.render(Template.java:26)
      at play.templates.GroovyTemplate.render(GroovyTemplate.java:187)
      at play.mvc.Router.parse(Router.java:162)
      at play.mvc.Router.parse(Router.java:190)
      at play.mvc.Router.parse(Router.java:164)
      at play.mvc.Router.load(Router.java:48)
      at play.mvc.Router.detectChanges(Router.java:219)
      at Invocation.HTTP Request(Play!)
  Caused by: play.exceptions.UnexpectedException: While applying class play.classloading.enhancers.PropertiesEnhancer on Bootstrap
      at play.CorePlugin.enhance(CorePlugin.java:302)
      at play.plugins.PluginCollection.enhance(PluginCollection.java:506)
      at play.classloading.ApplicationClasses$ApplicationClass.enhance(ApplicationClasses.java:235)
      at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:165)
      at play.classloading.ApplicationClassloader.loadClass(ApplicationClassloader.java:84)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      at play.classloading.ApplicationClasses.getAssignableClasses(ApplicationClasses.java:67)
      at play.classloading.ApplicationClassloader.getAssignableClasses(ApplicationClassloader.java:455)
      at play.classloading.ApplicationClassloader$getAssignableClasses.call(Unknown Source)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
      at Template_1001$_run_closure1.doCall(types.tag:6)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
      at Template_1001$_run_closure1.doCall(types.tag)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
      at groovy.lang.Closure.call(Closure.java:282)
      at groovy.lang.Closure.call(Closure.java:277)
      at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:99)
      at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.access$300(GroovyCategorySupport.java:61)
      at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:239)
      at org.codehaus.groovy.runtime.DefaultGroovyMethods.use(DefaultGroovyMethods.java:333)
      at org.codehaus.groovy.runtime.dgm$723.invoke(Unknown Source)
      at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoMetaMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:307)
      at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153)
      at Template_1001.run(types.tag:2)
      at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:232)
      at play.templates.GroovyTemplate$ExecutableTemplate.invokeTag(GroovyTemplate.java:379)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:362)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:161)
      at Template_1000$_run_closure1.doCall(routes:41)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149)
      at Template_1000$_run_closure1.doCall(routes)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
      at groovy.lang.Closure.call(Closure.java:282)
      at groovy.lang.Closure.call(Closure.java:277)
      at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:99)
      at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.access$300(GroovyCategorySupport.java:61)
      at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:239)
      at org.codehaus.groovy.runtime.DefaultGroovyMethods.use(DefaultGroovyMethods.java:333)
      at org.codehaus.groovy.runtime.dgm$723.invoke(Unknown Source)
      at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoMetaMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:307)
      at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153)
      at Template_1000.run(routes:2)
      ... 9 more
  Caused by: play.exceptions.UnexpectedException: Error in PropertiesEnhancer
      at play.classloading.enhancers.PropertiesEnhancer$1.edit(PropertiesEnhancer.java:175)
      at javassist.expr.ExprEditor.loopBody(ExprEditor.java:197)
      at javassist.expr.ExprEditor.doit(ExprEditor.java:90)
      at javassist.CtBehavior.instrument(CtBehavior.java:618)
      at play.classloading.enhancers.PropertiesEnhancer.enhanceThisClass(PropertiesEnhancer.java:133)
      at play.CorePlugin.enhance(CorePlugin.java:297)
      ... 84 more
  Caused by: java.lang.RuntimeException: Trying to visit uncompiled class while enhancing. Uncompiled class: models.User
      at play.classloading.enhancers.Enhancer$ApplicationClassesClasspath.openClassfile(Enhancer.java:75)
      at javassist.ClassPoolTail.openClassfile(ClassPoolTail.java:335)
      at javassist.ClassPool.openClassfile(ClassPool.java:594)
      at javassist.CtClassType.getClassFile2(CtClassType.java:185)
      at javassist.CtClassType.makeFieldCache(CtClassType.java:760)
      at javassist.CtClassType.getMembers(CtClassType.java:751)
      at javassist.CtClassType.getDeclaredField2(CtClassType.java:873)
      at javassist.CtClassType.getField2(CtClassType.java:828)
      at javassist.CtClassType.getField(CtClassType.java:820)
      at javassist.expr.FieldAccess.getField(FieldAccess.java:113)
      at play.classloading.enhancers.PropertiesEnhancer$1.edit(PropertiesEnhancer.java:140)
      ... 89 more
  </code></pre>