Deserialized entity can not lazy load

118 views
Skip to first unread message

Naoya Higuchi

unread,
Feb 27, 2023, 2:54:15 AM2/27/23
to Ebean ORM
Hi 

When we update Ebean 12.4.2 to latest, my application test fail.

Could you check my patch of example-minimal?
See attachment file.

This is due to the introduction of ReentrantLock.

Thank you in advance

0001-deserialized-entity-can-not-lazy-load.patch

Naoya Higuchi

unread,
Apr 5, 2023, 4:49:43 AM4/5/23
to Ebean ORM
Hi Rob.

Does my email go into your spam folder, too?

2023年2月27日月曜日 16:54:15 UTC+9 Naoya Higuchi:

Rob Bygrave

unread,
Apr 5, 2023, 6:21:59 PM4/5/23
to Ebean ORM
Yup, I didn't see this.

Ok, do you want to post up here what the stack trace is.  
Why do you think it's related to ReentrantLock?  
It sounds like the application needs to serialise and deserialise entity beans, are there alternatives / workarounds that you've been trying or thinking about?

Cheers, Rob.

Naoya Higuchi

unread,
Apr 8, 2023, 11:10:01 PM4/8/23
to eb...@googlegroups.com
Thank you for your reply.

Sorry, I can get stack trace next week.

Did you check my attachment file?
I debuged the test and ReentrantLock of deserialized entity was null. So, when lazy load occurred, NPE throwed.

We use Ebean with Apache Wicket.
Wicket require the serializable object. We don't have workaround yet. If exists, application has over 100 entities, there are a lot of cost for applying workaround.


2023年4月6日(木) 7:22 Rob Bygrave <robin....@gmail.com>:
--

---
You received this message because you are subscribed to the Google Groups "Ebean ORM" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ebean+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ebean/c8b42670-c617-453a-aec2-34194726694bn%40googlegroups.com.

Rob Bygrave

unread,
Apr 10, 2023, 6:03:07 AM4/10/23
to Ebean ORM
I had a quick look but didn't get to apply the patch and run it.

>  ReentrantLock of deserialized entity was null

So I see that the ReentrantLock on InterceptReadWrite is transient and I'd suggest that is the issue there. Are you able to build ebean from source?  If you remove the transient modifier there does that fix the issue?
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Naoya Higuchi

unread,
Apr 12, 2023, 6:28:14 AM4/12/23
to eb...@googlegroups.com
>  Are you able to build ebean from source?

I tried first, but I couldn't.
So I used example-minimal

I create github account and push my test.

Could you try again?

> I can get stack trace next week.

Full stack trace is here.

```
java.lang.NullPointerException
at io.ebean.bean.InterceptReadWrite.loadBean(InterceptReadWrite.java:688)
at io.ebean.bean.InterceptReadWrite.preGetter(InterceptReadWrite.java:820)
at org.example.domain.Customer._ebean_get_name(Customer.java:6)
at org.example.domain.Customer.getName(Customer.java:46)
at org.example.domain.OrderTest.lazyloadToOneOfDeserializedEntity(OrderTest.java:57)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:84)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
```


2023年4月10日(月) 19:03 Rob Bygrave <robin....@gmail.com>:

Rob Bygrave

unread,
Apr 12, 2023, 4:29:59 PM4/12/23
to eb...@googlegroups.com
Hi,

Sorry, your emails went into the google groups pending messages so didn't get published (hence they have all come out now).

For this issue, I'll look to see if I can run that and reproduce the stack trace. My suspicion is that this is just a case of wanting to remove the transient modifier from the ReentrantLock.


Cheers, Rob.

On Wed, 12 Apr 2023 at 22:28, Naoya Higuchi <naoh...@gmail.com> wrote:
>  Are you able to build ebean from source?

I tried first, but I couldn't.
So I used example-minimal

I create github account and push my test.

Could you try again?

> I can get stack trace next week.

2023年4月10日月曜日 19:03:07 UTC+9 Rob Bygrave:

Rob Bygrave

unread,
Apr 12, 2023, 11:43:48 PM4/12/23
to eb...@googlegroups.com
Just to say, a benefit which came in Java 17 I believe was better NPE errors:  For example,

[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.471 s <<< FAILURE! - in org.example.domain.OrderTest

[ERROR] org.example.domain.OrderTest.lazyloadToOneOfDeserializedEntity  Time elapsed: 0.456 s  <<< ERROR!

java.lang.NullPointerException: Cannot invoke "java.util.concurrent.locks.ReentrantLock.lock()" because "this.lock" is null

at org.example.domain.OrderTest.lazyloadToOneOfDeserializedEntity(OrderTest.java:57)



... which tells us explicitly that this.lock is null.

Rob Bygrave

unread,
Apr 13, 2023, 3:45:02 AM4/13/23
to Ebean ORM

Naoya Higuchi

unread,
Apr 14, 2023, 5:12:30 AM4/14/23
to eb...@googlegroups.com
Thank you for the fix!
I'll try it.

>> Just to say, a benefit which came in Java 17 I believe was better NPE errors

Exactly.
We planning to update to Java 17 this year.



2023年4月13日(木) 16:45 Rob Bygrave <robin....@gmail.com>:
> You received this message because you are subscribed to a topic in the Google Groups "Ebean ORM" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/ebean/wGiGKQ52Hh8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to ebean+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ebean/f88a5601-343a-44b6-a88e-c08d557e300bn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages