[ 
https://issues.apache.org/jira/browse/TUSCANY-2228?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12589075#action_12589075
 ] 

Mark Combellack commented on TUSCANY-2228:
------------------------------------------

The cause of this issue is that the class JavaPropertyValueObjectFactory in 
implementation-java-runtime calls the 
simpleTypeMapper.toJavaObject() method which will throw NumberFormatException 
or IllegalArgumentException if the data it is attempting to convert is not 
valid.

The fix for this issue is to add try/catch block for these two exceptions and 
make sure the Property name is in the exception.

> Setting an Integer Property with a non-number throws NumberFormatException - 
> but for which Property?
> ----------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-2228
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-2228
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SCA Java Implementation Extension
>    Affects Versions: Java-SCA-Next
>         Environment: SVN trunk revision 648161
> Linux
>            Reporter: Mark Combellack
>            Assignee: Mark Combellack
>             Fix For: Java-SCA-Next
>
>
> If I define a Property on my Component as type int and then attempt to set 
> the property value in the XML to a non-number (e.g. the String "Hello"), 
> Tuscany will throw the following exception:
> org.osoa.sca.ServiceRuntimeException: java.lang.NumberFormatException: For 
> input string: ""
>         at 
> org.apache.tuscany.sca.host.embedded.SCADomain.createNewInstance(SCADomain.java:264)
>         at 
> org.apache.tuscany.sca.host.embedded.SCADomain.newInstance(SCADomain.java:69)
>         <stack trace snipped here>
> Caused by: java.lang.NumberFormatException: For input string: ""
>         at 
> java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
>         at java.lang.Integer.parseInt(Integer.java:468)
>         at java.lang.Integer.parseInt(Integer.java:497)
>         at 
> org.apache.tuscany.sca.databinding.impl.XSDDataTypeConverter.parseInt(XSDDataTypeConverter.java:771)
>         at 
> org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl.toJavaObject(SimpleTypeMapperImpl.java:280)
>         at 
> org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory$ObjectFactoryImpl.getInstance(JavaPropertyValueObjectFactory.java:223)
>         at 
> org.apache.tuscany.sca.implementation.java.injection.FieldInjector.inject(FieldInjector.java:52)
>         at 
> org.apache.tuscany.sca.implementation.java.context.ReflectiveInstanceFactory.newInstance(ReflectiveInstanceFactory.java:80)
>         at 
> org.apache.tuscany.sca.implementation.java.invocation.JavaComponentContextProvider.createInstanceWrapper(JavaComponentContextProvider.java:101)
>         at 
> org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationProvider.createInstanceWrapper(JavaImplementationProvider.java:203)
>         at 
> org.apache.tuscany.sca.core.scope.AbstractScopeContainer.createInstanceWrapper(AbstractScopeContainer.java:65)
>         at 
> org.apache.tuscany.sca.core.scope.CompositeScopeContainer.getWrapper(CompositeScopeContainer.java:52)
>         at 
> org.apache.tuscany.sca.core.scope.CompositeScopeContainer.start(CompositeScopeContainer.java:71)
>         at 
> org.apache.tuscany.sca.core.assembly.CompositeActivatorImpl.start(CompositeActivatorImpl.java:540)
>         at 
> org.apache.tuscany.sca.core.assembly.CompositeActivatorImpl.start(CompositeActivatorImpl.java:476)
>         at 
> org.apache.tuscany.sca.core.assembly.CompositeActivatorImpl.start(CompositeActivatorImpl.java:529)
>         at 
> org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.init(DefaultSCADomain.java:221)
>         at 
> org.apache.tuscany.sca.host.embedded.impl.DefaultSCADomain.<init>(DefaultSCADomain.java:109)
>         at 
> org.apache.tuscany.sca.host.embedded.SCADomain.createNewInstance(SCADomain.java:230)
> The big problem with this exception is that it does not tell you which field 
> is invalid

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to