Agent enhancer weird problem

117 views
Skip to first unread message

Rien

unread,
Jun 2, 2010, 7:15:46 AM6/2/10
to Ebean ORM
Enhancement with the agent has been working fine for us until we
started to add our DAO's for transactional enhancement.

We now get errors like the one below, enhancing with the ant task
seems to work fine.

After a lot of debugging and testing it looks like it has to do with
the generics in our DAO's, they look like this:

@Transactional(type=TxType.SUPPORTS)
public class TblSaleSchedDAO extends BaseCacheDAO <TblSaleSched> {

We get the idea that if the TblSaleSchedDAO is enhanced before
TblSaleSched is, that then the TblSaleSched get's loaded into the jvm
without being enhanced (because of the generics?).

As a workaround we now make sure during startup that some core entity
classes are loaded before the DAO's and that works for us.

Rien


The error message:

2010-06-02 09:49:59,910 [http-8080-2]
ERROR ...web.filter.RequestStateFilter - Throwable exception on
Request state filter
java.lang.ExceptionInInitializerError
at
com.avaje.ebeaninternal.api.HelpScopeTrans.createScopeTrans(HelpScopeTrans.java:
36)
at ...model.BaseDAO.<clinit>(BaseDAO.java)
<more lines here>

Caused by: javax.persistence.PersistenceException: Error with
[...model.contract.sale.TblSaleSched] It has not been enhanced but
it's superClass [class ...model.BaseCacheCompanyDivisionEntity] is?
(You are not allowed to mix enhancement in a single inheritance
hierarchy) marker[...model.BaseCacheEntity]
className[...model.contract.sale.TblSaleSched]
at
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.setEntityBeanClass(BeanDescriptorManager.java:
1505)
at
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.createByteCode(BeanDescriptorManager.java:
1177)
at
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:
1097)
at
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:
618)
at
com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:
275)
at
com.avaje.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:
150)
at
com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:
193)
at
com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:
124)
at
com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:
63)
at
com.avaje.ebean.EbeanServerFactory.create(EbeanServerFactory.java:64)
at com.avaje.ebean.Ebean
$ServerManager.getWithCreate(Ebean.java:237)
at com.avaje.ebean.Ebean$ServerManager.<init>(Ebean.java:193)
at com.avaje.ebean.Ebean$ServerManager.<init>(Ebean.java:159)
at com.avaje.ebean.Ebean.<clinit>(Ebean.java:153)

Rob Bygrave

unread,
Jun 2, 2010, 8:10:19 AM6/2/10
to eb...@googlegroups.com
Interesting.

Note that the error indicates that TblSaleSched is actually NOT enhanced.

That is, somehow it is not being enhanced by the javaagent... and so Ebean is creating a dynamic subclass for it instead and that is failing because (as a rule/check that Ebean does) you can not mix enhanced and subclassed classes in a single inheritance hierarchy (it's parent class ...BaseCacheEntity is enhanced but TblSaleSched was not [was going to be a dynamically generated subclass] ... Ebean checks for that condition and throws this error.

So to me the question is... why is TblSaleSched not being enhanced by the javaagent ? ... and yes, the thought is that it might be something to do with the DAO, Generics and javaagent enhancement.

So it works for ANT enhancement... which might point the issue towards classloading behaviour with javaagent/Transformer in combination with the DAO and Generics.

If you put the debug level to > 5 for the enhancement ... then we should see the classes sent to the Transformer.transform() method ... and specifically if TblSaleSched is transformed/enhanced.


Cheers, Rob.

Rien

unread,
Jun 4, 2010, 6:28:43 AM6/4/10
to Ebean ORM
We did take a look at the logs, and in the case of the error message
the TblSaleSched class is never transformed/enhanced.

Rien

Rob Bygrave

unread,
Jun 6, 2010, 11:26:20 PM6/6/10
to eb...@googlegroups.com
> TblSaleSched class is never transformed/enhanced.

Hmmm, I think that is pointing the issue at the JRE which is controlling the javaagent transformation.

I'll try to reproduce and log a bug but not sure what we will be able to do about it. Sounds like you have a workaround by invoking the classloading of the beans prior to the DAO's ... so not optimal but not a show stopper either.


Cheers, Rob.

Rob Bygrave

unread,
Jun 7, 2010, 12:22:26 AM6/7/10
to eb...@googlegroups.com

Rien

unread,
Jun 7, 2010, 4:24:25 AM6/7/10
to eb...@googlegroups.com
Ok, btw we are using jdk 1.6 so maybe it has something to do with that as well.
Reply all
Reply to author
Forward
0 new messages