Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » ClassCastExeption with Elistwrapper
ClassCastExeption with Elistwrapper [message #79914] Mon, 16 April 2007 16:12 Go to next message
Eclipse UserFriend
Originally posted by: daniel.bret.w.wanadoo.fr

hi,
I get an error when I try to update a record in the database (but no problem
to add a new one ?)
Data access failure: Could not invoke JDO makePersistent(Object) method;
nested exception is java.lang.ClassCastException:
org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
org.springframework.dao.InvalidDataAccessResourceUsageExcept ion: Could not
invoke JDO makePersistent(Object) method; nested exception is
java.lang.ClassCastException:
org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
java.lang.ClassCastException:
org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 at
org.eclipse.emf.teneo.jpox.elist.EListWrapper.attachCopy(ELi stWrapper.java:431)
at
org.jpox.state.AttachFieldManager.storeObjectField(AttachFie ldManager.java:157)
at
org.jpox.state.StateManagerImpl.providedObjectField(StateMan agerImpl.java:2748)
at org.MyClassImpl.jdoProvideField(MyClassImpl.java) at....

the error is a ClassCastException thrown from the spring webcontainer method
public class JdoTemplate extends JdoAccessor implements JdoOperations {
......
public void makePersistent(final Object entity) throws DataAccessException {
execute(new JdoCallback() {
public Object doInJdo(PersistenceManager pm) throws JDOException {
try {
return makePersistentMethod.invoke(pm, new Object[] {entity});
}
catch (InvocationTargetException ex) {
throw new InvalidDataAccessResourceUsageException(
"Could not invoke JDO makePersistent(Object) method",
ex.getTargetException());
.......

and the eclipse debugger seems to say that there is a nullPointerException
in the EListWrapper attachCopy method execution :
public class EListWrapper<E> extends PersistableEList<E> implements SCO,
Queryable, SCOList {
.....
public void attachCopy(Object value) {
// if not loaded then nothing changed so nothing to attach
assert (value instanceof PersistableEList);
if (!((PersistableEList) value).isLoaded())
return;
.....
because "binding error on value"... which is null ("binding ==null for
value")

but the call, from the org.jpox.state.StateManager to the teneo sco class
(ElistWapper) seems to be good
public class AttachFieldManager extends AbstractFieldManager
{
......
public void storeObjectField(int fieldNumber, Object value)
{
......
sco.attachCopy(value);
......
sco and value are ElistWapper$1, empty but not null

the teneo log seems to be good :
....
15:53:55,625 (http-8080-Processor23) DEBUG
[org.eclipse.emf.teneo.mapping.elist.PersistableEList] - Loading EList of
type: org.eclipse.emf.teneo.jpox.elist.EListWrapper of member myField (that
cause the error) owned by MyClass with delegate list java.util.ArrayList
....
I use Eclipse3.2, EMF 2.2.2, teneo : emft-teneo-SDK-I200703301643, Jpox1.3
(to stay compatible withe Spring 1.2.X for syntax reason), Spring 1.2.8.
I've tried with Eclipse3.3, EMF 2.3, teneo : emft-teneo-SDK-I200703301643
etc... and that's the same

To be able to send you an example to reproduce to problem, I'tried to shrink
my webapp to the 3 or 4 classes with the field which cause the error... but
in this case, I have no error...?
I don't know where to search the error

Thanks
Daniel
Re: ClassCastExeption with Elistwrapper [message #79929 is a reply to message #79914] Mon, 16 April 2007 18:07 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Daniel,
Is it a nullpointerexception or a classcastexception (you mention both)?
You can't upgrade to jpox 1.1.7?

Which line in elistwrapper does it happen (my line 431 in cvs seems to be iter.hasNext which I can't
imagine to be the cause of the classcastexception)?

gr. Martin

daniel wrote:
> hi,
> I get an error when I try to update a record in the database (but no problem
> to add a new one ?)
> Data access failure: Could not invoke JDO makePersistent(Object) method;
> nested exception is java.lang.ClassCastException:
> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
> org.springframework.dao.InvalidDataAccessResourceUsageExcept ion: Could not
> invoke JDO makePersistent(Object) method; nested exception is
> java.lang.ClassCastException:
> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
> java.lang.ClassCastException:
> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 at
> org.eclipse.emf.teneo.jpox.elist.EListWrapper.attachCopy(ELi stWrapper.java:431)
> at
> org.jpox.state.AttachFieldManager.storeObjectField(AttachFie ldManager.java:157)
> at
> org.jpox.state.StateManagerImpl.providedObjectField(StateMan agerImpl.java:2748)
> at org.MyClassImpl.jdoProvideField(MyClassImpl.java) at....
>
> the error is a ClassCastException thrown from the spring webcontainer method
> public class JdoTemplate extends JdoAccessor implements JdoOperations {
> ......
> public void makePersistent(final Object entity) throws DataAccessException {
> execute(new JdoCallback() {
> public Object doInJdo(PersistenceManager pm) throws JDOException {
> try {
> return makePersistentMethod.invoke(pm, new Object[] {entity});
> }
> catch (InvocationTargetException ex) {
> throw new InvalidDataAccessResourceUsageException(
> "Could not invoke JDO makePersistent(Object) method",
> ex.getTargetException());
> .......
>
> and the eclipse debugger seems to say that there is a nullPointerException
> in the EListWrapper attachCopy method execution :
> public class EListWrapper<E> extends PersistableEList<E> implements SCO,
> Queryable, SCOList {
> .....
> public void attachCopy(Object value) {
> // if not loaded then nothing changed so nothing to attach
> assert (value instanceof PersistableEList);
> if (!((PersistableEList) value).isLoaded())
> return;
> .....
> because "binding error on value"... which is null ("binding ==null for
> value")
>
> but the call, from the org.jpox.state.StateManager to the teneo sco class
> (ElistWapper) seems to be good
> public class AttachFieldManager extends AbstractFieldManager
> {
> ......
> public void storeObjectField(int fieldNumber, Object value)
> {
> ......
> sco.attachCopy(value);
> ......
> sco and value are ElistWapper$1, empty but not null
>
> the teneo log seems to be good :
> ....
> 15:53:55,625 (http-8080-Processor23) DEBUG
> [org.eclipse.emf.teneo.mapping.elist.PersistableEList] - Loading EList of
> type: org.eclipse.emf.teneo.jpox.elist.EListWrapper of member myField (that
> cause the error) owned by MyClass with delegate list java.util.ArrayList
> ....
> I use Eclipse3.2, EMF 2.2.2, teneo : emft-teneo-SDK-I200703301643, Jpox1.3
> (to stay compatible withe Spring 1.2.X for syntax reason), Spring 1.2.8.
> I've tried with Eclipse3.3, EMF 2.3, teneo : emft-teneo-SDK-I200703301643
> etc... and that's the same
>
> To be able to send you an example to reproduce to problem, I'tried to shrink
> my webapp to the 3 or 4 classes with the field which cause the error... but
> in this case, I have no error...?
> I don't know where to search the error
>
> Thanks
> Daniel
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: ClassCastExeption with Elistwrapper [message #79946 is a reply to message #79929] Mon, 16 April 2007 21:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel.bret.w.wanadoo.fr

This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C7807E.16D4ADE0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

hi Martin
it happens like this :
a ClassCastException is thrown from the spring webcontainer method, by =
the catch

public class JdoTemplate extends JdoAccessor implements JdoOperations {
......
public void makePersistent(final Object entity) throws =
DataAccessException {
execute(new JdoCallback() {
public Object doInJdo(PersistenceManager pm) throws JDOException {
try { ///// this try fails so the following catch send the =
ClassCastException
(1) return makePersistentMethod.invoke(pm, new Object[] {entity});
}
catch (InvocationTargetException ex) { ///send the ClassCastException =20
throw new InvalidDataAccessResourceUsageException(
"Could not invoke JDO makePersistent(Object) method", =
ex.getTargetException());
.......


but the call within this try (1) ("return =
makePersistentMethod.invoke(pm, new Object[] {entity});") fails =
because... according to the Eclipse debugger, =20
a nullPointerException occur in the EListWrapper attachCopy method =
execution, (=3D=3D> called by the "makePersistentMethod.invoke" )

and the line 431 is "if (!((PersistableEList) value).isLoaded())"=20

public class EListWrapper<E> extends PersistableEList<E> implements SCO, =
Queryable, SCOList {
.....
public void attachCopy(Object value) {
// if not loaded then nothing changed so nothing to attach
line430 >> assert (value instanceof PersistableEList);
line431 >> if (!((PersistableEList) value).isLoaded())=20
return;
.....
upgrade to jpox 1.1.7? I've read somewhere in Jpox forum that "above =
Jpox 113 only Spring 2 is compatible and I didn't want to change my jsp =
code for the spring 2 forms syntax...

but, I just try with jpox117 and...=20

1- it doesn't seem to make problems with spring forms syntax, at first =
look...
2- error messages from the eclipse debugger is a bit clearer :
for line 430 execution : >> value instanceof PersistableEList"=3D false=20
for line 431 execution : >> ClassCastException: Cannot cast =
org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 (id=3D217) to =
org.eclipse.emf.teneo.mapping.elist.PersistableEList=20

gr. Daniel




"Martin Taal" <mtaal@elver.org> a =E9crit dans le message de news: =
f00e1v$88a$1@build.eclipse.org...
> Hi Daniel,
> Is it a nullpointerexception or a classcastexception (you mention =
both)?
> You can't upgrade to jpox 1.1.7?
>=20
> Which line in elistwrapper does it happen (my line 431 in cvs seems to =
be iter.hasNext which I can't=20
> imagine to be the cause of the classcastexception)?
>=20
> gr. Martin
>=20
> daniel wrote:
>> hi,
>> I get an error when I try to update a record in the database (but no =
problem=20
>> to add a new one ?)
>> Data access failure: Could not invoke JDO makePersistent(Object) =
method;=20
>> nested exception is java.lang.ClassCastException:=20
>> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
>> org.springframework.dao.InvalidDataAccessResourceUsageExcept ion: =
Could not=20
>> invoke JDO makePersistent(Object) method; nested exception is=20
>> java.lang.ClassCastException:=20
>> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1=20
>> java.lang.ClassCastException:=20
>> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 at=20
>> =
org.eclipse.emf.teneo.jpox.elist.EListWrapper.attachCopy(ELi stWrapper.jav=
a:431)=20
>> at=20
>> =
org.jpox.state.AttachFieldManager.storeObjectField(AttachFie ldManager.jav=
a:157)=20
>> at=20
>> =
org.jpox.state.StateManagerImpl.providedObjectField(StateMan agerImpl.java=
:2748)=20
>> at org.MyClassImpl.jdoProvideField(MyClassImpl.java) at....
>>=20
>> the error is a ClassCastException thrown from the spring webcontainer =
method
>> public class JdoTemplate extends JdoAccessor implements JdoOperations =
{
>> ......
>> public void makePersistent(final Object entity) throws =
DataAccessException {
>> execute(new JdoCallback() {
>> public Object doInJdo(PersistenceManager pm) throws JDOException {
>> try {
>> return makePersistentMethod.invoke(pm, new Object[] {entity});
>> }
>> catch (InvocationTargetException ex) {
>> throw new InvalidDataAccessResourceUsageException(
>> "Could not invoke JDO makePersistent(Object) method",=20
>> ex.getTargetException());
>> .......
>>=20
>> and the eclipse debugger seems to say that there is a =
nullPointerException=20
>> in the EListWrapper attachCopy method execution :
>> public class EListWrapper<E> extends PersistableEList<E> implements =
SCO,=20
>> Queryable, SCOList {
>> .....
>> public void attachCopy(Object value) {
>> // if not loaded then nothing changed so nothing to attach
>> assert (value instanceof PersistableEList);
>> if (!((PersistableEList) value).isLoaded())
>> return;
>> .....
>> because "binding error on value"... which is null ("binding =
=3D=3Dnull for=20
>> value")
>>=20
>> but the call, from the org.jpox.state.StateManager to the teneo sco =
class=20
>> (ElistWapper) seems to be good
>> public class AttachFieldManager extends AbstractFieldManager
>> {
>> ......
>> public void storeObjectField(int fieldNumber, Object value)
>> {
>> ......
>> sco.attachCopy(value);
>> ......
>> sco and value are ElistWapper$1, empty but not null
>>=20
>> the teneo log seems to be good :
>> ....
>> 15:53:55,625 (http-8080-Processor23) DEBUG=20
>> [org.eclipse.emf.teneo.mapping.elist.PersistableEList] - Loading =
EList of=20
>> type: org.eclipse.emf.teneo.jpox.elist.EListWrapper of member myField =
(that=20
>> cause the error) owned by MyClass with delegate list =
java.util.ArrayList
>> ....
>> I use Eclipse3.2, EMF 2.2.2, teneo : emft-teneo-SDK-I200703301643, =
Jpox1.3=20
>> (to stay compatible withe Spring 1.2.X for syntax reason), Spring =
1.2.8.
>> I've tried with Eclipse3.3, EMF 2.3, teneo : =
emft-teneo-SDK-I200703301643=20
>> etc... and that's the same
>>=20
>> To be able to send you an example to reproduce to problem, I'tried to =
shrink=20
>> my webapp to the 3 or 4 classes with the field which cause the =
error... but=20
>> in this case, I have no error...?
>> I don't know where to search the error
>>=20
>> Thanks
>> Daniel=20
>>=20
>>=20
>=20
>=20
> --=20
>=20
> With Regards, Martin Taal
>=20
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Tel: +31 (0)84 420 2397
> Fax: +31 (0)84 225 9307
> Mail: mtaal@springsite.com - mtaal@elver.org
> Web: www.springsite.com - www.elver.org
------=_NextPart_000_0007_01C7807E.16D4ADE0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16414" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>hi Martin</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>it happens like this :</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>a&nbsp;ClassCastException is thrown =
from the spring=20
webcontainer method, by the catch</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>public class JdoTemplate extends =
JdoAccessor=20
implements JdoOperations {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>.....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>public void makePersistent(final Object =
entity)=20
throws DataAccessException {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>execute(new JdoCallback() =
{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>public Object =
doInJdo(PersistenceManager pm) throws=20
JDOException {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>try { <FONT color=3D#ff0000>///// this =
try fails so=20
the following catch send the ClassCastException</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>(1) return =
makePersistentMethod.invoke(pm, new=20
Object[] {entity});</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT color=3D#ff0000>catch</FONT>=20
(InvocationTargetException ex) {&nbsp;///send the=20
ClassCastException</FONT>&nbsp;&nbsp; </DIV>
<DIV><FONT face=3DArial size=3D2>throw new=20
InvalidDataAccessResourceUsageException(</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>"Could not invoke JDO =
makePersistent(Object)=20
method", ex.getTargetException());</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>......</FONT></DIV>
<P><FONT face=3DArial size=3D2></FONT>&nbsp;</P>
<DIV><FONT face=3DArial size=3D2>but the call within this try (1) =
("return=20
makePersistentMethod.invoke(pm, new Object[] {entity});") fails =
because...=20
according to the Eclipse debugger,&nbsp; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>a nullPointerException occur in the =
EListWrapper=20
attachCopy method execution, (=3D=3D&gt; called by=20
the&nbsp;"makePersistentMethod.invoke"&nbsp;)</FONT ></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>and the line 431 is "if =
(!((PersistableEList)=20
value).isLoaded())"&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>public class EListWrapper&lt;E&gt; =
extends=20
PersistableEList&lt;E&gt; implements SCO, Queryable, SCOList =
{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>public void attachCopy(Object value) =
{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>// if not loaded then nothing changed =
so nothing to=20
attach</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>line430 &gt;&gt; assert (value =
instanceof=20
PersistableEList);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>line431 &gt;&gt;&nbsp;if =
(!((PersistableEList)=20
value).isLoaded()) </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>return;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>....</FONT></DIV>
<P><FONT face=3DArial size=3D2>upgrade to jpox 1.1.7? I've read =
somewhere in Jpox=20
forum that "above Jpox 113 only Spring 2 is compatible and I didn't want =
to=20
change my jsp code&nbsp;for the&nbsp;spring 2 forms syntax...</FONT></P>
<P><FONT face=3DArial size=3D2>but, I just try with jpox117 and... =
</FONT></P>
<DIV><FONT face=3DArial size=3D2>1- it doesn't seem to make problems =
with spring=20
forms syntax, at first look...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>2- error messages from the eclipse =
debugger is a=20
bit clearer :</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>for line 430 execution : &gt;&gt; <FONT =

color=3D#ff0000><STRONG>value instanceof PersistableEList"=3D=20
false</STRONG></FONT>&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>for line 431 execution : &gt;&gt; <FONT =

color=3D#ff0000><STRONG>ClassCastException: Cannot cast=20
org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 (id=3D217) to=20
org.eclipse.emf.teneo.mapping.elist.PersistableEList</STRONG ></FONT>&nbsp=
;<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>gr. Daniel</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;</DIV>
<DIV><BR></DIV></FONT>
<DIV><FONT face=3DArial size=3D2>"Martin Taal" &lt;</FONT><A=20
href=3D"mailto:mtaal@elver.org"><FONT face=3DArial=20
size=3D2>mtaal@elver.org</FONT></A><FONT face=3DArial size=3D2>&gt; a =
=E9crit dans le=20
message de news: </FONT><A =
href=3D"mailto:f00e1v$88a$1@build.eclipse.org"><FONT=20
face=3DArial size=3D2>f00e1v$88a$1@build.eclipse.org</FONT></A><FONT =
face=3DArial=20
size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>&gt; Hi =
Daniel,<BR>&gt; Is it a=20
nullpointerexception or a classcastexception (you mention both)?<BR>&gt; =
You=20
can't upgrade to jpox 1.1.7?<BR>&gt; <BR>&gt; Which line in elistwrapper =
does it=20
happen (my line 431 in cvs seems to be iter.hasNext which I can't =
<BR>&gt;=20
imagine to be the cause of the classcastexception)?<BR>&gt; <BR>&gt; gr. =

Martin<BR>&gt; <BR>&gt; daniel wrote:<BR>&gt;&gt; hi,<BR>&gt;&gt; I get =
an error=20
when I try to update a record in the database (but no problem =
<BR>&gt;&gt; to=20
add a new one ?)<BR>&gt;&gt; Data access failure: Could not invoke JDO=20
makePersistent(Object) method; <BR>&gt;&gt; nested exception is=20
java.lang.ClassCastException: <BR>&gt;&gt;=20
org.eclipse.emf.teneo.jpox.elist.EListWrapper$1<BR>&gt;&gt;=20
org.springframework.dao.InvalidDataAccessResourceUsageExcept ion: Could =
not=20
<BR>&gt;&gt; invoke JDO makePersistent(Object) method; nested exception =
is=20
<BR>&gt;&gt; java.lang.ClassCastException: <BR>&gt;&gt;=20
org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 <BR>&gt;&gt;=20
java.lang.ClassCastException: <BR>&gt;&gt;=20
org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 at <BR>&gt;&gt;=20
org.eclipse.emf.teneo.jpox.elist.EListWrapper.attachCopy(ELi stWrapper.jav=
a:431)=20
<BR>&gt;&gt; at <BR>&gt;&gt;=20
org.jpox.state.AttachFieldManager.storeObjectField(AttachFie ldManager.jav=
a:157)=20
<BR>&gt;&gt; at <BR>&gt;&gt;=20
org.jpox.state.StateManagerImpl.providedObjectField(StateMan agerImpl.java=
:2748)=20
<BR>&gt;&gt; at org.MyClassImpl.jdoProvideField(MyClassImpl.java)=20
at....<BR>&gt;&gt; <BR>&gt;&gt; the error is a ClassCastException thrown =
from=20
the spring webcontainer method<BR>&gt;&gt; public class JdoTemplate =
extends=20
JdoAccessor implements JdoOperations {<BR>&gt;&gt; ......<BR>&gt;&gt; =
public=20
void makePersistent(final Object entity) throws DataAccessException=20
{<BR>&gt;&gt; execute(new JdoCallback() {<BR>&gt;&gt; public Object=20
doInJdo(PersistenceManager pm) throws JDOException {<BR>&gt;&gt; try=20
{<BR>&gt;&gt; return makePersistentMethod.invoke(pm, new Object[]=20
{entity});<BR>&gt;&gt; }<BR>&gt;&gt; catch (InvocationTargetException =
ex)=20
{<BR>&gt;&gt; throw new =
InvalidDataAccessResourceUsageException(<BR>&gt;&gt;=20
"Could not invoke JDO makePersistent(Object) method", <BR>&gt;&gt;=20
ex.getTargetException());<BR>&gt;&gt; .......<BR>&gt;&gt; <BR>&gt;&gt; =
and the=20
eclipse debugger seems to say that there is a nullPointerException =
<BR>&gt;&gt;=20
in the EListWrapper attachCopy method execution :<BR>&gt;&gt; public =
class=20
EListWrapper&lt;E&gt; extends PersistableEList&lt;E&gt; implements SCO,=20
<BR>&gt;&gt; Queryable, SCOList {<BR>&gt;&gt; .....<BR>&gt;&gt; public =
void=20
attachCopy(Object value) {<BR>&gt;&gt; // if not loaded then nothing =
changed so=20
nothing to attach<BR>&gt;&gt; assert (value instanceof=20
PersistableEList);<BR>&gt;&gt; if (!((PersistableEList)=20
value).isLoaded())<BR>&gt;&gt; return;<BR>&gt;&gt; .....<BR>&gt;&gt; =
because=20
"binding error on value"... which is null ("binding =3D=3Dnull for =
<BR>&gt;&gt;=20
value")<BR>&gt;&gt; <BR>&gt;&gt; but the call, from the=20
org.jpox.state.StateManager to the teneo sco class <BR>&gt;&gt; =
(ElistWapper)=20
seems to be good<BR>&gt;&gt; public class AttachFieldManager extends=20
AbstractFieldManager<BR>&gt;&gt; {<BR>&gt;&gt; ......<BR>&gt;&gt; public =
void=20
storeObjectField(int fieldNumber, Object value)<BR>&gt;&gt; =
{<BR>&gt;&gt;=20
.......<BR>&gt;&gt; sco.attachCopy(value);<BR>&gt;&gt; ......<BR>&gt;&gt; =
sco and=20
value are ElistWapper$1, empty but not null<BR>&gt;&gt; <BR>&gt;&gt; the =
teneo=20
log seems to be good :<BR>&gt;&gt; ....<BR>&gt;&gt; 15:53:55,625=20
(http-8080-Processor23) DEBUG <BR>&gt;&gt;=20
[org.eclipse.emf.teneo.mapping.elist.PersistableEList] - Loading EList =
of=20
<BR>&gt;&gt; type: org.eclipse.emf.teneo.jpox.elist.EListWrapper of =
member=20
myField (that <BR>&gt;&gt; cause the error) owned by MyClass with =
delegate list=20
java.util.ArrayList<BR>&gt;&gt; ....<BR>&gt;&gt; I use Eclipse3.2, EMF =
2.2.2,=20
teneo : emft-teneo-SDK-I200703301643, Jpox1.3 <BR>&gt;&gt; (to stay =
compatible=20
withe Spring 1.2.X for syntax reason), Spring 1.2.8.<BR>&gt;&gt; I've =
tried with=20
Eclipse3.3, EMF 2.3, teneo : emft-teneo-SDK-I200703301643 <BR>&gt;&gt; =
etc...=20
and that's the same<BR>&gt;&gt; <BR>&gt;&gt; To be able to send you an =
example=20
to reproduce to problem, I'tried to shrink <BR>&gt;&gt; my webapp to the =
3 or 4=20
classes with the field which cause the error... but <BR>&gt;&gt; in this =
case, I=20
have no error...?<BR>&gt;&gt; I don't know where to search the =
error<BR>&gt;&gt;=20
<BR>&gt;&gt; Thanks<BR>&gt;&gt; Daniel <BR>&gt;&gt; <BR>&gt;&gt; =
<BR>&gt;=20
<BR>&gt; <BR>&gt; -- <BR>&gt; <BR>&gt; With Regards, Martin Taal<BR>&gt; =

<BR>&gt; Springsite/Elver.org<BR>&gt; Office: Hardwareweg 4, 3821 BV=20
Amersfoort<BR>&gt; Postal: Nassaulaan 7, 3941 EC Doorn<BR>&gt; The=20
Netherlands<BR>&gt; Tel: +31 (0)84 420 2397<BR>&gt; Fax: +31 (0)84 225=20
9307<BR>&gt; Mail: </FONT><A href=3D"mailto:mtaal@springsite.com"><FONT =
face=3DArial=20
size=3D2>mtaal@springsite.com</FONT></A><FONT face=3DArial size=3D2> - =
</FONT><A=20
href=3D"mailto:mtaal@elver.org"><FONT face=3DArial=20
size=3D2>mtaal@elver.org</FONT></A><BR><FONT face=3DArial size=3D2>&gt; =
Web: </FONT><A=20
href=3D"http://www.springsite.com"><FONT face=3DArial=20
size=3D2>www.springsite.com</FONT></A><FONT face=3DArial size=3D2> - =
</FONT><A=20
href=3D"http://www.elver.org"><FONT face=3DArial=20
size=3D2>www.elver.org</FONT></A></BODY></HTML>

------=_NextPart_000_0007_01C7807E.16D4ADE0--
Re: ClassCastExeption with Elistwrapper [message #79960 is a reply to message #79946] Mon, 16 April 2007 21:45 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Daniel,
Was the instance (EListWrapper$1) created before in a call to detachcopy?

If so then this is a bug and the class casting should not happen in the attachcopy (or the
classcasting should only happen after checking that the instance is a PersistableEList.
You can file a bugzilla for this.

gr. Martin

daniel wrote:
> hi Martin
> it happens like this :
> a ClassCastException is thrown from the spring webcontainer method, by
> the catch
>
> public class JdoTemplate extends JdoAccessor implements JdoOperations {
> .....
> public void makePersistent(final Object entity) throws DataAccessException {
> execute(new JdoCallback() {
> public Object doInJdo(PersistenceManager pm) throws JDOException {
> try { ///// this try fails so the following catch send the
> ClassCastException
> (1) return makePersistentMethod.invoke(pm, new Object[] {entity});
> }
> catch (InvocationTargetException ex) { ///send the ClassCastException
> throw new InvalidDataAccessResourceUsageException(
> "Could not invoke JDO makePersistent(Object) method",
> ex.getTargetException());
> ......
>
>
>
> but the call within this try (1) ("return
> makePersistentMethod.invoke(pm, new Object[] {entity});") fails
> because... according to the Eclipse debugger,
> a nullPointerException occur in the EListWrapper attachCopy method
> execution, (==> called by the "makePersistentMethod.invoke" )
>
> and the line 431 is "if (!((PersistableEList) value).isLoaded())"
>
> public class EListWrapper<E> extends PersistableEList<E> implements SCO,
> Queryable, SCOList {
> ....
> public void attachCopy(Object value) {
> // if not loaded then nothing changed so nothing to attach
> line430 >> assert (value instanceof PersistableEList);
> line431 >> if (!((PersistableEList) value).isLoaded())
> return;
> ....
>
> upgrade to jpox 1.1.7? I've read somewhere in Jpox forum that "above
> Jpox 113 only Spring 2 is compatible and I didn't want to change my jsp
> code for the spring 2 forms syntax...
>
> but, I just try with jpox117 and...
>
> 1- it doesn't seem to make problems with spring forms syntax, at first
> look...
> 2- error messages from the eclipse debugger is a bit clearer :
> for line 430 execution : >> *value instanceof PersistableEList"= false*
> for line 431 execution : >> *ClassCastException: Cannot cast
> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 (id=217) to
> org.eclipse.emf.teneo.mapping.elist.PersistableEList*
> gr. Daniel
>
>
>
> "Martin Taal" <mtaal@elver.org <mailto:mtaal@elver.org>> a écrit dans le
> message de news: f00e1v$88a$1@build.eclipse.org
> <mailto:f00e1v$88a$1@build.eclipse.org>...
> > Hi Daniel,
> > Is it a nullpointerexception or a classcastexception (you mention both)?
> > You can't upgrade to jpox 1.1.7?
> >
> > Which line in elistwrapper does it happen (my line 431 in cvs seems
> to be iter.hasNext which I can't
> > imagine to be the cause of the classcastexception)?
> >
> > gr. Martin
> >
> > daniel wrote:
> >> hi,
> >> I get an error when I try to update a record in the database (but no
> problem
> >> to add a new one ?)
> >> Data access failure: Could not invoke JDO makePersistent(Object)
> method;
> >> nested exception is java.lang.ClassCastException:
> >> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
> >> org.springframework.dao.InvalidDataAccessResourceUsageExcept ion:
> Could not
> >> invoke JDO makePersistent(Object) method; nested exception is
> >> java.lang.ClassCastException:
> >> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
> >> java.lang.ClassCastException:
> >> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 at
> >>
> org.eclipse.emf.teneo.jpox.elist.EListWrapper.attachCopy(ELi stWrapper.java:431)
>
> >> at
> >>
> org.jpox.state.AttachFieldManager.storeObjectField(AttachFie ldManager.java:157)
>
> >> at
> >>
> org.jpox.state.StateManagerImpl.providedObjectField(StateMan agerImpl.java:2748)
>
> >> at org.MyClassImpl.jdoProvideField(MyClassImpl.java) at....
> >>
> >> the error is a ClassCastException thrown from the spring
> webcontainer method
> >> public class JdoTemplate extends JdoAccessor implements JdoOperations {
> >> ......
> >> public void makePersistent(final Object entity) throws
> DataAccessException {
> >> execute(new JdoCallback() {
> >> public Object doInJdo(PersistenceManager pm) throws JDOException {
> >> try {
> >> return makePersistentMethod.invoke(pm, new Object[] {entity});
> >> }
> >> catch (InvocationTargetException ex) {
> >> throw new InvalidDataAccessResourceUsageException(
> >> "Could not invoke JDO makePersistent(Object) method",
> >> ex.getTargetException());
> >> .......
> >>
> >> and the eclipse debugger seems to say that there is a
> nullPointerException
> >> in the EListWrapper attachCopy method execution :
> >> public class EListWrapper<E> extends PersistableEList<E> implements
> SCO,
> >> Queryable, SCOList {
> >> .....
> >> public void attachCopy(Object value) {
> >> // if not loaded then nothing changed so nothing to attach
> >> assert (value instanceof PersistableEList);
> >> if (!((PersistableEList) value).isLoaded())
> >> return;
> >> .....
> >> because "binding error on value"... which is null ("binding ==null for
> >> value")
> >>
> >> but the call, from the org.jpox.state.StateManager to the teneo sco
> class
> >> (ElistWapper) seems to be good
> >> public class AttachFieldManager extends AbstractFieldManager
> >> {
> >> ......
> >> public void storeObjectField(int fieldNumber, Object value)
> >> {
> >> .......
> >> sco.attachCopy(value);
> >> ......
> >> sco and value are ElistWapper$1, empty but not null
> >>
> >> the teneo log seems to be good :
> >> ....
> >> 15:53:55,625 (http-8080-Processor23) DEBUG
> >> [org.eclipse.emf.teneo.mapping.elist.PersistableEList] - Loading
> EList of
> >> type: org.eclipse.emf.teneo.jpox.elist.EListWrapper of member
> myField (that
> >> cause the error) owned by MyClass with delegate list java.util.ArrayList
> >> ....
> >> I use Eclipse3.2, EMF 2.2.2, teneo : emft-teneo-SDK-I200703301643,
> Jpox1.3
> >> (to stay compatible withe Spring 1.2.X for syntax reason), Spring 1.2.8.
> >> I've tried with Eclipse3.3, EMF 2.3, teneo :
> emft-teneo-SDK-I200703301643
> >> etc... and that's the same
> >>
> >> To be able to send you an example to reproduce to problem, I'tried
> to shrink
> >> my webapp to the 3 or 4 classes with the field which cause the
> error... but
> >> in this case, I have no error...?
> >> I don't know where to search the error
> >>
> >> Thanks
> >> Daniel
> >>
> >>
> >
> >
> > --
> >
> > With Regards, Martin Taal
> >
> > Springsite/Elver.org
> > Office: Hardwareweg 4, 3821 BV Amersfoort
> > Postal: Nassaulaan 7, 3941 EC Doorn
> > The Netherlands
> > Tel: +31 (0)84 420 2397
> > Fax: +31 (0)84 225 9307
> > Mail: mtaal@springsite.com <mailto:mtaal@springsite.com> -
> mtaal@elver.org <mailto:mtaal@elver.org>
> > Web: www.springsite.com <http://www.springsite.com> - www.elver.org
> <http://www.elver.org>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: ClassCastExeption with Elistwrapper [message #79993 is a reply to message #79960] Tue, 17 April 2007 08:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel.bret.w.wanadoo.fr

Hi Martin
> Was the instance (EListWrapper$1) created before in a call to detachcopy?
the instance (EListWrapper$1) seems to be created in the
KanPatientImpl.jdoProvideField(int) method execution (uneasy because jdo
method are not accessible by debugger) (see jpg debug_01)

after that, the call to EListWrapper seems to be good, with real instance
(not null) (see jpg debug_02)

ant finaly, in the EListWrapper.attachCopy(object) :
1- the "assert (value instanceof PersistableEList);" should send an
exception whereas "value instanceof PersistableEList"= false, shouldn't it ?
2- why value instanceof PersistableEList"= false and why the value
(EListWrapper$1 (id=xxx) cannot be cast to PersistableEList if EListWrapper
is a subclass of PersistableEList (public class EListWrapper<E> extends
PersistableEList<E>.) ? (see jpg debug_03)

I can report that on Eclipse bugzilla EMFT, if you like

gr. Daniel


"Martin Taal" <mtaal@elver.org> a
  • Attachment: debug_01.jpg
    (Size: 130.51KB, Downloaded 136 times)
  • Attachment: debug_02.jpg
    (Size: 150.76KB, Downloaded 138 times)
  • Attachment: debug_03.jpg
    (Size: 114.49KB, Downloaded 163 times)
Re: ClassCastExeption with Elistwrapper [message #80024 is a reply to message #79993] Tue, 17 April 2007 13:52 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Daniel,
Afaik the EListWrapper$1 is not the EListWrapper itself but an anonymous inner class. My guess is
that this one is created in the detachCopy method (you can try by setting a breakpoint there). So
the attachcopy method check on PersistableEList should also check if the type is a PersistableEList
and only check isloaded in that case and allow other cases to pass on.

Can you enter a bugzilla for this?

gr. Martin

daniel wrote:
> Hi Martin
>> Was the instance (EListWrapper$1) created before in a call to detachcopy?
> the instance (EListWrapper$1) seems to be created in the
> KanPatientImpl.jdoProvideField(int) method execution (uneasy because jdo
> method are not accessible by debugger) (see jpg debug_01)
>
> after that, the call to EListWrapper seems to be good, with real instance
> (not null) (see jpg debug_02)
>
> ant finaly, in the EListWrapper.attachCopy(object) :
> 1- the "assert (value instanceof PersistableEList);" should send an
> exception whereas "value instanceof PersistableEList"= false, shouldn't it ?
> 2- why value instanceof PersistableEList"= false and why the value
> (EListWrapper$1 (id=xxx) cannot be cast to PersistableEList if EListWrapper
> is a subclass of PersistableEList (public class EListWrapper<E> extends
> PersistableEList<E>.) ? (see jpg debug_03)
>
> I can report that on Eclipse bugzilla EMFT, if you like
>
> gr. Daniel
>
>
> "Martin Taal" <mtaal@elver.org> a écrit dans le message de news:
> f00qqi$q1e$1@build.eclipse.org...
>> Hi Daniel,
>> Was the instance (EListWrapper$1) created before in a call to detachcopy?
>>
>> If so then this is a bug and the class casting should not happen in the
>> attachcopy (or the
>> classcasting should only happen after checking that the instance is a
>> PersistableEList.
>> You can file a bugzilla for this.
>>
>> gr. Martin
>>
>> daniel wrote:
>>> hi Martin
>>> it happens like this :
>>> a ClassCastException is thrown from the spring webcontainer method, by
>>> the catch
>>>
>>> public class JdoTemplate extends JdoAccessor implements JdoOperations {
>>> .....
>>> public void makePersistent(final Object entity) throws
>>> DataAccessException {
>>> execute(new JdoCallback() {
>>> public Object doInJdo(PersistenceManager pm) throws JDOException {
>>> try { ///// this try fails so the following catch send the
>>> ClassCastException
>>> (1) return makePersistentMethod.invoke(pm, new Object[] {entity});
>>> }
>>> catch (InvocationTargetException ex) { ///send the ClassCastException
>>> throw new InvalidDataAccessResourceUsageException(
>>> "Could not invoke JDO makePersistent(Object) method",
>>> ex.getTargetException());
>>> ......
>>>
>>>
>>>
>>> but the call within this try (1) ("return
>>> makePersistentMethod.invoke(pm, new Object[] {entity});") fails
>>> because... according to the Eclipse debugger,
>>> a nullPointerException occur in the EListWrapper attachCopy method
>>> execution, (==> called by the "makePersistentMethod.invoke" )
>>>
>>> and the line 431 is "if (!((PersistableEList) value).isLoaded())"
>>>
>>> public class EListWrapper<E> extends PersistableEList<E> implements SCO,
>>> Queryable, SCOList {
>>> ....
>>> public void attachCopy(Object value) {
>>> // if not loaded then nothing changed so nothing to attach
>>> line430 >> assert (value instanceof PersistableEList);
>>> line431 >> if (!((PersistableEList) value).isLoaded())
>>> return;
>>> ....
>>>
>>> upgrade to jpox 1.1.7? I've read somewhere in Jpox forum that "above
>>> Jpox 113 only Spring 2 is compatible and I didn't want to change my jsp
>>> code for the spring 2 forms syntax...
>>>
>>> but, I just try with jpox117 and...
>>>
>>> 1- it doesn't seem to make problems with spring forms syntax, at first
>>> look...
>>> 2- error messages from the eclipse debugger is a bit clearer :
>>> for line 430 execution : >> *value instanceof PersistableEList"= false*
>>> for line 431 execution : >> *ClassCastException: Cannot cast
>>> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 (id=217) to
>>> org.eclipse.emf.teneo.mapping.elist.PersistableEList*
>>> gr. Daniel
>>>
>>>
>>>
>>> "Martin Taal" <mtaal@elver.org <mailto:mtaal@elver.org>> a écrit dans le
>>> message de news: f00e1v$88a$1@build.eclipse.org
>>> <mailto:f00e1v$88a$1@build.eclipse.org>...
>>> > Hi Daniel,
>>> > Is it a nullpointerexception or a classcastexception (you mention
>>> both)?
>>> > You can't upgrade to jpox 1.1.7?
>>> >
>>> > Which line in elistwrapper does it happen (my line 431 in cvs seems
>>> to be iter.hasNext which I can't
>>> > imagine to be the cause of the classcastexception)?
>>> >
>>> > gr. Martin
>>> >
>>> > daniel wrote:
>>> >> hi,
>>> >> I get an error when I try to update a record in the database (but no
>>> problem
>>> >> to add a new one ?)
>>> >> Data access failure: Could not invoke JDO makePersistent(Object)
>>> method;
>>> >> nested exception is java.lang.ClassCastException:
>>> >> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
>>> >> org.springframework.dao.InvalidDataAccessResourceUsageExcept ion:
>>> Could not
>>> >> invoke JDO makePersistent(Object) method; nested exception is
>>> >> java.lang.ClassCastException:
>>> >> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
>>> >> java.lang.ClassCastException:
>>> >> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 at
>>> >>
>>> org.eclipse.emf.teneo.jpox.elist.EListWrapper.attachCopy(ELi stWrapper.java:431)
>>>
>>> >> at
>>> >>
>>> org.jpox.state.AttachFieldManager.storeObjectField(AttachFie ldManager.java:157)
>>>
>>> >> at
>>> >>
>>> org.jpox.state.StateManagerImpl.providedObjectField(StateMan agerImpl.java:2748)
>>>
>>> >> at org.MyClassImpl.jdoProvideField(MyClassImpl.java) at....
>>> >>
>>> >> the error is a ClassCastException thrown from the spring
>>> webcontainer method
>>> >> public class JdoTemplate extends JdoAccessor implements JdoOperations
>>> {
>>> >> ......
>>> >> public void makePersistent(final Object entity) throws
>>> DataAccessException {
>>> >> execute(new JdoCallback() {
>>> >> public Object doInJdo(PersistenceManager pm) throws JDOException {
>>> >> try {
>>> >> return makePersistentMethod.invoke(pm, new Object[] {entity});
>>> >> }
>>> >> catch (InvocationTargetException ex) {
>>> >> throw new InvalidDataAccessResourceUsageException(
>>> >> "Could not invoke JDO makePersistent(Object) method",
>>> >> ex.getTargetException());
>>> >> .......
>>> >>
>>> >> and the eclipse debugger seems to say that there is a
>>> nullPointerException
>>> >> in the EListWrapper attachCopy method execution :
>>> >> public class EListWrapper<E> extends PersistableEList<E> implements
>>> SCO,
>>> >> Queryable, SCOList {
>>> >> .....
>>> >> public void attachCopy(Object value) {
>>> >> // if not loaded then nothing changed so nothing to attach
>>> >> assert (value instanceof PersistableEList);
>>> >> if (!((PersistableEList) value).isLoaded())
>>> >> return;
>>> >> .....
>>> >> because "binding error on value"... which is null ("binding ==null
>>> for
>>> >> value")
>>> >>
>>> >> but the call, from the org.jpox.state.StateManager to the teneo sco
>>> class
>>> >> (ElistWapper) seems to be good
>>> >> public class AttachFieldManager extends AbstractFieldManager
>>> >> {
>>> >> ......
>>> >> public void storeObjectField(int fieldNumber, Object value)
>>> >> {
>>> >> .......
>>> >> sco.attachCopy(value);
>>> >> ......
>>> >> sco and value are ElistWapper$1, empty but not null
>>> >>
>>> >> the teneo log seems to be good :
>>> >> ....
>>> >> 15:53:55,625 (http-8080-Processor23) DEBUG
>>> >> [org.eclipse.emf.teneo.mapping.elist.PersistableEList] - Loading
>>> EList of
>>> >> type: org.eclipse.emf.teneo.jpox.elist.EListWrapper of member
>>> myField (that
>>> >> cause the error) owned by MyClass with delegate list
>>> java.util.ArrayList
>>> >> ....
>>> >> I use Eclipse3.2, EMF 2.2.2, teneo : emft-teneo-SDK-I200703301643,
>>> Jpox1.3
>>> >> (to stay compatible withe Spring 1.2.X for syntax reason), Spring
>>> 1.2.8.
>>> >> I've tried with Eclipse3.3, EMF 2.3, teneo :
>>> emft-teneo-SDK-I200703301643
>>> >> etc... and that's the same
>>> >>
>>> >> To be able to send you an example to reproduce to problem, I'tried
>>> to shrink
>>> >> my webapp to the 3 or 4 classes with the field which cause the
>>> error... but
>>> >> in this case, I have no error...?
>>> >> I don't know where to search the error
>>> >>
>>> >> Thanks
>>> >> Daniel
>>> >>
>>> >>
>>> >
>>> >
>>> > --
>>> >
>>> > With Regards, Martin Taal
>>> >
>>> > Springsite/Elver.org
>>> > Office: Hardwareweg 4, 3821 BV Amersfoort
>>> > Postal: Nassaulaan 7, 3941 EC Doorn
>>> > The Netherlands
>>> > Tel: +31 (0)84 420 2397
>>> > Fax: +31 (0)84 225 9307
>>> > Mail: mtaal@springsite.com <mailto:mtaal@springsite.com> -
>>> mtaal@elver.org <mailto:mtaal@elver.org>
>>> > Web: www.springsite.com <http://www.springsite.com> - www.elver.org
>>> <http://www.elver.org>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Tel: +31 (0)84 420 2397
>> Fax: +31 (0)84 225 9307
>> Mail: mtaal@springsite.com - mtaal@elver.org
>> Web: www.springsite.com - www.elver.org
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: ClassCastExeption with Elistwrapper [message #604761 is a reply to message #79914] Mon, 16 April 2007 18:07 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Daniel,
Is it a nullpointerexception or a classcastexception (you mention both)?
You can't upgrade to jpox 1.1.7?

Which line in elistwrapper does it happen (my line 431 in cvs seems to be iter.hasNext which I can't
imagine to be the cause of the classcastexception)?

gr. Martin

daniel wrote:
> hi,
> I get an error when I try to update a record in the database (but no problem
> to add a new one ?)
> Data access failure: Could not invoke JDO makePersistent(Object) method;
> nested exception is java.lang.ClassCastException:
> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
> org.springframework.dao.InvalidDataAccessResourceUsageExcept ion: Could not
> invoke JDO makePersistent(Object) method; nested exception is
> java.lang.ClassCastException:
> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
> java.lang.ClassCastException:
> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 at
> org.eclipse.emf.teneo.jpox.elist.EListWrapper.attachCopy(ELi stWrapper.java:431)
> at
> org.jpox.state.AttachFieldManager.storeObjectField(AttachFie ldManager.java:157)
> at
> org.jpox.state.StateManagerImpl.providedObjectField(StateMan agerImpl.java:2748)
> at org.MyClassImpl.jdoProvideField(MyClassImpl.java) at....
>
> the error is a ClassCastException thrown from the spring webcontainer method
> public class JdoTemplate extends JdoAccessor implements JdoOperations {
> ......
> public void makePersistent(final Object entity) throws DataAccessException {
> execute(new JdoCallback() {
> public Object doInJdo(PersistenceManager pm) throws JDOException {
> try {
> return makePersistentMethod.invoke(pm, new Object[] {entity});
> }
> catch (InvocationTargetException ex) {
> throw new InvalidDataAccessResourceUsageException(
> "Could not invoke JDO makePersistent(Object) method",
> ex.getTargetException());
> .......
>
> and the eclipse debugger seems to say that there is a nullPointerException
> in the EListWrapper attachCopy method execution :
> public class EListWrapper<E> extends PersistableEList<E> implements SCO,
> Queryable, SCOList {
> .....
> public void attachCopy(Object value) {
> // if not loaded then nothing changed so nothing to attach
> assert (value instanceof PersistableEList);
> if (!((PersistableEList) value).isLoaded())
> return;
> .....
> because "binding error on value"... which is null ("binding ==null for
> value")
>
> but the call, from the org.jpox.state.StateManager to the teneo sco class
> (ElistWapper) seems to be good
> public class AttachFieldManager extends AbstractFieldManager
> {
> ......
> public void storeObjectField(int fieldNumber, Object value)
> {
> ......
> sco.attachCopy(value);
> ......
> sco and value are ElistWapper$1, empty but not null
>
> the teneo log seems to be good :
> ....
> 15:53:55,625 (http-8080-Processor23) DEBUG
> [org.eclipse.emf.teneo.mapping.elist.PersistableEList] - Loading EList of
> type: org.eclipse.emf.teneo.jpox.elist.EListWrapper of member myField (that
> cause the error) owned by MyClass with delegate list java.util.ArrayList
> ....
> I use Eclipse3.2, EMF 2.2.2, teneo : emft-teneo-SDK-I200703301643, Jpox1.3
> (to stay compatible withe Spring 1.2.X for syntax reason), Spring 1.2.8.
> I've tried with Eclipse3.3, EMF 2.3, teneo : emft-teneo-SDK-I200703301643
> etc... and that's the same
>
> To be able to send you an example to reproduce to problem, I'tried to shrink
> my webapp to the 3 or 4 classes with the field which cause the error... but
> in this case, I have no error...?
> I don't know where to search the error
>
> Thanks
> Daniel
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: ClassCastExeption with Elistwrapper [message #604764 is a reply to message #79929] Mon, 16 April 2007 21:21 Go to previous message
daniel is currently offline danielFriend
Messages: 17
Registered: July 2009
Junior Member
This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C7807E.16D4ADE0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

hi Martin
it happens like this :
a ClassCastException is thrown from the spring webcontainer method, by =
the catch

public class JdoTemplate extends JdoAccessor implements JdoOperations {
......
public void makePersistent(final Object entity) throws =
DataAccessException {
execute(new JdoCallback() {
public Object doInJdo(PersistenceManager pm) throws JDOException {
try { ///// this try fails so the following catch send the =
ClassCastException
(1) return makePersistentMethod.invoke(pm, new Object[] {entity});
}
catch (InvocationTargetException ex) { ///send the ClassCastException =20
throw new InvalidDataAccessResourceUsageException(
"Could not invoke JDO makePersistent(Object) method", =
ex.getTargetException());
.......


but the call within this try (1) ("return =
makePersistentMethod.invoke(pm, new Object[] {entity});") fails =
because... according to the Eclipse debugger, =20
a nullPointerException occur in the EListWrapper attachCopy method =
execution, (=3D=3D> called by the "makePersistentMethod.invoke" )

and the line 431 is "if (!((PersistableEList) value).isLoaded())"=20

public class EListWrapper<E> extends PersistableEList<E> implements SCO, =
Queryable, SCOList {
.....
public void attachCopy(Object value) {
// if not loaded then nothing changed so nothing to attach
line430 >> assert (value instanceof PersistableEList);
line431 >> if (!((PersistableEList) value).isLoaded())=20
return;
.....
upgrade to jpox 1.1.7? I've read somewhere in Jpox forum that "above =
Jpox 113 only Spring 2 is compatible and I didn't want to change my jsp =
code for the spring 2 forms syntax...

but, I just try with jpox117 and...=20

1- it doesn't seem to make problems with spring forms syntax, at first =
look...
2- error messages from the eclipse debugger is a bit clearer :
for line 430 execution : >> value instanceof PersistableEList"=3D false=20
for line 431 execution : >> ClassCastException: Cannot cast =
org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 (id=3D217) to =
org.eclipse.emf.teneo.mapping.elist.PersistableEList=20

gr. Daniel




"Martin Taal" <mtaal@elver.org> a =E9crit dans le message de news: =
f00e1v$88a$1@build.eclipse.org...
> Hi Daniel,
> Is it a nullpointerexception or a classcastexception (you mention =
both)?
> You can't upgrade to jpox 1.1.7?
>=20
> Which line in elistwrapper does it happen (my line 431 in cvs seems to =
be iter.hasNext which I can't=20
> imagine to be the cause of the classcastexception)?
>=20
> gr. Martin
>=20
> daniel wrote:
>> hi,
>> I get an error when I try to update a record in the database (but no =
problem=20
>> to add a new one ?)
>> Data access failure: Could not invoke JDO makePersistent(Object) =
method;=20
>> nested exception is java.lang.ClassCastException:=20
>> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
>> org.springframework.dao.InvalidDataAccessResourceUsageExcept ion: =
Could not=20
>> invoke JDO makePersistent(Object) method; nested exception is=20
>> java.lang.ClassCastException:=20
>> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1=20
>> java.lang.ClassCastException:=20
>> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 at=20
>> =
org.eclipse.emf.teneo.jpox.elist.EListWrapper.attachCopy(ELi stWrapper.jav=
a:431)=20
>> at=20
>> =
org.jpox.state.AttachFieldManager.storeObjectField(AttachFie ldManager.jav=
a:157)=20
>> at=20
>> =
org.jpox.state.StateManagerImpl.providedObjectField(StateMan agerImpl.java=
:2748)=20
>> at org.MyClassImpl.jdoProvideField(MyClassImpl.java) at....
>>=20
>> the error is a ClassCastException thrown from the spring webcontainer =
method
>> public class JdoTemplate extends JdoAccessor implements JdoOperations =
{
>> ......
>> public void makePersistent(final Object entity) throws =
DataAccessException {
>> execute(new JdoCallback() {
>> public Object doInJdo(PersistenceManager pm) throws JDOException {
>> try {
>> return makePersistentMethod.invoke(pm, new Object[] {entity});
>> }
>> catch (InvocationTargetException ex) {
>> throw new InvalidDataAccessResourceUsageException(
>> "Could not invoke JDO makePersistent(Object) method",=20
>> ex.getTargetException());
>> .......
>>=20
>> and the eclipse debugger seems to say that there is a =
nullPointerException=20
>> in the EListWrapper attachCopy method execution :
>> public class EListWrapper<E> extends PersistableEList<E> implements =
SCO,=20
>> Queryable, SCOList {
>> .....
>> public void attachCopy(Object value) {
>> // if not loaded then nothing changed so nothing to attach
>> assert (value instanceof PersistableEList);
>> if (!((PersistableEList) value).isLoaded())
>> return;
>> .....
>> because "binding error on value"... which is null ("binding =
=3D=3Dnull for=20
>> value")
>>=20
>> but the call, from the org.jpox.state.StateManager to the teneo sco =
class=20
>> (ElistWapper) seems to be good
>> public class AttachFieldManager extends AbstractFieldManager
>> {
>> ......
>> public void storeObjectField(int fieldNumber, Object value)
>> {
>> ......
>> sco.attachCopy(value);
>> ......
>> sco and value are ElistWapper$1, empty but not null
>>=20
>> the teneo log seems to be good :
>> ....
>> 15:53:55,625 (http-8080-Processor23) DEBUG=20
>> [org.eclipse.emf.teneo.mapping.elist.PersistableEList] - Loading =
EList of=20
>> type: org.eclipse.emf.teneo.jpox.elist.EListWrapper of member myField =
(that=20
>> cause the error) owned by MyClass with delegate list =
java.util.ArrayList
>> ....
>> I use Eclipse3.2, EMF 2.2.2, teneo : emft-teneo-SDK-I200703301643, =
Jpox1.3=20
>> (to stay compatible withe Spring 1.2.X for syntax reason), Spring =
1.2.8.
>> I've tried with Eclipse3.3, EMF 2.3, teneo : =
emft-teneo-SDK-I200703301643=20
>> etc... and that's the same
>>=20
>> To be able to send you an example to reproduce to problem, I'tried to =
shrink=20
>> my webapp to the 3 or 4 classes with the field which cause the =
error... but=20
>> in this case, I have no error...?
>> I don't know where to search the error
>>=20
>> Thanks
>> Daniel=20
>>=20
>>=20
>=20
>=20
> --=20
>=20
> With Regards, Martin Taal
>=20
> Springsite/Elver.org
> Office: Hardwareweg 4, 3821 BV Amersfoort
> Postal: Nassaulaan 7, 3941 EC Doorn
> The Netherlands
> Tel: +31 (0)84 420 2397
> Fax: +31 (0)84 225 9307
> Mail: mtaal@springsite.com - mtaal@elver.org
> Web: www.springsite.com - www.elver.org
------=_NextPart_000_0007_01C7807E.16D4ADE0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16414" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>hi Martin</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>it happens like this :</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>a&nbsp;ClassCastException is thrown =
from the spring=20
webcontainer method, by the catch</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>public class JdoTemplate extends =
JdoAccessor=20
implements JdoOperations {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>.....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>public void makePersistent(final Object =
entity)=20
throws DataAccessException {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>execute(new JdoCallback() =
{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>public Object =
doInJdo(PersistenceManager pm) throws=20
JDOException {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>try { <FONT color=3D#ff0000>///// this =
try fails so=20
the following catch send the ClassCastException</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>(1) return =
makePersistentMethod.invoke(pm, new=20
Object[] {entity});</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><FONT color=3D#ff0000>catch</FONT>=20
(InvocationTargetException ex) {&nbsp;///send the=20
ClassCastException</FONT>&nbsp;&nbsp; </DIV>
<DIV><FONT face=3DArial size=3D2>throw new=20
InvalidDataAccessResourceUsageException(</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>"Could not invoke JDO =
makePersistent(Object)=20
method", ex.getTargetException());</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>......</FONT></DIV>
<P><FONT face=3DArial size=3D2></FONT>&nbsp;</P>
<DIV><FONT face=3DArial size=3D2>but the call within this try (1) =
("return=20
makePersistentMethod.invoke(pm, new Object[] {entity});") fails =
because...=20
according to the Eclipse debugger,&nbsp; </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>a nullPointerException occur in the =
EListWrapper=20
attachCopy method execution, (=3D=3D&gt; called by=20
the&nbsp;"makePersistentMethod.invoke"&nbsp;)</FONT ></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>and the line 431 is "if =
(!((PersistableEList)=20
value).isLoaded())"&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>public class EListWrapper&lt;E&gt; =
extends=20
PersistableEList&lt;E&gt; implements SCO, Queryable, SCOList =
{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>....</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>public void attachCopy(Object value) =
{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>// if not loaded then nothing changed =
so nothing to=20
attach</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>line430 &gt;&gt; assert (value =
instanceof=20
PersistableEList);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>line431 &gt;&gt;&nbsp;if =
(!((PersistableEList)=20
value).isLoaded()) </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>return;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>....</FONT></DIV>
<P><FONT face=3DArial size=3D2>upgrade to jpox 1.1.7? I've read =
somewhere in Jpox=20
forum that "above Jpox 113 only Spring 2 is compatible and I didn't want =
to=20
change my jsp code&nbsp;for the&nbsp;spring 2 forms syntax...</FONT></P>
<P><FONT face=3DArial size=3D2>but, I just try with jpox117 and... =
</FONT></P>
<DIV><FONT face=3DArial size=3D2>1- it doesn't seem to make problems =
with spring=20
forms syntax, at first look...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>2- error messages from the eclipse =
debugger is a=20
bit clearer :</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>for line 430 execution : &gt;&gt; <FONT =

color=3D#ff0000><STRONG>value instanceof PersistableEList"=3D=20
false</STRONG></FONT>&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>for line 431 execution : &gt;&gt; <FONT =

color=3D#ff0000><STRONG>ClassCastException: Cannot cast=20
org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 (id=3D217) to=20
org.eclipse.emf.teneo.mapping.elist.PersistableEList</STRONG ></FONT>&nbsp=
;<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>gr. Daniel</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;</DIV>
<DIV><BR></DIV></FONT>
<DIV><FONT face=3DArial size=3D2>"Martin Taal" &lt;</FONT><A=20
href=3D"mailto:mtaal@elver.org"><FONT face=3DArial=20
size=3D2>mtaal@elver.org</FONT></A><FONT face=3DArial size=3D2>&gt; a =
=E9crit dans le=20
message de news: </FONT><A =
href=3D"mailto:f00e1v$88a$1@build.eclipse.org"><FONT=20
face=3DArial size=3D2>f00e1v$88a$1@build.eclipse.org</FONT></A><FONT =
face=3DArial=20
size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>&gt; Hi =
Daniel,<BR>&gt; Is it a=20
nullpointerexception or a classcastexception (you mention both)?<BR>&gt; =
You=20
can't upgrade to jpox 1.1.7?<BR>&gt; <BR>&gt; Which line in elistwrapper =
does it=20
happen (my line 431 in cvs seems to be iter.hasNext which I can't =
<BR>&gt;=20
imagine to be the cause of the classcastexception)?<BR>&gt; <BR>&gt; gr. =

Martin<BR>&gt; <BR>&gt; daniel wrote:<BR>&gt;&gt; hi,<BR>&gt;&gt; I get =
an error=20
when I try to update a record in the database (but no problem =
<BR>&gt;&gt; to=20
add a new one ?)<BR>&gt;&gt; Data access failure: Could not invoke JDO=20
makePersistent(Object) method; <BR>&gt;&gt; nested exception is=20
java.lang.ClassCastException: <BR>&gt;&gt;=20
org.eclipse.emf.teneo.jpox.elist.EListWrapper$1<BR>&gt;&gt;=20
org.springframework.dao.InvalidDataAccessResourceUsageExcept ion: Could =
not=20
<BR>&gt;&gt; invoke JDO makePersistent(Object) method; nested exception =
is=20
<BR>&gt;&gt; java.lang.ClassCastException: <BR>&gt;&gt;=20
org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 <BR>&gt;&gt;=20
java.lang.ClassCastException: <BR>&gt;&gt;=20
org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 at <BR>&gt;&gt;=20
org.eclipse.emf.teneo.jpox.elist.EListWrapper.attachCopy(ELi stWrapper.jav=
a:431)=20
<BR>&gt;&gt; at <BR>&gt;&gt;=20
org.jpox.state.AttachFieldManager.storeObjectField(AttachFie ldManager.jav=
a:157)=20
<BR>&gt;&gt; at <BR>&gt;&gt;=20
org.jpox.state.StateManagerImpl.providedObjectField(StateMan agerImpl.java=
:2748)=20
<BR>&gt;&gt; at org.MyClassImpl.jdoProvideField(MyClassImpl.java)=20
at....<BR>&gt;&gt; <BR>&gt;&gt; the error is a ClassCastException thrown =
from=20
the spring webcontainer method<BR>&gt;&gt; public class JdoTemplate =
extends=20
JdoAccessor implements JdoOperations {<BR>&gt;&gt; ......<BR>&gt;&gt; =
public=20
void makePersistent(final Object entity) throws DataAccessException=20
{<BR>&gt;&gt; execute(new JdoCallback() {<BR>&gt;&gt; public Object=20
doInJdo(PersistenceManager pm) throws JDOException {<BR>&gt;&gt; try=20
{<BR>&gt;&gt; return makePersistentMethod.invoke(pm, new Object[]=20
{entity});<BR>&gt;&gt; }<BR>&gt;&gt; catch (InvocationTargetException =
ex)=20
{<BR>&gt;&gt; throw new =
InvalidDataAccessResourceUsageException(<BR>&gt;&gt;=20
"Could not invoke JDO makePersistent(Object) method", <BR>&gt;&gt;=20
ex.getTargetException());<BR>&gt;&gt; .......<BR>&gt;&gt; <BR>&gt;&gt; =
and the=20
eclipse debugger seems to say that there is a nullPointerException =
<BR>&gt;&gt;=20
in the EListWrapper attachCopy method execution :<BR>&gt;&gt; public =
class=20
EListWrapper&lt;E&gt; extends PersistableEList&lt;E&gt; implements SCO,=20
<BR>&gt;&gt; Queryable, SCOList {<BR>&gt;&gt; .....<BR>&gt;&gt; public =
void=20
attachCopy(Object value) {<BR>&gt;&gt; // if not loaded then nothing =
changed so=20
nothing to attach<BR>&gt;&gt; assert (value instanceof=20
PersistableEList);<BR>&gt;&gt; if (!((PersistableEList)=20
value).isLoaded())<BR>&gt;&gt; return;<BR>&gt;&gt; .....<BR>&gt;&gt; =
because=20
"binding error on value"... which is null ("binding =3D=3Dnull for =
<BR>&gt;&gt;=20
value")<BR>&gt;&gt; <BR>&gt;&gt; but the call, from the=20
org.jpox.state.StateManager to the teneo sco class <BR>&gt;&gt; =
(ElistWapper)=20
seems to be good<BR>&gt;&gt; public class AttachFieldManager extends=20
AbstractFieldManager<BR>&gt;&gt; {<BR>&gt;&gt; ......<BR>&gt;&gt; public =
void=20
storeObjectField(int fieldNumber, Object value)<BR>&gt;&gt; =
{<BR>&gt;&gt;=20
.......<BR>&gt;&gt; sco.attachCopy(value);<BR>&gt;&gt; ......<BR>&gt;&gt; =
sco and=20
value are ElistWapper$1, empty but not null<BR>&gt;&gt; <BR>&gt;&gt; the =
teneo=20
log seems to be good :<BR>&gt;&gt; ....<BR>&gt;&gt; 15:53:55,625=20
(http-8080-Processor23) DEBUG <BR>&gt;&gt;=20
[org.eclipse.emf.teneo.mapping.elist.PersistableEList] - Loading EList =
of=20
<BR>&gt;&gt; type: org.eclipse.emf.teneo.jpox.elist.EListWrapper of =
member=20
myField (that <BR>&gt;&gt; cause the error) owned by MyClass with =
delegate list=20
java.util.ArrayList<BR>&gt;&gt; ....<BR>&gt;&gt; I use Eclipse3.2, EMF =
2.2.2,=20
teneo : emft-teneo-SDK-I200703301643, Jpox1.3 <BR>&gt;&gt; (to stay =
compatible=20
withe Spring 1.2.X for syntax reason), Spring 1.2.8.<BR>&gt;&gt; I've =
tried with=20
Eclipse3.3, EMF 2.3, teneo : emft-teneo-SDK-I200703301643 <BR>&gt;&gt; =
etc...=20
and that's the same<BR>&gt;&gt; <BR>&gt;&gt; To be able to send you an =
example=20
to reproduce to problem, I'tried to shrink <BR>&gt;&gt; my webapp to the =
3 or 4=20
classes with the field which cause the error... but <BR>&gt;&gt; in this =
case, I=20
have no error...?<BR>&gt;&gt; I don't know where to search the =
error<BR>&gt;&gt;=20
<BR>&gt;&gt; Thanks<BR>&gt;&gt; Daniel <BR>&gt;&gt; <BR>&gt;&gt; =
<BR>&gt;=20
<BR>&gt; <BR>&gt; -- <BR>&gt; <BR>&gt; With Regards, Martin Taal<BR>&gt; =

<BR>&gt; Springsite/Elver.org<BR>&gt; Office: Hardwareweg 4, 3821 BV=20
Amersfoort<BR>&gt; Postal: Nassaulaan 7, 3941 EC Doorn<BR>&gt; The=20
Netherlands<BR>&gt; Tel: +31 (0)84 420 2397<BR>&gt; Fax: +31 (0)84 225=20
9307<BR>&gt; Mail: </FONT><A href=3D"mailto:mtaal@springsite.com"><FONT =
face=3DArial=20
size=3D2>mtaal@springsite.com</FONT></A><FONT face=3DArial size=3D2> - =
</FONT><A=20
href=3D"mailto:mtaal@elver.org"><FONT face=3DArial=20
size=3D2>mtaal@elver.org</FONT></A><BR><FONT face=3DArial size=3D2>&gt; =
Web: </FONT><A=20
href=3D"http://www.springsite.com"><FONT face=3DArial=20
size=3D2>www.springsite.com</FONT></A><FONT face=3DArial size=3D2> - =
</FONT><A=20
href=3D"http://www.elver.org"><FONT face=3DArial=20
size=3D2>www.elver.org</FONT></A></BODY></HTML>

------=_NextPart_000_0007_01C7807E.16D4ADE0--
Re: ClassCastExeption with Elistwrapper [message #604767 is a reply to message #79946] Mon, 16 April 2007 21:45 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Daniel,
Was the instance (EListWrapper$1) created before in a call to detachcopy?

If so then this is a bug and the class casting should not happen in the attachcopy (or the
classcasting should only happen after checking that the instance is a PersistableEList.
You can file a bugzilla for this.

gr. Martin

daniel wrote:
> hi Martin
> it happens like this :
> a ClassCastException is thrown from the spring webcontainer method, by
> the catch
>
> public class JdoTemplate extends JdoAccessor implements JdoOperations {
> .....
> public void makePersistent(final Object entity) throws DataAccessException {
> execute(new JdoCallback() {
> public Object doInJdo(PersistenceManager pm) throws JDOException {
> try { ///// this try fails so the following catch send the
> ClassCastException
> (1) return makePersistentMethod.invoke(pm, new Object[] {entity});
> }
> catch (InvocationTargetException ex) { ///send the ClassCastException
> throw new InvalidDataAccessResourceUsageException(
> "Could not invoke JDO makePersistent(Object) method",
> ex.getTargetException());
> ......
>
>
>
> but the call within this try (1) ("return
> makePersistentMethod.invoke(pm, new Object[] {entity});") fails
> because... according to the Eclipse debugger,
> a nullPointerException occur in the EListWrapper attachCopy method
> execution, (==> called by the "makePersistentMethod.invoke" )
>
> and the line 431 is "if (!((PersistableEList) value).isLoaded())"
>
> public class EListWrapper<E> extends PersistableEList<E> implements SCO,
> Queryable, SCOList {
> ....
> public void attachCopy(Object value) {
> // if not loaded then nothing changed so nothing to attach
> line430 >> assert (value instanceof PersistableEList);
> line431 >> if (!((PersistableEList) value).isLoaded())
> return;
> ....
>
> upgrade to jpox 1.1.7? I've read somewhere in Jpox forum that "above
> Jpox 113 only Spring 2 is compatible and I didn't want to change my jsp
> code for the spring 2 forms syntax...
>
> but, I just try with jpox117 and...
>
> 1- it doesn't seem to make problems with spring forms syntax, at first
> look...
> 2- error messages from the eclipse debugger is a bit clearer :
> for line 430 execution : >> *value instanceof PersistableEList"= false*
> for line 431 execution : >> *ClassCastException: Cannot cast
> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 (id=217) to
> org.eclipse.emf.teneo.mapping.elist.PersistableEList*
> gr. Daniel
>
>
>
> "Martin Taal" <mtaal@elver.org <mailto:mtaal@elver.org>> a écrit dans le
> message de news: f00e1v$88a$1@build.eclipse.org
> <mailto:f00e1v$88a$1@build.eclipse.org>...
> > Hi Daniel,
> > Is it a nullpointerexception or a classcastexception (you mention both)?
> > You can't upgrade to jpox 1.1.7?
> >
> > Which line in elistwrapper does it happen (my line 431 in cvs seems
> to be iter.hasNext which I can't
> > imagine to be the cause of the classcastexception)?
> >
> > gr. Martin
> >
> > daniel wrote:
> >> hi,
> >> I get an error when I try to update a record in the database (but no
> problem
> >> to add a new one ?)
> >> Data access failure: Could not invoke JDO makePersistent(Object)
> method;
> >> nested exception is java.lang.ClassCastException:
> >> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
> >> org.springframework.dao.InvalidDataAccessResourceUsageExcept ion:
> Could not
> >> invoke JDO makePersistent(Object) method; nested exception is
> >> java.lang.ClassCastException:
> >> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
> >> java.lang.ClassCastException:
> >> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 at
> >>
> org.eclipse.emf.teneo.jpox.elist.EListWrapper.attachCopy(ELi stWrapper.java:431)
>
> >> at
> >>
> org.jpox.state.AttachFieldManager.storeObjectField(AttachFie ldManager.java:157)
>
> >> at
> >>
> org.jpox.state.StateManagerImpl.providedObjectField(StateMan agerImpl.java:2748)
>
> >> at org.MyClassImpl.jdoProvideField(MyClassImpl.java) at....
> >>
> >> the error is a ClassCastException thrown from the spring
> webcontainer method
> >> public class JdoTemplate extends JdoAccessor implements JdoOperations {
> >> ......
> >> public void makePersistent(final Object entity) throws
> DataAccessException {
> >> execute(new JdoCallback() {
> >> public Object doInJdo(PersistenceManager pm) throws JDOException {
> >> try {
> >> return makePersistentMethod.invoke(pm, new Object[] {entity});
> >> }
> >> catch (InvocationTargetException ex) {
> >> throw new InvalidDataAccessResourceUsageException(
> >> "Could not invoke JDO makePersistent(Object) method",
> >> ex.getTargetException());
> >> .......
> >>
> >> and the eclipse debugger seems to say that there is a
> nullPointerException
> >> in the EListWrapper attachCopy method execution :
> >> public class EListWrapper<E> extends PersistableEList<E> implements
> SCO,
> >> Queryable, SCOList {
> >> .....
> >> public void attachCopy(Object value) {
> >> // if not loaded then nothing changed so nothing to attach
> >> assert (value instanceof PersistableEList);
> >> if (!((PersistableEList) value).isLoaded())
> >> return;
> >> .....
> >> because "binding error on value"... which is null ("binding ==null for
> >> value")
> >>
> >> but the call, from the org.jpox.state.StateManager to the teneo sco
> class
> >> (ElistWapper) seems to be good
> >> public class AttachFieldManager extends AbstractFieldManager
> >> {
> >> ......
> >> public void storeObjectField(int fieldNumber, Object value)
> >> {
> >> .......
> >> sco.attachCopy(value);
> >> ......
> >> sco and value are ElistWapper$1, empty but not null
> >>
> >> the teneo log seems to be good :
> >> ....
> >> 15:53:55,625 (http-8080-Processor23) DEBUG
> >> [org.eclipse.emf.teneo.mapping.elist.PersistableEList] - Loading
> EList of
> >> type: org.eclipse.emf.teneo.jpox.elist.EListWrapper of member
> myField (that
> >> cause the error) owned by MyClass with delegate list java.util.ArrayList
> >> ....
> >> I use Eclipse3.2, EMF 2.2.2, teneo : emft-teneo-SDK-I200703301643,
> Jpox1.3
> >> (to stay compatible withe Spring 1.2.X for syntax reason), Spring 1.2.8.
> >> I've tried with Eclipse3.3, EMF 2.3, teneo :
> emft-teneo-SDK-I200703301643
> >> etc... and that's the same
> >>
> >> To be able to send you an example to reproduce to problem, I'tried
> to shrink
> >> my webapp to the 3 or 4 classes with the field which cause the
> error... but
> >> in this case, I have no error...?
> >> I don't know where to search the error
> >>
> >> Thanks
> >> Daniel
> >>
> >>
> >
> >
> > --
> >
> > With Regards, Martin Taal
> >
> > Springsite/Elver.org
> > Office: Hardwareweg 4, 3821 BV Amersfoort
> > Postal: Nassaulaan 7, 3941 EC Doorn
> > The Netherlands
> > Tel: +31 (0)84 420 2397
> > Fax: +31 (0)84 225 9307
> > Mail: mtaal@springsite.com <mailto:mtaal@springsite.com> -
> mtaal@elver.org <mailto:mtaal@elver.org>
> > Web: www.springsite.com <http://www.springsite.com> - www.elver.org
> <http://www.elver.org>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: ClassCastExeption with Elistwrapper [message #604777 is a reply to message #79960] Tue, 17 April 2007 08:59 Go to previous message
daniel is currently offline danielFriend
Messages: 17
Registered: July 2009
Junior Member
Hi Martin
> Was the instance (EListWrapper$1) created before in a call to detachcopy?
the instance (EListWrapper$1) seems to be created in the
KanPatientImpl.jdoProvideField(int) method execution (uneasy because jdo
method are not accessible by debugger) (see jpg debug_01)

after that, the call to EListWrapper seems to be good, with real instance
(not null) (see jpg debug_02)

ant finaly, in the EListWrapper.attachCopy(object) :
1- the "assert (value instanceof PersistableEList);" should send an
exception whereas "value instanceof PersistableEList"= false, shouldn't it ?
2- why value instanceof PersistableEList"= false and why the value
(EListWrapper$1 (id=xxx) cannot be cast to PersistableEList if EListWrapper
is a subclass of PersistableEList (public class EListWrapper<E> extends
PersistableEList<E>.) ? (see jpg debug_03)

I can report that on Eclipse bugzilla EMFT, if you like

gr. Daniel


"Martin Taal" <mtaal@elver.org> a
  • Attachment: debug_01.jpg
    (Size: 130.51KB, Downloaded 112 times)
  • Attachment: debug_02.jpg
    (Size: 150.76KB, Downloaded 103 times)
  • Attachment: debug_03.jpg
    (Size: 114.49KB, Downloaded 111 times)
Re: ClassCastExeption with Elistwrapper [message #604782 is a reply to message #79993] Tue, 17 April 2007 13:52 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Daniel,
Afaik the EListWrapper$1 is not the EListWrapper itself but an anonymous inner class. My guess is
that this one is created in the detachCopy method (you can try by setting a breakpoint there). So
the attachcopy method check on PersistableEList should also check if the type is a PersistableEList
and only check isloaded in that case and allow other cases to pass on.

Can you enter a bugzilla for this?

gr. Martin

daniel wrote:
> Hi Martin
>> Was the instance (EListWrapper$1) created before in a call to detachcopy?
> the instance (EListWrapper$1) seems to be created in the
> KanPatientImpl.jdoProvideField(int) method execution (uneasy because jdo
> method are not accessible by debugger) (see jpg debug_01)
>
> after that, the call to EListWrapper seems to be good, with real instance
> (not null) (see jpg debug_02)
>
> ant finaly, in the EListWrapper.attachCopy(object) :
> 1- the "assert (value instanceof PersistableEList);" should send an
> exception whereas "value instanceof PersistableEList"= false, shouldn't it ?
> 2- why value instanceof PersistableEList"= false and why the value
> (EListWrapper$1 (id=xxx) cannot be cast to PersistableEList if EListWrapper
> is a subclass of PersistableEList (public class EListWrapper<E> extends
> PersistableEList<E>.) ? (see jpg debug_03)
>
> I can report that on Eclipse bugzilla EMFT, if you like
>
> gr. Daniel
>
>
> "Martin Taal" <mtaal@elver.org> a écrit dans le message de news:
> f00qqi$q1e$1@build.eclipse.org...
>> Hi Daniel,
>> Was the instance (EListWrapper$1) created before in a call to detachcopy?
>>
>> If so then this is a bug and the class casting should not happen in the
>> attachcopy (or the
>> classcasting should only happen after checking that the instance is a
>> PersistableEList.
>> You can file a bugzilla for this.
>>
>> gr. Martin
>>
>> daniel wrote:
>>> hi Martin
>>> it happens like this :
>>> a ClassCastException is thrown from the spring webcontainer method, by
>>> the catch
>>>
>>> public class JdoTemplate extends JdoAccessor implements JdoOperations {
>>> .....
>>> public void makePersistent(final Object entity) throws
>>> DataAccessException {
>>> execute(new JdoCallback() {
>>> public Object doInJdo(PersistenceManager pm) throws JDOException {
>>> try { ///// this try fails so the following catch send the
>>> ClassCastException
>>> (1) return makePersistentMethod.invoke(pm, new Object[] {entity});
>>> }
>>> catch (InvocationTargetException ex) { ///send the ClassCastException
>>> throw new InvalidDataAccessResourceUsageException(
>>> "Could not invoke JDO makePersistent(Object) method",
>>> ex.getTargetException());
>>> ......
>>>
>>>
>>>
>>> but the call within this try (1) ("return
>>> makePersistentMethod.invoke(pm, new Object[] {entity});") fails
>>> because... according to the Eclipse debugger,
>>> a nullPointerException occur in the EListWrapper attachCopy method
>>> execution, (==> called by the "makePersistentMethod.invoke" )
>>>
>>> and the line 431 is "if (!((PersistableEList) value).isLoaded())"
>>>
>>> public class EListWrapper<E> extends PersistableEList<E> implements SCO,
>>> Queryable, SCOList {
>>> ....
>>> public void attachCopy(Object value) {
>>> // if not loaded then nothing changed so nothing to attach
>>> line430 >> assert (value instanceof PersistableEList);
>>> line431 >> if (!((PersistableEList) value).isLoaded())
>>> return;
>>> ....
>>>
>>> upgrade to jpox 1.1.7? I've read somewhere in Jpox forum that "above
>>> Jpox 113 only Spring 2 is compatible and I didn't want to change my jsp
>>> code for the spring 2 forms syntax...
>>>
>>> but, I just try with jpox117 and...
>>>
>>> 1- it doesn't seem to make problems with spring forms syntax, at first
>>> look...
>>> 2- error messages from the eclipse debugger is a bit clearer :
>>> for line 430 execution : >> *value instanceof PersistableEList"= false*
>>> for line 431 execution : >> *ClassCastException: Cannot cast
>>> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 (id=217) to
>>> org.eclipse.emf.teneo.mapping.elist.PersistableEList*
>>> gr. Daniel
>>>
>>>
>>>
>>> "Martin Taal" <mtaal@elver.org <mailto:mtaal@elver.org>> a écrit dans le
>>> message de news: f00e1v$88a$1@build.eclipse.org
>>> <mailto:f00e1v$88a$1@build.eclipse.org>...
>>> > Hi Daniel,
>>> > Is it a nullpointerexception or a classcastexception (you mention
>>> both)?
>>> > You can't upgrade to jpox 1.1.7?
>>> >
>>> > Which line in elistwrapper does it happen (my line 431 in cvs seems
>>> to be iter.hasNext which I can't
>>> > imagine to be the cause of the classcastexception)?
>>> >
>>> > gr. Martin
>>> >
>>> > daniel wrote:
>>> >> hi,
>>> >> I get an error when I try to update a record in the database (but no
>>> problem
>>> >> to add a new one ?)
>>> >> Data access failure: Could not invoke JDO makePersistent(Object)
>>> method;
>>> >> nested exception is java.lang.ClassCastException:
>>> >> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
>>> >> org.springframework.dao.InvalidDataAccessResourceUsageExcept ion:
>>> Could not
>>> >> invoke JDO makePersistent(Object) method; nested exception is
>>> >> java.lang.ClassCastException:
>>> >> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1
>>> >> java.lang.ClassCastException:
>>> >> org.eclipse.emf.teneo.jpox.elist.EListWrapper$1 at
>>> >>
>>> org.eclipse.emf.teneo.jpox.elist.EListWrapper.attachCopy(ELi stWrapper.java:431)
>>>
>>> >> at
>>> >>
>>> org.jpox.state.AttachFieldManager.storeObjectField(AttachFie ldManager.java:157)
>>>
>>> >> at
>>> >>
>>> org.jpox.state.StateManagerImpl.providedObjectField(StateMan agerImpl.java:2748)
>>>
>>> >> at org.MyClassImpl.jdoProvideField(MyClassImpl.java) at....
>>> >>
>>> >> the error is a ClassCastException thrown from the spring
>>> webcontainer method
>>> >> public class JdoTemplate extends JdoAccessor implements JdoOperations
>>> {
>>> >> ......
>>> >> public void makePersistent(final Object entity) throws
>>> DataAccessException {
>>> >> execute(new JdoCallback() {
>>> >> public Object doInJdo(PersistenceManager pm) throws JDOException {
>>> >> try {
>>> >> return makePersistentMethod.invoke(pm, new Object[] {entity});
>>> >> }
>>> >> catch (InvocationTargetException ex) {
>>> >> throw new InvalidDataAccessResourceUsageException(
>>> >> "Could not invoke JDO makePersistent(Object) method",
>>> >> ex.getTargetException());
>>> >> .......
>>> >>
>>> >> and the eclipse debugger seems to say that there is a
>>> nullPointerException
>>> >> in the EListWrapper attachCopy method execution :
>>> >> public class EListWrapper<E> extends PersistableEList<E> implements
>>> SCO,
>>> >> Queryable, SCOList {
>>> >> .....
>>> >> public void attachCopy(Object value) {
>>> >> // if not loaded then nothing changed so nothing to attach
>>> >> assert (value instanceof PersistableEList);
>>> >> if (!((PersistableEList) value).isLoaded())
>>> >> return;
>>> >> .....
>>> >> because "binding error on value"... which is null ("binding ==null
>>> for
>>> >> value")
>>> >>
>>> >> but the call, from the org.jpox.state.StateManager to the teneo sco
>>> class
>>> >> (ElistWapper) seems to be good
>>> >> public class AttachFieldManager extends AbstractFieldManager
>>> >> {
>>> >> ......
>>> >> public void storeObjectField(int fieldNumber, Object value)
>>> >> {
>>> >> .......
>>> >> sco.attachCopy(value);
>>> >> ......
>>> >> sco and value are ElistWapper$1, empty but not null
>>> >>
>>> >> the teneo log seems to be good :
>>> >> ....
>>> >> 15:53:55,625 (http-8080-Processor23) DEBUG
>>> >> [org.eclipse.emf.teneo.mapping.elist.PersistableEList] - Loading
>>> EList of
>>> >> type: org.eclipse.emf.teneo.jpox.elist.EListWrapper of member
>>> myField (that
>>> >> cause the error) owned by MyClass with delegate list
>>> java.util.ArrayList
>>> >> ....
>>> >> I use Eclipse3.2, EMF 2.2.2, teneo : emft-teneo-SDK-I200703301643,
>>> Jpox1.3
>>> >> (to stay compatible withe Spring 1.2.X for syntax reason), Spring
>>> 1.2.8.
>>> >> I've tried with Eclipse3.3, EMF 2.3, teneo :
>>> emft-teneo-SDK-I200703301643
>>> >> etc... and that's the same
>>> >>
>>> >> To be able to send you an example to reproduce to problem, I'tried
>>> to shrink
>>> >> my webapp to the 3 or 4 classes with the field which cause the
>>> error... but
>>> >> in this case, I have no error...?
>>> >> I don't know where to search the error
>>> >>
>>> >> Thanks
>>> >> Daniel
>>> >>
>>> >>
>>> >
>>> >
>>> > --
>>> >
>>> > With Regards, Martin Taal
>>> >
>>> > Springsite/Elver.org
>>> > Office: Hardwareweg 4, 3821 BV Amersfoort
>>> > Postal: Nassaulaan 7, 3941 EC Doorn
>>> > The Netherlands
>>> > Tel: +31 (0)84 420 2397
>>> > Fax: +31 (0)84 225 9307
>>> > Mail: mtaal@springsite.com <mailto:mtaal@springsite.com> -
>>> mtaal@elver.org <mailto:mtaal@elver.org>
>>> > Web: www.springsite.com <http://www.springsite.com> - www.elver.org
>>> <http://www.elver.org>
>>
>> --
>>
>> With Regards, Martin Taal
>>
>> Springsite/Elver.org
>> Office: Hardwareweg 4, 3821 BV Amersfoort
>> Postal: Nassaulaan 7, 3941 EC Doorn
>> The Netherlands
>> Tel: +31 (0)84 420 2397
>> Fax: +31 (0)84 225 9307
>> Mail: mtaal@springsite.com - mtaal@elver.org
>> Web: www.springsite.com - www.elver.org
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:GMF(Callisto) 1.0.3: org.eclipse.emf.validation.ocl requires "org.eclipse.ocl.ecore" ????
Next Topic:[Teneo] correct version for Eclipse 3.2.2 ??
Goto Forum:
  


Current Time: Fri Apr 19 12:10:44 GMT 2024

Powered by FUDForum. Page generated in 0.03319 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top