From 551f6edf58b574ab5e12207b7c44433514415354 Mon Sep 17 00:00:00 2001 From: slaws Date: Fri, 9 Apr 2010 11:56:14 +0000 Subject: TUSCANY-3530 - not a solution for property type validation but display more info at runtime when a simple type conversion fails. We need to validate the property types at read or build time. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@932370 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/databinding/jaxb/JAXBContextHelper.java | 12 +++++++++++- .../java/context/ReflectiveInstanceFactory.java | 2 +- .../java/invocation/JavaImplementationInvoker.java | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java b/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java index 81f4475f4b..50fc346270 100644 --- a/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java +++ b/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java @@ -182,7 +182,17 @@ public final class JAXBContextHelper { return createJAXBElement(context, dataType, value); } else { if (value instanceof JAXBElement) { - return ((JAXBElement)value).getValue(); + Object returnValue = ((JAXBElement)value).getValue(); + + if (returnValue == null){ + // TUSCANY-3530 + // something went wrong in the transformation that + // generated the JAXBElement. Have seen this when trying + // to convert a value to a simple type with an incompatible + // value. + throw new TransformationException("Null returned when trying to convert value to: " + cls.getName()); + } + return returnValue; } else { return value; } diff --git a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java index 8189271ed5..209546ce2f 100644 --- a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java +++ b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java @@ -83,7 +83,7 @@ public class ReflectiveInstanceFactory implements InstanceFactory { if (destroyInvoker != null) { destroyInvoker.invokeEvent(instance); } - throw new ObjectCreationException("Exception invoking injector", e); + throw new ObjectCreationException("Exception invoking injector - " + e.getMessage(), e); } } } diff --git a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java index 26e1e56845..4d54fbd46c 100644 --- a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java +++ b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java @@ -23,6 +23,7 @@ import java.lang.reflect.Method; import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.core.factory.InstanceWrapper; +import org.apache.tuscany.sca.core.factory.ObjectCreationException; import org.apache.tuscany.sca.core.scope.ScopeContainer; import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent; import org.apache.tuscany.sca.implementation.java.JavaImplementation; @@ -137,6 +138,8 @@ public class JavaImplementationInvoker implements Invoker { } } + } catch (ObjectCreationException e) { + throw new ServiceRuntimeException(e.getMessage(), e); } catch (Exception e) { msg.setFaultBody(e); } finally { -- cgit v1.2.3