You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Udi <Sa...@gmail.com> on 2009/05/27 10:02:41 UTC

NullPointerException in pcReplaceField

Hey,
I don't know yet how to force this situation, but it happens a lot:
I get a NullPointerException caused by pcReplaceField.
I can't paste the stack but it goes something like:
...
caused bu: java.lang.NullPointerException
        at MyProjrct.entities.Tree.pcReplaceField(Tree)
and here some statemanager calls.

I'm pretty sure that the exception is not caused because of a detached
entity..
Is there any known issue for that? What can cause this exception?

thanks,
Udi
-- 
View this message in context: http://n2.nabble.com/NullPointerException-in-pcReplaceField-tp2979657p2979657.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: NullPointerException in pcReplaceField

Posted by rpalache <ra...@oracle.com>.
Hi Mike,

The openJPA test case for http://issues.apache.org/jira/browse/OPENJPA-453
can be found under one of my previous posts :
http://n2.nabble.com/Evicting-an-embedded-object.-td2528068.html#a2551873

You can also download directly from:
http://n2.nabble.com/file/n2551873/openJPATestCase.zip

The above test case can not replicate nullpointer exception but will nullify
the state manager on 
evicting the embedded object.

Regarding the test case for nullpointer Exception, I have a JDO sample for
this.
In the JDO sample I can clearly replicate the nullpointer.
Modified the same test case to use JPA specific api's.
Doing so is resulting in a hung process rather than a nullpointer.

Please let me know if you want this test case also.

Udi,
If you have openJPA specific testcase, that can result in nullpointer, then
please upload it.

Regards,
Ravi.



Michael Dick wrote:
> 
> Hi Ravi and Udi
> 
> This is interesting, the issue referenced mentions JDOHelper (not part of
> OpenJPA) and Kodo 4.4. I wouldn't have been sure it applied to OpenJPA.
> 
> Do either of you have a testcase that reproduces the issue without JDO?
> 
> -mike
> 
> On Wed, May 27, 2009 at 8:13 AM, Ravi Palacherla
> <ravi.palacherla@oracle.com
>> wrote:
> 
>> Sorry, I do not have a proper resolution for this.
>>
>> The following JIRA was already opened for this:
>> http://issues.apache.org/jira/browse/OPENJPA-453
>>
>> It is currently unassigned.
>>
>> I think the cause of the issue is, if you have multithreaded environment
>> and when transactions begin and end, all
>> references to embedded objects become invalid. Reacquiring the reference
>> from owning persistent object is the
>> only workaround that I know of.
>>
>> Regards,
>> Ravi.
>>
>> -----Original Message-----
>> From: Udi [mailto:SabaUdi@gmail.com]
>> Sent: Wednesday, May 27, 2009 6:27 AM
>> To: users@openjpa.apache.org
>> Subject: RE: NullPointerException in pcReplaceField
>>
>>
>> Hey Ravi,
>> Thanks for the comment. "Tree" is indeed an embedded object...
>> What did you do with this exception?
>> --
>> View this message in context:
>> http://n2.nabble.com/NullPointerException-in-pcReplaceField-tp2979657p2980726.html
>> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://n2.nabble.com/NullPointerException-in-pcReplaceField-tp2979657p2982532.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


RE: NullPointerException in pcReplaceField

Posted by Ravi Palacherla <ra...@oracle.com>.
Mike,

I think I have an openJPA test case for this issue.
I will update the JIRA with openJPA specific test case , as soon as I find it.

Regards,
Ravi.

-----Original Message-----
From: Michael Dick [mailto:michael.d.dick@gmail.com] 
Sent: Wednesday, May 27, 2009 8:21 AM
To: users@openjpa.apache.org
Subject: Re: NullPointerException in pcReplaceField

Hi Ravi and Udi

This is interesting, the issue referenced mentions JDOHelper (not part of
OpenJPA) and Kodo 4.4. I wouldn't have been sure it applied to OpenJPA.

Do either of you have a testcase that reproduces the issue without JDO?

-mike

On Wed, May 27, 2009 at 8:13 AM, Ravi Palacherla <ravi.palacherla@oracle.com
> wrote:

> Sorry, I do not have a proper resolution for this.
>
> The following JIRA was already opened for this:
> http://issues.apache.org/jira/browse/OPENJPA-453
>
> It is currently unassigned.
>
> I think the cause of the issue is, if you have multithreaded environment
> and when transactions begin and end, all
> references to embedded objects become invalid. Reacquiring the reference
> from owning persistent object is the
> only workaround that I know of.
>
> Regards,
> Ravi.
>
> -----Original Message-----
> From: Udi [mailto:SabaUdi@gmail.com]
> Sent: Wednesday, May 27, 2009 6:27 AM
> To: users@openjpa.apache.org
> Subject: RE: NullPointerException in pcReplaceField
>
>
> Hey Ravi,
> Thanks for the comment. "Tree" is indeed an embedded object...
> What did you do with this exception?
> --
> View this message in context:
> http://n2.nabble.com/NullPointerException-in-pcReplaceField-tp2979657p2980726.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
>

Re: NullPointerException in pcReplaceField

Posted by Michael Dick <mi...@gmail.com>.
Hi Ravi and Udi

This is interesting, the issue referenced mentions JDOHelper (not part of
OpenJPA) and Kodo 4.4. I wouldn't have been sure it applied to OpenJPA.

Do either of you have a testcase that reproduces the issue without JDO?

-mike

On Wed, May 27, 2009 at 8:13 AM, Ravi Palacherla <ravi.palacherla@oracle.com
> wrote:

> Sorry, I do not have a proper resolution for this.
>
> The following JIRA was already opened for this:
> http://issues.apache.org/jira/browse/OPENJPA-453
>
> It is currently unassigned.
>
> I think the cause of the issue is, if you have multithreaded environment
> and when transactions begin and end, all
> references to embedded objects become invalid. Reacquiring the reference
> from owning persistent object is the
> only workaround that I know of.
>
> Regards,
> Ravi.
>
> -----Original Message-----
> From: Udi [mailto:SabaUdi@gmail.com]
> Sent: Wednesday, May 27, 2009 6:27 AM
> To: users@openjpa.apache.org
> Subject: RE: NullPointerException in pcReplaceField
>
>
> Hey Ravi,
> Thanks for the comment. "Tree" is indeed an embedded object...
> What did you do with this exception?
> --
> View this message in context:
> http://n2.nabble.com/NullPointerException-in-pcReplaceField-tp2979657p2980726.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
>

RE: NullPointerException in pcReplaceField

Posted by Ravi Palacherla <ra...@oracle.com>.
Sorry, I do not have a proper resolution for this.

The following JIRA was already opened for this:
http://issues.apache.org/jira/browse/OPENJPA-453

It is currently unassigned.

I think the cause of the issue is, if you have multithreaded environment and when transactions begin and end, all
references to embedded objects become invalid. Reacquiring the reference from owning persistent object is the 
only workaround that I know of.

Regards,
Ravi.

-----Original Message-----
From: Udi [mailto:SabaUdi@gmail.com] 
Sent: Wednesday, May 27, 2009 6:27 AM
To: users@openjpa.apache.org
Subject: RE: NullPointerException in pcReplaceField


Hey Ravi,
Thanks for the comment. "Tree" is indeed an embedded object...
What did you do with this exception?
-- 
View this message in context: http://n2.nabble.com/NullPointerException-in-pcReplaceField-tp2979657p2980726.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


RE: NullPointerException in pcReplaceField

Posted by Udi <Sa...@gmail.com>.
Hey Ravi,
Thanks for the comment. "Tree" is indeed an embedded object...
What did you do with this exception?
-- 
View this message in context: http://n2.nabble.com/NullPointerException-in-pcReplaceField-tp2979657p2980726.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


RE: NullPointerException in pcReplaceField

Posted by Ravi Palacherla <ra...@oracle.com>.
Hi Udi,

I saw a similar exception while using embedded objects.
Is "Tree" an Embeddable object ?

Regards,
Ravi.

-----Original Message-----
From: Udi [mailto:SabaUdi@gmail.com] 
Sent: Wednesday, May 27, 2009 2:03 AM
To: users@openjpa.apache.org
Subject: NullPointerException in pcReplaceField


Hey,
I don't know yet how to force this situation, but it happens a lot:
I get a NullPointerException caused by pcReplaceField.
I can't paste the stack but it goes something like:
...
caused bu: java.lang.NullPointerException
        at MyProjrct.entities.Tree.pcReplaceField(Tree)
and here some statemanager calls.

I'm pretty sure that the exception is not caused because of a detached
entity..
Is there any known issue for that? What can cause this exception?

thanks,
Udi
-- 
View this message in context: http://n2.nabble.com/NullPointerException-in-pcReplaceField-tp2979657p2979657.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Re: NullPointerException in pcReplaceField

Posted by Michael Dick <mi...@gmail.com>.
Thanks for the testcase Ravi, I've copied your response verbatim into the
JIRA issue. If you wouldn't mind attaching the testcase to the JIRA that
might help as well. I'd do it but I don't want to make assumptions about
granting a license to the ASF on your behalf..


-mike

On Wed, May 27, 2009 at 12:55 PM, rpalache <ra...@oracle.com>wrote:

>
> Hi Mike,
>
> I am able to replicate the nullpointer exception with openJPA
>
> Exception in thread "Thread-1" java.lang.NullPointerException
>        at
>
> org.apache.openjpa.kernel.StateManagerImpl.replaceObjectField(StateManagerImpl.java:2090)
>
>        at Book.pcReplaceField(Book.java)
>        at
>
> org.apache.openjpa.kernel.StateManagerImpl.replaceField(StateManagerImpl.java:3056)
>        at
>
> org.apache.openjpa.kernel.StateManagerImpl.clearFields(StateManagerImpl.java:2665)
>        at
>
> org.apache.openjpa.kernel.PNonTransState.beforeWrite(PNonTransState.java:107)
>        at
>
> org.apache.openjpa.kernel.PNonTransState.beforeWrite(PNonTransState.java:77)
>        at
>
> org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1608)
>        at
>
> org.apache.openjpa.kernel.StateManagerImpl.settingStringField(StateManagerImpl.java:1976)
>
>        at Book.pcSettitle(Book.java)
>        at Book.setTitle(Book.java:23)
>        at Main$2.run(Main.java:60)
>        at java.lang.Thread.run(Thread.java:595)
>
> You can download the test case from:
> http://n2.nabble.com/file/n2982705/embeddopenJPA.zip embeddopenJPA.zip
>
> If you verify I set the property "<property name="openjpa.Multithreaded"
> value="false"/>" even though I am spawning threads in my sample.
>
> When I correct this configuration by changing MultiThreaded property to
> "true" then my test case hangs.
>
> Please let me know if you need more information.
>
> Udi,
> Please validate my test case to see if it is in sync with your application.
>
> - Ravi.
>
>
>
> Udi wrote:
> >
> > Hey,
> > I don't know yet how to force this situation, but it happens a lot:
> > I get a NullPointerException caused by pcReplaceField.
> > I can't paste the stack but it goes something like:
> > ...
> > caused bu: java.lang.NullPointerException
> >         at MyProjrct.entities.Tree.pcReplaceField(Tree)
> > and here some statemanager calls.
> >
> > I'm pretty sure that the exception is not caused because of a detached
> > entity..
> > Is there any known issue for that? What can cause this exception?
> >
> > thanks,
> > Udi
> >
>
> --
> View this message in context:
> http://n2.nabble.com/NullPointerException-in-pcReplaceField-tp2979657p2982705.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
>

Re: NullPointerException in pcReplaceField

Posted by rpalache <ra...@oracle.com>.
Hi Mike,

I am able to replicate the nullpointer exception with openJPA

Exception in thread "Thread-1" java.lang.NullPointerException
        at
org.apache.openjpa.kernel.StateManagerImpl.replaceObjectField(StateManagerImpl.java:2090)

        at Book.pcReplaceField(Book.java)
        at
org.apache.openjpa.kernel.StateManagerImpl.replaceField(StateManagerImpl.java:3056)
        at
org.apache.openjpa.kernel.StateManagerImpl.clearFields(StateManagerImpl.java:2665)
        at
org.apache.openjpa.kernel.PNonTransState.beforeWrite(PNonTransState.java:107)
        at
org.apache.openjpa.kernel.PNonTransState.beforeWrite(PNonTransState.java:77)
        at
org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1608)
        at
org.apache.openjpa.kernel.StateManagerImpl.settingStringField(StateManagerImpl.java:1976)

        at Book.pcSettitle(Book.java)
        at Book.setTitle(Book.java:23)
        at Main$2.run(Main.java:60)
        at java.lang.Thread.run(Thread.java:595)

You can download the test case from:
http://n2.nabble.com/file/n2982705/embeddopenJPA.zip embeddopenJPA.zip 

If you verify I set the property "<property name="openjpa.Multithreaded"
value="false"/>" even though I am spawning threads in my sample.

When I correct this configuration by changing MultiThreaded property to
"true" then my test case hangs.

Please let me know if you need more information.

Udi,
Please validate my test case to see if it is in sync with your application.

- Ravi.



Udi wrote:
> 
> Hey,
> I don't know yet how to force this situation, but it happens a lot:
> I get a NullPointerException caused by pcReplaceField.
> I can't paste the stack but it goes something like:
> ...
> caused bu: java.lang.NullPointerException
>         at MyProjrct.entities.Tree.pcReplaceField(Tree)
> and here some statemanager calls.
> 
> I'm pretty sure that the exception is not caused because of a detached
> entity..
> Is there any known issue for that? What can cause this exception?
> 
> thanks,
> Udi
> 

-- 
View this message in context: http://n2.nabble.com/NullPointerException-in-pcReplaceField-tp2979657p2982705.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.