BlazeDs java.lang.Double cannot be cast to java.lang.Float

1k views Asked by At

Hello I'm implementing some tests through an AMF connection to test the performaces of a service deployed to a wildfly8 application server instance, that saves a complex type of entity. This entity contains a field like:

  private Quantity<Float> quantity = null;

When Quantity is an object.

public class Quantity<T extends Number> implements Serializable

When this field is valued it is raised an exception:

javax.ejb.EJBTransactionRolledbackException: java.lang.Double cannot be cast to java.lang.Float
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleInCallerTx(CMTTxInterceptor.java:163)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInCallerTx(CMTTxInterceptor.java:253)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:342)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:239)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:309)

Caused by: java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Float
at org.hibernate.type.descriptor.java.FloatTypeDescriptor.unwrap(FloatTypeDescriptor.java:36)
at org.hibernate.type.descriptor.sql.RealTypeDescriptor$1.doBind(RealTypeDescriptor.java:64)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:90)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:286)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:281)
at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:367)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2843)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3121)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3581)`

As suggested in this link (http://flexblog.faratasystems.com/index.php/custom-type-masrhaller-in-blazeds) I tried to override the method ASTranslator.convert (Object source, Class desiredClass) using a NumberDecoder to solve a problem known in BlazeDS, but nothing changed.

The problem is that Flex java wrapper classes (i.e. Float, Double, Long, Integer, Short, Byte, BigDecimal and BigInteger) and simple type (i.e. float, double, long, int, short, byte) are marshaled into AS3 Number type.

0

There are 0 answers