Weird RuntimeException without message when caching enabled

92 views
Skip to first unread message

Mikael Nousiainen

unread,
Sep 1, 2012, 3:00:33 AM9/1/12
to eb...@googlegroups.com
I tried to enable L2 caching for my entities, but I get a weird exception without any explanation of the reason.

I also found out the exact source code line that was causing the exception, and the code looks really weird, as it is just throwing an exception in this particular case:
http://grepcode.com/file/repo1.maven.org/maven2/org.avaje/ebean/2.7.5/com/avaje/ebeaninternal/server/deploy/BeanPropertyAssocOne.java#396

What does the "embedded" boolean mean in that piece of code? And why is RuntimeException thrown if embedded is true?

The full stack trace was:

(The bean that is being accessed is behind a LAZY OneToMany mapping and caching was enabled for both beans.)

Caused by: java.lang.RuntimeException: null
    at com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne.getCacheDataValue(BeanPropertyAssocOne.java:396) ~[ebean-2.7.5.jar:na]
    at com.avaje.ebeaninternal.server.cache.CachedBeanDataFromBean.extract(CachedBeanDataFromBean.java:57) ~[ebean-2.7.5.jar:na]
    at com.avaje.ebeaninternal.server.cache.CachedBeanDataFromBean.extract(CachedBeanDataFromBean.java:22) ~[ebean-2.7.5.jar:na]
    at com.avaje.ebeaninternal.server.deploy.BeanDescriptor.cachePutBeanData(BeanDescriptor.java:1091) ~[ebean-2.7.5.jar:na]
    at com.avaje.ebeaninternal.server.core.DefaultBeanLoader.loadBean(DefaultBeanLoader.java:382) ~[ebean-2.7.5.jar:na]
    at com.avaje.ebeaninternal.server.core.DefaultServer.loadBean(DefaultServer.java:529) ~[ebean-2.7.5.jar:na]
    at com.avaje.ebeaninternal.server.loadcontext.DLoadBeanContext.loadBean(DLoadBeanContext.java:203) ~[ebean-2.7.5.jar:na]
    at com.avaje.ebean.bean.EntityBeanIntercept.loadBeanInternal(EntityBeanIntercept.java:531) ~[ebean-2.7.5.jar:na]
    at com.avaje.ebean.bean.EntityBeanIntercept.loadBean(EntityBeanIntercept.java:499) ~[ebean-2.7.5.jar:na]
    at com.avaje.ebean.bean.EntityBeanIntercept.preGetter(EntityBeanIntercept.java:625) ~[ebean-2.7.5.jar:na]


Mikael Nousiainen

unread,
Sep 1, 2012, 3:17:22 AM9/1/12
to eb...@googlegroups.com
Correction: The mapping was LAZY ManyToOne for the field:

  @ManyToOne(fetch = FetchType.LAZY, optional = true,
      cascade = CascadeType.ALL)
  @JoinColumn(name = "defaultWorkspacePermissionId", nullable = true)

A setter for a field with those mappings was called to cause the exception.

I can't see how anything called "embedded" would have anything to do with the field...

Mikael Nousiainen

unread,
Sep 1, 2012, 3:35:01 AM9/1/12
to eb...@googlegroups.com
I did some more searching in Ebean source code (without really knowing my way around), and I found only these places where setEmbedded is used:
http://grepcode.com/search/usages?type=method&id=repo1.maven.org%24ma...@org.avaje%24e...@2.7.5@com%24avaje%24ebeaninternal%24server%24deploy%24meta@DeployBeanProperty@setEmbedded%28boolean%29&k=u

All the cases are related to either using @Embedded, @EmbeddedId or @Id, so I wonder why @ManyToOne with @JoinColumn would have it set.
One thing worth mentioning might be that I am using @Embedded in another field in the same class, but I guess that should not have any effect to other fields.

Additionally, (this might be totally unrelated), does setEmbedded(true) make sense for @Id, as I found it in one place, but not in another -- compare these:
- setEmbbedded(true) for @Id
  - http://grepcode.com/file/repo1.maven.org/maven2/org.avaje/ebean/2.7.5/com/avaje/ebeaninternal/server/deploy/parse/AnnotationAssocOnes.java#106
- no setEmbedded call for @Id
  - http://grepcode.com/file/repo1.maven.org/maven2/org.avaje/ebean/2.7.5/com/avaje/ebeaninternal/server/deploy/parse/AnnotationFields.java#122

Mikael Nousiainen

unread,
Sep 4, 2012, 5:57:47 AM9/4/12
to eb...@googlegroups.com
Rob,

Do you have any idea why this exception gets thrown?
Even a little hint towards the right direction would be appreciated :)

Thanks!

On Saturday, September 1, 2012 10:00:33 AM UTC+3, Mikael Nousiainen wrote:

Rob Bygrave

unread,
Sep 4, 2012, 6:18:38 AM9/4/12
to eb...@googlegroups.com
>> Do you have any idea why this exception gets thrown?

That code where the exception is thrown ... indicates to me that the feature to support embedded beans in the caching wasn't finished - which is a bit pants.

It would seem that one of the types or fields is annotated with Embedded or EmbeddedId ?  You suggest that is not the case though so it is not obvious at this point why you are hitting this issue.


Cheers, Rob.

Mikael Nousiainen

unread,
Sep 4, 2012, 6:59:51 AM9/4/12
to eb...@googlegroups.com
Ok. Actually, I am using @Embedded in one of the fields in both classes: the one containing the collection, and the one in the collection.

So are you suggesting that caching will not work if any of the fields inside a cached entity are @Embedded?
(Meaning that the types that are cached are not embedded, but some of the fields inside them are.)

Rob Bygrave

unread,
Sep 4, 2012, 7:35:44 AM9/4/12
to eb...@googlegroups.com
>> So are you suggesting that caching will not work if any of the fields inside a cached entity are @Embedded
?

Yes.

It is a bit (enter a bad word / less than ideal) but yes.  Throwing that exception should be replaced with actual implementation (that I managed to forget / miss etc). The bean cache has got 'arrays of values' rather than actual beans in it ... and the missing implementation should convert an embedded bean into a 'value'.


Mikael Nousiainen

unread,
Sep 6, 2012, 6:32:55 AM9/6/12
to eb...@googlegroups.com
Allright. I'll manage for a while without caching, so it's not a showstopper for me :)

Would this be a terribly demanding feature to implement?
Is it on the roadmap for next releases?

Rob Bygrave

unread,
Sep 9, 2012, 5:40:30 AM9/9/12
to eb...@googlegroups.com
I have logged a bug for this:  BUG 422 : L2 Cache not working for embedded beans - RuntimeException

>> Is it on the roadmap for next releases?

It definately needs to be fixed.  I'm just struggling time wise at the moment (big projects, none of which use Ebean).
Reply all
Reply to author
Forward
0 new messages