Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Riena » Java 5 Enums / Hessian / Riena
Java 5 Enums / Hessian / Riena [message #496232] Mon, 09 November 2009 12:28 Go to next message
Jens Mayer is currently offline Jens Mayer
Messages: 19
Registered: September 2009
Location: Hamburg
Junior Member
Hi,

I encountered a com.caucho.hessian.io.HessianFieldException when I tried to use a DTO which owns an Enum.

This is the Enum:

public enum BelegTyp {
	
	Lieferschein("LIEFERUNG"),
	Retoure("RETOURE"),
	Rechnung("REKO");
	
	private final static Map<String,BelegTyp> map = new HashMap<String,BelegTyp>();
	private final String value;

	private BelegTyp (String val){
		this.value = val;
	}
	
	public String getValue() {
		return value;
	}
	
	@Override
	public String toString() {
		return value;
	}
}



... this is the DTO which owns the Enum:

public class DTOBeleg {
	protected BelegTyp typ;

	public BelegTyp getTyp() {
		return typ;
	}

	public void setTyp(BelegTyp typ) {
		this.typ = typ;
	}
}



... and this is the DTO which has to be transferred:

public class DTOLieferschein extends DTOBeleg {

	private String lieferscheinNr;

        (...)

	public String getLieferscheinNr() {
		return lieferscheinNr;
	}

	public void setLieferscheinNr(String lieferscheinNr) {
		this.lieferscheinNr = lieferscheinNr;
	}

        (...)
}


On the client-side the following exception is fired during deserialization:

Caused by: com.caucho.hessian.io.HessianFieldException: de.myapp.common.we.DTOBeleg.typ: de.myapp.common.we.DTOLieferschein (DTOLieferschein [allbel_id=0, lieferscheinNr=00039023]) cannot be assigned to de.myapp.common.we.BelegTyp
	at com.caucho.hessian.io.JavaDeserializer.logDeserializeError(JavaDeserializer.java:589)
	at com.caucho.hessian.io.JavaDeserializer$ObjectFieldDeserializer.deserialize(JavaDeserializer.java:387)
	at com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:233)
	at com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeserializer.java:157)
	at com.caucho.hessian.io.SerializerFactory.readObject(SerializerFactory.java:364)
	at com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessian2Input.java:2017)
	at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1943)
	at com.caucho.hessian.io.CollectionDeserializer.readList(CollectionDeserializer.java:78)
	at com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input.java:1666)
	at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.java:201)
	... 36 more



I know that there were some issues with hessian and Java5-Enums in former versions of hessian (3.0.x)
Riena 1.1.0 uses Hessian 3.1.3, right ? So Enums should be supported.

Can anybody tell me how to avoid these errors?

Thanks in advance, Jens

[Updated on: Mon, 09 November 2009 12:29]

Report message to a moderator

Riena RCP mit redView - events - [message #496268 is a reply to message #496232] Mon, 09 November 2009 14:40 Go to previous messageGo to next message
ekkehard gentz is currently offline ekkehard gentz
Messages: 118
Registered: July 2009
Location: rosenheim, Germany, bavar...
Senior Member

This is a multi-part message in MIME format.
--------------080903070108060005000003
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

if you're interested into Riena RCP - I'll demonstrate the next weeks
how redView (Riena EMF Dynamic Views) will enhance Riena RCP applications,
esp. if you're using a model-driven workflow.

redView (http://redview.org) will finally become open source (EPL) in
nov/dec 2009.
promised !!!

first time I presented redView together with flo at EclipseCon 2009 and
I know it took much more time as expected to reach the point where we'll
make it open source.

please notice: redView was developed by flo and me: flo does it in his
spare time beside his regular job
and I'm self-employed - so there's (till now) no company behind redView.
but there are real projects using redView.

redView provides a WYSIWYG SWT editor and can be used for prototyping,
RCP applications with riena UI + LnF
or as a nice UI for WebServices. redView Views can be generated using
openArchitectureWare (MWE / Xpand / Xtend)

the next weeks we'll fill some gaps and create documentation and I'll
also demonstrate redView:

Munich, W-JAX, 2009-11-11, BOF, Room Barcelona, 19:30 - 20:30
"Was man mit Eclipse EMF alles machen kann: Business UIs modellgetrieben"
(What you can do with Eclipse EMF: Business UIs model-driven)
http://it-republik.de/jaxenter/wjax09/

Karlsruhe, Open Source EXPO, 2009-11-15 + 2009-11-16 at Exhibition
and 2009-11-16, 16:35 - 17:05 Open Stage
http://it-republik.de/konferenzen/openexpo/psecom,id,1.html

Eclipse Democamp Frankfurt, 2009-11-26
http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Fran kfurt

Eclipse Democamp Hamburg, 2009-12-04
http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Hamb urg

(and Flo will present redView at Eclipse Democamp, Vienna, 2009-11-30
http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Vien na)

read more about redView at http://redview.wordpress.com/
or http://ekkescorner.wordpress.com/
or follow me at @twitter http://twitter.com/ekkescorner

I'll publish the links soon after redView can be downloaded (EPL)
--

ekke (ekkehard gentz)
independent software-architect
senior erp-consultant
eclipse | osgi | equinox | mdsd | oaw | emf | uml
max-josefs-platz 30, D-83022 rosenheim, germany
mailto:ekke@ekkes-corner.org
homepage (de): http://gentz-software.de
blog (en): http://ekkes-corner.org
twitter: @ekkescorner
skype: ekkes-corner
Steuer-Nr: 156/220/30931 FA Rosenheim, UST-ID: DE189929490


--------------080903070108060005000003
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
if you're interested into Riena RCP - I'll demonstrate the next weeks
how redView (Riena EMF Dynamic Views) will enhance Riena RCP
applications,<br>
esp. if you're using a model-driven workflow.<br>
<br>
redView (<a class="moz-txt-link-freetext" href="http://redview.org">http://redview.org</a>) will finally become open source (EPL) in
nov/dec 2009.<br>
promised !!!<br>
<br>
first time I presented redView together with flo at EclipseCon 2009 and<br>
I know it took much more time as expected to reach the point where
we'll make it open source.<br>
<br>
please notice: redView was developed by flo and me: flo does it in his
spare time beside his regular job<br>
and I'm self-employed - so there's (till now) no company behind redView.<br>
but there are real projects using redView.<br>
<br>
redView provides a WYSIWYG SWT editor and can be used for prototyping,
RCP applications with riena UI + LnF<br>
or as a nice UI for WebServices. redView Views can be generated using
openArchitectureWare (MWE / Xpand / Xtend)<br>
<br>
the next weeks we'll fill some gaps and create documentation and I'll
also demonstrate redView:<br>
<br>
Munich, W-JAX, 2009-11-11, BOF, Room Barcelona, 19:30 - 20:30<br>
"Was man mit Eclipse EMF alles machen kann: Business UIs
modellgetrieben"<br>
(What you can do with Eclipse EMF: Business UIs model-driven)<br>
<a class="moz-txt-link-freetext" href="http://it-republik.de/jaxenter/wjax09/">http://it-republik.de/jaxenter/wjax09/</a><br>
<br>
Karlsruhe, Open Source EXPO, 2009-11-15 + 2009-11-16 at Exhibition<br>
and 2009-11-16, 16:35 - 17:05 Open Stage<br>
<a class="moz-txt-link-freetext" href="http://it-republik.de/konferenzen/openexpo/psecom,id,1.html">http://it-republik.de/konferenzen/openexpo/psecom,id,1.html</a><br>
<br>
Eclipse Democamp Frankfurt, 2009-11-26<br>
<a class="moz-txt-link-freetext" href=" http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Fran kfurt"> http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Fran kfurt</a><br>
<br>
Eclipse Democamp Hamburg, 2009-12-04<br>
<a class="moz-txt-link-freetext" href=" http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Hamb urg"> http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Hamb urg</a><br>
<br>
(and Flo will present redView at Eclipse Democamp, Vienna, 2009-11-30<br>
<a class="moz-txt-link-freetext" href=" http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Vien na"> http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Vien na</a>)<br>
<br>
read more about redView at <a class="moz-txt-link-freetext" href="http://redview.wordpress.com/">http://redview.wordpress.com/</a><br>
or <a class="moz-txt-link-freetext" href="http://ekkescorner.wordpress.com/">http://ekkescorner.wordpress.com/</a><br>
or follow me at @twitter <a class="moz-txt-link-freetext" href="http://twitter.com/ekkescorner">http://twitter.com/ekkescorner</a><br>
<br>
I'll publish the links soon after redView can be downloaded (EPL)<br>
<div class="moz-signature">-- <br>
<p style="margin-bottom: 0cm;"> <font ,="" color="#808080"
face="Verdana, sans-serif"> <font size="4">ekke (ekkehard gentz)<br>
</font> <font size="3"> independent software-architect<br>
senior erp-consultant<br>
</font> <font size="2">eclipse | osgi | equinox | mdsd | oaw | emf |
uml<br>
max-josefs-platz 30, D-83022 rosenheim, germany<br>
<a class="moz-txt-link-freetext" href="mailto:ekke@ekkes-corner.org">mailto:ekke@ekkes-corner.org</a><br>
homepage (de): <a class="moz-txt-link-freetext" href="http://gentz-software.de">http://gentz-software.de</a><br>
blog (en): <a class="moz-txt-link-freetext" href="http://ekkes-corner.org">http://ekkes-corner.org</a><br>
twitter: @ekkescorner<br>
skype: ekkes-corner<br>
</font> <font size="1"> Steuer-Nr: 156/220/30931 FA Rosenheim, UST-ID:
DE189929490<br>
</font> </font> </p>
</div>
</body>
</html>

--------------080903070108060005000003--


ekke
independent software architect

blog: http://ekkes-corner.org
twitter: @ekkescorner
Re: Java 5 Enums / Hessian / Riena [message #496477 is a reply to message #496232] Tue, 10 November 2009 08:57 Go to previous messageGo to next message
Stefan Liebig is currently offline Stefan Liebig
Messages: 124
Registered: July 2009
Senior Member
Hi Jens,

I tried to reproduce your problem. But I could not reproduce it.
Within our test bundle we have a AbstractSerializerFactoryTestCase
class. With that I wrote a test case (see below) trying to reproduce
your problem. I added equals/hashCode for comparing the expected and
result objects. Could you please run the test in your environment?
(Yes, we use Hessian 3.1.3)

public class EnumProblemOnNG extends AbstractSerializerFactoryTestCase {

public void testEnumGiven() {
DTOLieferschein lieferschein = new DTOLieferschein();
lieferschein.setLieferscheinNr("0815");
lieferschein.setTyp(BelegTyp.Lieferschein);
assertTrue(isBackAndForthOk(lieferschein,
HessianSerializerVersion.Two, null));
}

public void testEnumNotGiven() {
DTOLieferschein lieferschein = new DTOLieferschein();
lieferschein.setLieferscheinNr("0815");
assertTrue(isBackAndForthOk(lieferschein,
HessianSerializerVersion.Two, null));
}

private static enum BelegTyp {

Lieferschein("LIEFERUNG"), Retoure("RETOURE"), Rechnung("REKO");

private final static Map<String, BelegTyp> map = new HashMap<String,
BelegTyp>();
private final String value;

private BelegTyp(String val) {
this.value = val;
}

public String getValue() {
return value;
}

@Override
public String toString() {
return value;
}
}

// ... this is the DTO which owns the Enum:

private static class DTOBeleg {
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((typ == null) ? 0 : typ.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
DTOBeleg other = (DTOBeleg) obj;
if (typ == null) {
if (other.typ != null) {
return false;
}
} else if (!typ.equals(other.typ)) {
return false;
}
return true;
}

protected BelegTyp typ;

public BelegTyp getTyp() {
return typ;
}

public void setTyp(BelegTyp typ) {
this.typ = typ;
}
}

//... and this is the DTO which has to be transferred:

public static class DTOLieferschein extends DTOBeleg {

@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((lieferscheinNr == null) ? 0 :
lieferscheinNr.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
DTOLieferschein other = (DTOLieferschein) obj;
if (lieferscheinNr == null) {
if (other.lieferscheinNr != null) {
return false;
}
} else if (!lieferscheinNr.equals(other.lieferscheinNr)) {
return false;
}
return true;
}

@Override
public String toString() {
return "DTOLieferschein [lieferscheinNr=" + lieferscheinNr + ", typ="
+ typ + "]";
}

private String lieferscheinNr;

// (...)

public String getLieferscheinNr() {
return lieferscheinNr;
}

public void setLieferscheinNr(String lieferscheinNr) {
this.lieferscheinNr = lieferscheinNr;
}

// (...)
}

}


jens.mayer1@gmx.de wrote:
> Hi,
> I encountered a com.caucho.hessian.io.HessianFieldException when I tried
> to use a DTO which owns an Enum.
>
> This is the Enum:
>
>
> public enum BelegTyp {
>
> Lieferschein("LIEFERUNG"),
> Retoure("RETOURE"),
> Rechnung("REKO");
>
> private final static Map<String,BelegTyp> map = new
> HashMap<String,BelegTyp>();
> private final String value;
>
> private BelegTyp (String val){
> this.value = val;
> }
>
> public String getValue() {
> return value;
> }
>
> @Override
> public String toString() {
> return value;
> }
> }
>
>
>
> ... this is the DTO which owns the Enum:
>
>
> public class DTOBeleg {
> protected BelegTyp typ;
>
> public BelegTyp getTyp() {
> return typ;
> }
>
> public void setTyp(BelegTyp typ) {
> this.typ = typ;
> }
> }
>
>
>
> ... and this is the DTO which has to be transferred:
>
>
> public class DTOLieferschein extends DTOBeleg {
>
> private String lieferscheinNr;
>
> (...)
>
> public String getLieferscheinNr() {
> return lieferscheinNr;
> }
>
> public void setLieferscheinNr(String lieferscheinNr) {
> this.lieferscheinNr = lieferscheinNr;
> }
>
> (...)
> }
>
>
> On the client-side the following exception is fired during deserialization:
>
>
> Caused by: com.caucho.hessian.io.HessianFieldException:
> de.myapp.common.we.DTOBeleg.typ: de.myapp.common.we.DTOLieferschein
> (DTOLieferschein [allbel_id=0, lieferscheinNr=00039023]) cannot be
> assigned to de.myapp.common.we.BelegTyp
> at
> com.caucho.hessian.io.JavaDeserializer.logDeserializeError(J avaDeserializer.java:589)
>
> at
> com.caucho.hessian.io.JavaDeserializer$ObjectFieldDeserializ er.deserialize(JavaDeserializer.java:387)
>
> at
> com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeseri alizer.java:233)
>
> at
> com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeseri alizer.java:157)
>
> at
> com.caucho.hessian.io.SerializerFactory.readObject(Serialize rFactory.java:364)
>
> at
> com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessi an2Input.java:2017)
>
> at
> com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input .java:1943)
> at
> com.caucho.hessian.io.CollectionDeserializer.readList(Collec tionDeserializer.java:78)
>
> at
> com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input .java:1666)
> at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.j ava:201)
> ... 36 more
>
>
>
> I know that there were some issues with hessian and Java5-Enums in
> former versions of hessian (3.0.x)
> Riena 1.1.0 uses Hessian 3.1.3, right ? So Enums should be supported.
> Can anybody tell me how to avoid these errors?
>
Re: Java 5 Enums / Hessian / Riena [message #498320 is a reply to message #496477] Mon, 16 November 2009 13:41 Go to previous messageGo to next message
Jens Mayer is currently offline Jens Mayer
Messages: 19
Registered: September 2009
Location: Hamburg
Junior Member
Hi Stefan,

sorry for answering that late (last week I attended the w-jax 2009 in München - great conference!).

hmm - maybe I'm too dumb but I can't find the AbstractSerializerFactoryTestCase in the test bundle (nor Java Search neither Text Search gave any results). I'm using Riena 1.1.0 - maybe it's implemented only in 1.2.0.Mx ?

May you tell me the package that should contain that Testcase?

Thanks,

Jens
Re: Java 5 Enums / Hessian / Riena [message #498344 is a reply to message #498320] Mon, 16 November 2009 14:23 Go to previous message
Stefan Liebig is currently offline Stefan Liebig
Messages: 124
Registered: July 2009
Senior Member
Hi Jens,

Yes, it was introduced in 1.2.0.M1.
You could just fetch the head version of the package
"org.eclipse.riena.internal.communication.hessian" from our test bundle.
That should be sufficient for running the test.

Tschüß,
Stefan

jens.mayer1@gmx.de wrote:
> Hi Stefan,
>
> sorry for answering that late (last week I attended the w-jax 2009 in
> München - great conference!).
>
> hmm - maybe I'm too dumb but I can't find the
> AbstractSerializerFactoryTestCase in the test bundle (nor Java Search
> neither Text Search gave any results). I'm using Riena 1.1.0 - maybe
> it's implemented only in 1.2.0.Mx ?
>
> May you tell me the package that should contain that Testcase?
>
> Thanks,
>
> Jens
Riena RCP mit redView - events - [message #584071 is a reply to message #496232] Mon, 09 November 2009 14:40 Go to previous message
ekkehard gentz is currently offline ekkehard gentz
Messages: 118
Registered: July 2009
Location: rosenheim, Germany, bavar...
Senior Member

This is a multi-part message in MIME format.
--------------080903070108060005000003
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

if you're interested into Riena RCP - I'll demonstrate the next weeks
how redView (Riena EMF Dynamic Views) will enhance Riena RCP applications,
esp. if you're using a model-driven workflow.

redView (http://redview.org) will finally become open source (EPL) in
nov/dec 2009.
promised !!!

first time I presented redView together with flo at EclipseCon 2009 and
I know it took much more time as expected to reach the point where we'll
make it open source.

please notice: redView was developed by flo and me: flo does it in his
spare time beside his regular job
and I'm self-employed - so there's (till now) no company behind redView.
but there are real projects using redView.

redView provides a WYSIWYG SWT editor and can be used for prototyping,
RCP applications with riena UI + LnF
or as a nice UI for WebServices. redView Views can be generated using
openArchitectureWare (MWE / Xpand / Xtend)

the next weeks we'll fill some gaps and create documentation and I'll
also demonstrate redView:

Munich, W-JAX, 2009-11-11, BOF, Room Barcelona, 19:30 - 20:30
"Was man mit Eclipse EMF alles machen kann: Business UIs modellgetrieben"
(What you can do with Eclipse EMF: Business UIs model-driven)
http://it-republik.de/jaxenter/wjax09/

Karlsruhe, Open Source EXPO, 2009-11-15 + 2009-11-16 at Exhibition
and 2009-11-16, 16:35 - 17:05 Open Stage
http://it-republik.de/konferenzen/openexpo/psecom,id,1.html

Eclipse Democamp Frankfurt, 2009-11-26
http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Fran kfurt

Eclipse Democamp Hamburg, 2009-12-04
http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Hamb urg

(and Flo will present redView at Eclipse Democamp, Vienna, 2009-11-30
http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Vien na)

read more about redView at http://redview.wordpress.com/
or http://ekkescorner.wordpress.com/
or follow me at @twitter http://twitter.com/ekkescorner

I'll publish the links soon after redView can be downloaded (EPL)
--

ekke (ekkehard gentz)
independent software-architect
senior erp-consultant
eclipse | osgi | equinox | mdsd | oaw | emf | uml
max-josefs-platz 30, D-83022 rosenheim, germany
mailto:ekke@ekkes-corner.org
homepage (de): http://gentz-software.de
blog (en): http://ekkes-corner.org
twitter: @ekkescorner
skype: ekkes-corner
Steuer-Nr: 156/220/30931 FA Rosenheim, UST-ID: DE189929490


--------------080903070108060005000003
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
if you're interested into Riena RCP - I'll demonstrate the next weeks
how redView (Riena EMF Dynamic Views) will enhance Riena RCP
applications,<br>
esp. if you're using a model-driven workflow.<br>
<br>
redView (<a class="moz-txt-link-freetext" href="http://redview.org">http://redview.org</a>) will finally become open source (EPL) in
nov/dec 2009.<br>
promised !!!<br>
<br>
first time I presented redView together with flo at EclipseCon 2009 and<br>
I know it took much more time as expected to reach the point where
we'll make it open source.<br>
<br>
please notice: redView was developed by flo and me: flo does it in his
spare time beside his regular job<br>
and I'm self-employed - so there's (till now) no company behind redView.<br>
but there are real projects using redView.<br>
<br>
redView provides a WYSIWYG SWT editor and can be used for prototyping,
RCP applications with riena UI + LnF<br>
or as a nice UI for WebServices. redView Views can be generated using
openArchitectureWare (MWE / Xpand / Xtend)<br>
<br>
the next weeks we'll fill some gaps and create documentation and I'll
also demonstrate redView:<br>
<br>
Munich, W-JAX, 2009-11-11, BOF, Room Barcelona, 19:30 - 20:30<br>
"Was man mit Eclipse EMF alles machen kann: Business UIs
modellgetrieben"<br>
(What you can do with Eclipse EMF: Business UIs model-driven)<br>
<a class="moz-txt-link-freetext" href="http://it-republik.de/jaxenter/wjax09/">http://it-republik.de/jaxenter/wjax09/</a><br>
<br>
Karlsruhe, Open Source EXPO, 2009-11-15 + 2009-11-16 at Exhibition<br>
and 2009-11-16, 16:35 - 17:05 Open Stage<br>
<a class="moz-txt-link-freetext" href="http://it-republik.de/konferenzen/openexpo/psecom,id,1.html">http://it-republik.de/konferenzen/openexpo/psecom,id,1.html</a><br>
<br>
Eclipse Democamp Frankfurt, 2009-11-26<br>
<a class="moz-txt-link-freetext" href=" http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Fran kfurt"> http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Fran kfurt</a><br>
<br>
Eclipse Democamp Hamburg, 2009-12-04<br>
<a class="moz-txt-link-freetext" href=" http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Hamb urg"> http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Hamb urg</a><br>
<br>
(and Flo will present redView at Eclipse Democamp, Vienna, 2009-11-30<br>
<a class="moz-txt-link-freetext" href=" http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Vien na"> http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Vien na</a>)<br>
<br>
read more about redView at <a class="moz-txt-link-freetext" href="http://redview.wordpress.com/">http://redview.wordpress.com/</a><br>
or <a class="moz-txt-link-freetext" href="http://ekkescorner.wordpress.com/">http://ekkescorner.wordpress.com/</a><br>
or follow me at @twitter <a class="moz-txt-link-freetext" href="http://twitter.com/ekkescorner">http://twitter.com/ekkescorner</a><br>
<br>
I'll publish the links soon after redView can be downloaded (EPL)<br>
<div class="moz-signature">-- <br>
<p style="margin-bottom: 0cm;"> <font ,="" color="#808080"
face="Verdana, sans-serif"> <font size="4">ekke (ekkehard gentz)<br>
</font> <font size="3"> independent software-architect<br>
senior erp-consultant<br>
</font> <font size="2">eclipse | osgi | equinox | mdsd | oaw | emf |
uml<br>
max-josefs-platz 30, D-83022 rosenheim, germany<br>
<a class="moz-txt-link-freetext" href="mailto:ekke@ekkes-corner.org">mailto:ekke@ekkes-corner.org</a><br>
homepage (de): <a class="moz-txt-link-freetext" href="http://gentz-software.de">http://gentz-software.de</a><br>
blog (en): <a class="moz-txt-link-freetext" href="http://ekkes-corner.org">http://ekkes-corner.org</a><br>
twitter: @ekkescorner<br>
skype: ekkes-corner<br>
</font> <font size="1"> Steuer-Nr: 156/220/30931 FA Rosenheim, UST-ID:
DE189929490<br>
</font> </font> </p>
</div>
</body>
</html>

--------------080903070108060005000003--


ekke
independent software architect

blog: http://ekkes-corner.org
twitter: @ekkescorner
Re: Java 5 Enums / Hessian / Riena [message #584078 is a reply to message #496232] Tue, 10 November 2009 08:57 Go to previous message
Stefan Liebig is currently offline Stefan Liebig
Messages: 124
Registered: July 2009
Senior Member
Hi Jens,

I tried to reproduce your problem. But I could not reproduce it.
Within our test bundle we have a AbstractSerializerFactoryTestCase
class. With that I wrote a test case (see below) trying to reproduce
your problem. I added equals/hashCode for comparing the expected and
result objects. Could you please run the test in your environment?
(Yes, we use Hessian 3.1.3)

public class EnumProblemOnNG extends AbstractSerializerFactoryTestCase {

public void testEnumGiven() {
DTOLieferschein lieferschein = new DTOLieferschein();
lieferschein.setLieferscheinNr("0815");
lieferschein.setTyp(BelegTyp.Lieferschein);
assertTrue(isBackAndForthOk(lieferschein,
HessianSerializerVersion.Two, null));
}

public void testEnumNotGiven() {
DTOLieferschein lieferschein = new DTOLieferschein();
lieferschein.setLieferscheinNr("0815");
assertTrue(isBackAndForthOk(lieferschein,
HessianSerializerVersion.Two, null));
}

private static enum BelegTyp {

Lieferschein("LIEFERUNG"), Retoure("RETOURE"), Rechnung("REKO");

private final static Map<String, BelegTyp> map = new HashMap<String,
BelegTyp>();
private final String value;

private BelegTyp(String val) {
this.value = val;
}

public String getValue() {
return value;
}

@Override
public String toString() {
return value;
}
}

// ... this is the DTO which owns the Enum:

private static class DTOBeleg {
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((typ == null) ? 0 : typ.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
DTOBeleg other = (DTOBeleg) obj;
if (typ == null) {
if (other.typ != null) {
return false;
}
} else if (!typ.equals(other.typ)) {
return false;
}
return true;
}

protected BelegTyp typ;

public BelegTyp getTyp() {
return typ;
}

public void setTyp(BelegTyp typ) {
this.typ = typ;
}
}

//... and this is the DTO which has to be transferred:

public static class DTOLieferschein extends DTOBeleg {

@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((lieferscheinNr == null) ? 0 :
lieferscheinNr.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
DTOLieferschein other = (DTOLieferschein) obj;
if (lieferscheinNr == null) {
if (other.lieferscheinNr != null) {
return false;
}
} else if (!lieferscheinNr.equals(other.lieferscheinNr)) {
return false;
}
return true;
}

@Override
public String toString() {
return "DTOLieferschein [lieferscheinNr=" + lieferscheinNr + ", typ="
+ typ + "]";
}

private String lieferscheinNr;

// (...)

public String getLieferscheinNr() {
return lieferscheinNr;
}

public void setLieferscheinNr(String lieferscheinNr) {
this.lieferscheinNr = lieferscheinNr;
}

// (...)
}

}


jens.mayer1@gmx.de wrote:
> Hi,
> I encountered a com.caucho.hessian.io.HessianFieldException when I tried
> to use a DTO which owns an Enum.
>
> This is the Enum:
>
>
> public enum BelegTyp {
>
> Lieferschein("LIEFERUNG"),
> Retoure("RETOURE"),
> Rechnung("REKO");
>
> private final static Map<String,BelegTyp> map = new
> HashMap<String,BelegTyp>();
> private final String value;
>
> private BelegTyp (String val){
> this.value = val;
> }
>
> public String getValue() {
> return value;
> }
>
> @Override
> public String toString() {
> return value;
> }
> }
>
>
>
> ... this is the DTO which owns the Enum:
>
>
> public class DTOBeleg {
> protected BelegTyp typ;
>
> public BelegTyp getTyp() {
> return typ;
> }
>
> public void setTyp(BelegTyp typ) {
> this.typ = typ;
> }
> }
>
>
>
> ... and this is the DTO which has to be transferred:
>
>
> public class DTOLieferschein extends DTOBeleg {
>
> private String lieferscheinNr;
>
> (...)
>
> public String getLieferscheinNr() {
> return lieferscheinNr;
> }
>
> public void setLieferscheinNr(String lieferscheinNr) {
> this.lieferscheinNr = lieferscheinNr;
> }
>
> (...)
> }
>
>
> On the client-side the following exception is fired during deserialization:
>
>
> Caused by: com.caucho.hessian.io.HessianFieldException:
> de.myapp.common.we.DTOBeleg.typ: de.myapp.common.we.DTOLieferschein
> (DTOLieferschein [allbel_id=0, lieferscheinNr=00039023]) cannot be
> assigned to de.myapp.common.we.BelegTyp
> at
> com.caucho.hessian.io.JavaDeserializer.logDeserializeError(J avaDeserializer.java:589)
>
> at
> com.caucho.hessian.io.JavaDeserializer$ObjectFieldDeserializ er.deserialize(JavaDeserializer.java:387)
>
> at
> com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeseri alizer.java:233)
>
> at
> com.caucho.hessian.io.JavaDeserializer.readObject(JavaDeseri alizer.java:157)
>
> at
> com.caucho.hessian.io.SerializerFactory.readObject(Serialize rFactory.java:364)
>
> at
> com.caucho.hessian.io.Hessian2Input.readObjectInstance(Hessi an2Input.java:2017)
>
> at
> com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input .java:1943)
> at
> com.caucho.hessian.io.CollectionDeserializer.readList(Collec tionDeserializer.java:78)
>
> at
> com.caucho.hessian.io.Hessian2Input.readObject(Hessian2Input .java:1666)
> at com.caucho.hessian.client.HessianProxy.invoke(HessianProxy.j ava:201)
> ... 36 more
>
>
>
> I know that there were some issues with hessian and Java5-Enums in
> former versions of hessian (3.0.x)
> Riena 1.1.0 uses Hessian 3.1.3, right ? So Enums should be supported.
> Can anybody tell me how to avoid these errors?
>
Re: Java 5 Enums / Hessian / Riena [message #584102 is a reply to message #496477] Mon, 16 November 2009 13:41 Go to previous message
Jens Mayer is currently offline Jens Mayer
Messages: 19
Registered: September 2009
Location: Hamburg
Junior Member
Hi Stefan,

sorry for answering that late (last week I attended the w-jax 2009 in München - great conference!).

hmm - maybe I'm too dumb but I can't find the AbstractSerializerFactoryTestCase in the test bundle (nor Java Search neither Text Search gave any results). I'm using Riena 1.1.0 - maybe it's implemented only in 1.2.0.Mx ?

May you tell me the package that should contain that Testcase?

Thanks,

Jens
Re: Java 5 Enums / Hessian / Riena [message #584112 is a reply to message #584102] Mon, 16 November 2009 14:23 Go to previous message
Stefan Liebig is currently offline Stefan Liebig
Messages: 124
Registered: July 2009
Senior Member
Hi Jens,

Yes, it was introduced in 1.2.0.M1.
You could just fetch the head version of the package
"org.eclipse.riena.internal.communication.hessian" from our test bundle.
That should be sufficient for running the test.

Tschüß,
Stefan

jens.mayer1@gmx.de wrote:
> Hi Stefan,
>
> sorry for answering that late (last week I attended the w-jax 2009 in
> München - great conference!).
>
> hmm - maybe I'm too dumb but I can't find the
> AbstractSerializerFactoryTestCase in the test bundle (nor Java Search
> neither Text Search gave any results). I'm using Riena 1.1.0 - maybe
> it's implemented only in 1.2.0.Mx ?
>
> May you tell me the package that should contain that Testcase?
>
> Thanks,
>
> Jens
Previous Topic:Using SSLConfiguration
Next Topic:Riena 1.2.0.M3 is available
Goto Forum:
  


Current Time: Fri Sep 19 15:58:03 GMT 2014

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

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