Search code examples
javasbtebean

Ebean enhancement ignores a model


We are using the avaje-agentloader to enhance our ebeans. All the ebeans are in the same package. We are including the loader, the agent & the base ebean library in our project (via sbt):

"org.avaje" % "avaje-agentloader" % "1.1.2",
"org.avaje.ebeanorm" % "avaje-ebeanorm" % "4.5.5",
"org.avaje.ebeanorm" % "avaje-ebeanorm-agent" % "4.5.2",

However, when the loader runs the enhancement, it skips ONE ebean.

Each ebean is annotated with @Entity and extends com.avaje.ebean.Model. There seem to be no differences between the ones that get enhanced and the one that does not. There are no extra includes, or extends, etc.

Basically, I'm wondering if anyone has run across this issue in the past, or has any insights.

Things we've tried:

  • specifying actual classes to be enhanced via serverConfig.setClasses(...)
  • specifying pakages to analyse/enhance via serverConfig.addPackage(...) or setPackages(...)
  • not specifying at all and having the loader analyse all.
  • we've set a break-point at Transformer.transform and the bean in question is never actually hit.

Note: if we use the ebean agent via an agent loader on the command line, or via a maven plugin, or sbt, it works.


Solution

  • Ok, So I posted this on the Ebean group on Google Groups as well, and Rob Bygrave responded, explaining a few things. (read his reply here)

    1. serverConfig.setXXX have nothing to do with ebean enhancement.
    2. It looks like the bean is being loaded before the agent loads.

    He was correct, indeed the model/bean in question is being loaded well before the agent. So we are tracking down why.

    The issue therefore is that the agent does not enhance beans that have already been loaded by the ClassLoader (makes sense). he did mention that we could "Change the Ebean agent to also support 'class redefinition'".