JPOX enhancer bug
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > Apache Server configuration support > Apache JDO Project > JPOX enhancer bug




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    JPOX enhancer bug  
Michael Watzek


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-10-05 10:45 PM

Hi Andy,

I'm investigating JDO-100 ("Insert request failed ... because it would
have caused a duplicate key value").

The duplicate key exception is thrown because there is an exception in a
previous run during teardown preventing to delete the instance in the
datastore.

That exception is a NoSuchMethodError thrown by the enhanced code (see
below) of a class "PCPointSingleFieldDate" in methods
"jdoCopyKeyFieldsFromObjectId". I decompiled the code of that class. It
seems that the JPOX enhancer generates a java.util.Date constructor call
that does not exist. This is an excerpt of the decompiled code:

protected void jdoCopyKeyFieldsFromObjectId(Object oid)
{
if(!(oid instanceof ObjectIdentity))
{
throw new ClassCastException("key class is not
javax.jdo.identity.ObjectIdentity or null");
} else
{
ObjectIdentity o = (ObjectIdentity)oid;
id = new Date(o.getKey());
return;
}
}

Regards,
Michael

[java]
 testSingleFieldIdentityInitializedDate(o
rg.apache.jdo.tck.api.persistencecap
able.NewObjectIdInstance)javax
.jdo.JDOFatalException: Exception during tearDown
[java]      at org.apache.jdo.tck.JDO_Test.tearDown(JDO_Test.java:281)
[java]      at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:211)
[java]      at
org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:128)
[java]      at
org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:106)
[java] NestedThrowablesStackTrace:
[java] java.lang.NoSuchMethodError:
java.util.Date.<init>(Ljava/lang/Object;)V
[java]      at
org.apache.jdo.tck.pc.singlefieldidentity.PCPointSingleFieldDate.jdoCopyKeyF
ieldsFromObjectId(PCPoint
SingleFieldDate.java)
[java]      at
org.apache.jdo.tck.pc.singlefieldidentity.PCPointSingleFieldDate.jdoNewInsta
nce(PCPointSingleFieldDat
e.java)
[java]      at
javax.jdo.spi.JDOImplHelper.newInstance(JDOImplHelper.java:199)
[java]      at
org.jpox.state.StateManagerImpl.<init>(StateManagerImpl.java:340)
[java]      at
org.jpox.AbstractPersistenceManager. getObjectById(AbstractPersistenceManager

.java:2322)
[java]      at
org.jpox.AbstractPersistenceManager. getObjectById(AbstractPersistenceManager

.java:2230)
[java]      at
org.apache.jdo.tck.JDO_Test.deleteTearDownInstances(JDO_Test.java:336)
[java]      at
org.apache.jdo.tck.JDO_Test.localTearDown(JDO_Test.java:292)
[java]      at org.apache.jdo.tck.JDO_Test.tearDown(JDO_Test.java:263)
[java]      at org.apache.jdo.tck.JDO_Test.runBare(JDO_Test.java:211)
[java]      at
org.apache.jdo.tck.util.BatchTestRunner.start(BatchTestRunner.java:128)
[java]      at
org.apache.jdo.tck.util.BatchTestRunner.main(BatchTestRunner.java:106)
--
-------------------------------------------------------------------
Michael Watzek                  Tech@Spree Engineering GmbH
mailto:mwa.tech@spree.de        Buelowstr. 66
Tel.:  ++49/30/235 520 36       10783 Berlin - Germany
Fax.:  ++49/30/217 520 12       http://www.spree.de/
-------------------------------------------------------------------






[ Post a follow-up to this message ]



    Re: JPOX enhancer bug  
Andy Jefferson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-10-05 10:45 PM

> That exception is a NoSuchMethodError thrown by the enhanced code (see
> below) of a class "PCPointSingleFieldDate" in methods
> "jdoCopyKeyFieldsFromObjectId". I decompiled the code of that class. It
> seems that the JPOX enhancer generates a java.util.Date constructor call
> that does not exist. This is an excerpt of the decompiled code:

Already known about.
Sadly the enhancer can't just put a call in to Craig's JDOImplHelper method 
to
construct a date (since it needs AccessPriveleged adding to the enhanced
classes etc, and since that has implications on enhancement). If that
JDOImplHelper method was just a static call then it would be easy to do, but
it isn't.

--
Andy






[ Post a follow-up to this message ]



    Re: JPOX enhancer bug  
Craig Russell


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-10-05 10:45 PM






[ Post a follow-up to this message ]



    Re: JPOX enhancer bug  
Craig Russell


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-10-05 10:45 PM






[ Post a follow-up to this message ]



    Re: JPOX enhancer bug  
Andy Jefferson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-10-05 10:45 PM

> I've patched the JDOImplHelper class to make the construct method
> static. There are no issues that I can think of to make this method
> static, so I'll change this.
>
> Does this help?

Hi Craig,

Thanks for looking into it. Referring to Michael's mail of the added=20
jdoCopyKeyFieldsFromObjectId() method, the error is at the end where it nee=
ds=20
to create a Date (or Locale, or Currency, or whatever) from the "oid". Is=20
construct() doing this ? or is it doing the reverse (I remember scanning=20
through it when you added ObjectIdentity and seeing the sort of parsing I=20
need to create an object from the oid, but may have been mistaken).

protected void jdoCopyKeyFieldsFromObjectId(Object oid)
=A0 =A0 =A0{
=A0 =A0 =A0 =A0 =A0if(!(oid instanceof ObjectIdentity))
=A0 =A0 =A0 =A0 =A0{
=A0 =A0 =A0 =A0 =A0 =A0 =A0throw new ClassCastException("key class is not =
=20
javax.jdo.identity.ObjectIdentity or null");
=A0 =A0 =A0 =A0 =A0} else
=A0 =A0 =A0 =A0 =A0{
=A0 =A0 =A0 =A0 =A0 =A0 =A0ObjectIdentity o =3D (ObjectIdentity)oid;
=A0 =A0 =A0 =A0 =A0 =A0 =A0id =3D new Date(o.getKey());
=A0 =A0 =A0 =A0 =A0 =A0 =A0return;
=A0 =A0 =A0 =A0 =A0}
=A0 =A0 =A0}

=2D-=20
Andy






[ Post a follow-up to this message ]



    Re: JPOX enhancer bug  
Craig Russell


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-10-05 10:45 PM






[ Post a follow-up to this message ]



    Re: JPOX enhancer bug  
Andy Jefferson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-11-05 12:45 PM

Hi Craig,

> I should have noticed this earlier. There already is a proper Date in
> the ObjectIdentity oid instance and all you need to do is to get it
> and cast it.

I should have noticed that one earlier too, much earlier :-)
Enhancer "jdoCopyKeyFieldsFromObjectId" methods are now fixed in CVS (will b
e
in build on 12/08/2005)

--
Andy






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:48 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register