You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Jean-Sebastien Delfino <js...@apache.org> on 2007/11/12 17:39:02 UTC

DataBinding issues - ClassCastException

I'm trying to add some support for business objects to the Tutorial 
(instead of just flowing the catalog and cart items as strings).

My business objects are simple JavaBeans with an empty constructor. I 
need to flow them as Java objects through local service calls, XML (in 
Atom payloads) and JSON.

It should have been a simple exercise, but I've been running into a 
number of issues with the DataBinding framework. Here they are:

1. Some of the Bean2* and *2Bean transformers were missing to 
META-INF/services I added them.

2. The Databinding framework was not finding the transformers in XML <-> 
registrations. I changed all instances of java.lang.String to xml.string 
in the registrations of the *2String and String2* transformer to fix that.

3. Next I ran into a ClassCastException in XML2JavaBeanTransformer at
public Object transform(T source, TransformationContext context) {
- ->       XMLType xmlType = (XMLType) 
context.getSourceDataType().getLogical();
as the logical type was Class instead of XMLType

4. I had to add "implements Serializable" to my business object class as 
it looks like we are using Java serialization to enforce pass by value 
in local service calls. I don't think it's right as we are not using 
Java serialization to pass the same business object through a remote 
call. We should change to use the same XML transformation to enforce 
pass by value with local calls as well, and not require the business 
objects to be Serializable.

5. After changes (1), (2), (3) and (4) I am now running into a build issue:
testTransform1(org.apache.tuscany.sca.databinding.impl.MediatorImplTestCase)  
Time elapsed: 0.02 sec  <<< ERROR!
java.lang.ClassCastException: 
org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer 
cannot be cast to org.apache.tuscany.sca.databinding.DataPipeTransformer
        at 
org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:75)
        at 
org.apache.tuscany.sca.databinding.impl.MediatorImplTestCase.testTransform1(MediatorImplTestCase.java:104)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at junit.framework.TestCase.runTest(TestCase.java:168)
        at junit.framework.TestCase.runBare(TestCase.java:134)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:124)
        at junit.framework.TestSuite.runTest(TestSuite.java:232)
        at junit.framework.TestSuite.run(TestSuite.java:227)
        at 
org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
        at 
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
        at 
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
        at 
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:299)
        at 
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:837)

I'm getting to the end of the rope here... does anyone know what can 
cause error (5)?

Thanks

-- 
Jean-Sebastien


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Updated tutorial, was: DataBinding issues - ClassCastException

Posted by Jean-Sebastien Delfino <js...@apache.org>.
[snip]
Jean-Sebastien Delfino wrote:
> Jean-Sebastien Delfino wrote:
>> Jean-Sebastien Delfino wrote:
>>> I'm trying to add some support for business objects to the Tutorial 
>>> (instead of just flowing the catalog and cart items as strings).
>>>
>>> My business objects are simple JavaBeans with an empty constructor. 
>>> I need to flow them as Java objects through local service calls, XML 
>>> (in Atom payloads) and JSON.
>>>
>>> It should have been a simple exercise, but I've been running into a 
>>> number of issues with the DataBinding framework. Here they are:
>>>

OK, I've been able to fix or workaround the issues I described earlier. 
An update of the tutorial using business objects (see class Item in the 
assets module) is now available in SVN.

I also put under tutorial a Tutorial.pdf that shows the steps in the 
construction of the tutorial application.

After what I've been through trying to get my little Item object 
converted to XML and JSON I'm going to do a little bit of thinking and 
I'll post some suggestions later to try to simplify the whole 
databinding story.

-- 

Jean-Sebastien


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: DataBinding issues - ClassCastException

Posted by Raymond Feng <en...@gmail.com>.
OK. I found the problem. I am testing the fix now and will check it in as 
soon as the full build passes.

Thanks,
Raymond

----- Original Message ----- 
From: "Jean-Sebastien Delfino" <js...@apache.org>
To: <tu...@ws.apache.org>
Sent: Tuesday, November 13, 2007 10:09 AM
Subject: Re: DataBinding issues - ClassCastException


> Raymond Feng wrote:
>> What problem did you see with JavaBean2XMLStreamReader? How to reproduce 
>> the problem? I can take a quick look.
>
> Great. Add that line to 
> databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer:
> org.apache.tuscany.sca.databinding.javabeans.JavaBean2XMLStreamReader;source=java:complexType,target=javax.xml.stream.XMLStreamReader,weight=79000
>
> Build the databinding module. You should get the exception at the bottom 
> of that email.
>
> Thanks.
>
>>
>> Thanks,
>> Raymond
>>
>> ----- Original Message ----- From: "Jean-Sebastien Delfino" 
>> <js...@apache.org>
>> To: <tu...@ws.apache.org>
>> Sent: Monday, November 12, 2007 12:05 PM
>> Subject: Re: DataBinding issues - ClassCastException
>>
>>
>>> Jean-Sebastien Delfino wrote:
>>>> Jean-Sebastien Delfino wrote:
>>>>> I'm trying to add some support for business objects to the Tutorial 
>>>>> (instead of just flowing the catalog and cart items as strings).
>>>>>
>>>>> My business objects are simple JavaBeans with an empty constructor. I 
>>>>> need to flow them as Java objects through local service calls, XML (in 
>>>>> Atom payloads) and JSON.
>>>>>
>>>>> It should have been a simple exercise, but I've been running into a 
>>>>> number of issues with the DataBinding framework. Here they are:
>>>>>
>>>>> 1. Some of the Bean2* and *2Bean transformers were missing to 
>>>>> META-INF/services I added them.
>>>>>
>>>>> 2. The Databinding framework was not finding the transformers in XML 
>>>>> <-> registrations. I changed all instances of java.lang.String to 
>>>>> xml.string in the registrations of the *2String and String2* 
>>>>> transformer to fix that.
>>>>>
>>>>> 3. Next I ran into a ClassCastException in XML2JavaBeanTransformer at
>>>>> public Object transform(T source, TransformationContext context) {
>>>>> - ->       XMLType xmlType = (XMLType) 
>>>>> context.getSourceDataType().getLogical();
>>>>> as the logical type was Class instead of XMLType
>>>>>
>>>>> 4. I had to add "implements Serializable" to my business object class 
>>>>> as it looks like we are using Java serialization to enforce pass by 
>>>>> value in local service calls. I don't think it's right as we are not 
>>>>> using Java serialization to pass the same business object through a 
>>>>> remote call. We should change to use the same XML transformation to 
>>>>> enforce pass by value with local calls as well, and not require the 
>>>>> business objects to be Serializable.
>>>>>
>>>>> 5. After changes (1), (2), (3) and (4) I am now running into a build 
>>>>> issue:
>>>>> testTransform1(org.apache.tuscany.sca.databinding.impl.MediatorImplTestCase) 
>>>>> Time elapsed: 0.02 sec  <<< ERROR!
>>>>> java.lang.ClassCastException: 
>>>>> org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer 
>>>>> cannot be cast to 
>>>>> org.apache.tuscany.sca.databinding.DataPipeTransformer
>>>>>        at 
>>>>> org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:75)
>>>>>        at 
>>>>> org.apache.tuscany.sca.databinding.impl.MediatorImplTestCase.testTransform1(MediatorImplTestCase.java:104)
>>>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>        at 
>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>>>        at 
>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>>>        at junit.framework.TestCase.runTest(TestCase.java:168)
>>>>>        at junit.framework.TestCase.runBare(TestCase.java:134)
>>>>>        at junit.framework.TestResult$1.protect(TestResult.java:110)
>>>>>        at junit.framework.TestResult.runProtected(TestResult.java:128)
>>>>>        at junit.framework.TestResult.run(TestResult.java:113)
>>>>>        at junit.framework.TestCase.run(TestCase.java:124)
>>>>>        at junit.framework.TestSuite.runTest(TestSuite.java:232)
>>>>>        at junit.framework.TestSuite.run(TestSuite.java:227)
>>>>>        at 
>>>>> org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
>>>>>        at 
>>>>> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
>>>>>        at 
>>>>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
>>>>>        at 
>>>>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
>>>>>        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
>>>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>        at 
>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>>>        at 
>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>>>        at 
>>>>> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:299)
>>>>>        at 
>>>>> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:837)
>>>>>
>>>>> I'm getting to the end of the rope here... does anyone know what can 
>>>>> cause error (5)?
>>>>>
>>>>> Thanks
>>>>>
>>>>
>>>> A little more info:
>>>>
>>>> The ClassCastException is on:
>>>>            } else if (transformer instanceof PushTransformer) {
>>>>                DataPipeTransformer dataPipeFactory = (i < size - 1) ? 
>>>> (DataPipeTransformer)path.get(++i) : null;
>>>>
>>>> path =
>>>> [org.apache.tuscany.sca.databinding.xml.String2SAX@15a6029,
>>>> org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer@5f6303;className=org.apache.tuscany.sca.databinding.xml.SAX2DOMPipe]
>>>>
>>>> sourceDataType = class java.lang.String java.lang.String class 
>>>> java.lang.String
>>>> targetDataType = interface org.w3c.dom.Node org.w3c.dom.Node interface 
>>>> org.w3c.dom.Node
>>>>
>>>
>>> Next stop on the road to databinding happiness:  Revert changes (2) as 
>>> registering the transformers with xml.string seems to confuse all the 
>>> code that uses java.lang.String instead of xml.string as databinding 
>>> name or id.
>>>
>>> I then get the following exception:
>>> Running 
>>> org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldNoWSDLTestCase
>>> info: Added Servlet mapping: 
>>> http://delfinoj60.burlingame.ibm.com:8085/helloWorld
>>> info: Added Servlet mapping: 
>>> http://delfinoj60.burlingame.ibm.com:8085/Echo
>>> info: Added Servlet mapping: 
>>> http://delfinoj60.burlingame.ibm.com:8085/helloWorld
>>> info: Added Servlet mapping: 
>>> http://delfinoj60.burlingame.ibm.com:8085/Echo
>>> severe: 
>>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
>>> java.lang.NullPointerException <bars>  in <class 
>>> org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
>>> org.osoa.sca.ServiceRuntimeException: 
>>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
>>> java.lang.NullPointerException <bars>  in <class 
>>> org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
>>>        at 
>>> org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:127)
>>>        at 
>>> org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:89)
>>>        at 
>>> org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:83)
>>>        at 
>>> org.apache.tuscany.sca.core.assembly.RuntimeWireImpl.invoke(RuntimeWireImpl.java:127)
>>>        at 
>>> org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceProvider.invokeTarget(Axis2ServiceProvider.java:567)
>>>        at 
>>> org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceInOutSyncMessageReceiver.invokeBusinessLogic(Axis2ServiceInOutSyncMessageReceiver.java:59)
>>>        at 
>>> org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:42)
>>>        at 
>>> org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:96)
>>>        at 
>>> org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
>>>        at 
>>> org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
>>>        at 
>>> org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120)
>>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>>        at 
>>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
>>>        at 
>>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367)
>>>        at 
>>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>>        at 
>>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
>>>        at 
>>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>>>        at org.mortbay.jetty.Server.handle(Server.java:285)
>>>        at 
>>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:502)
>>>        at 
>>> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:835)
>>>        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:641)
>>>        at 
>>> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:208)
>>>        at 
>>> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:378)
>>>        at 
>>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:368)
>>>        at 
>>> org.apache.tuscany.sca.core.work.Jsr237Work.run(Jsr237Work.java:61)
>>>        at 
>>> org.apache.tuscany.sca.core.work.ThreadPoolWorkManager$DecoratingWork.run(ThreadPoolWorkManager.java:205)
>>>        at 
>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
>>>        at 
>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
>>>        at java.lang.Thread.run(Thread.java:619)
>>> Caused by: 
>>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
>>> java.lang.NullPointerException <bars>  in <class 
>>> org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
>>>        at 
>>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.createJavaObject(XML2JavaBeanTransformer.java:110)
>>>        at 
>>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.toJavaObject(XML2JavaBeanTransformer.java:67)
>>>        at 
>>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.transform(XML2JavaBeanTransformer.java:59)
>>>        at 
>>> org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer.transform(DefaultTransformerExtensionPoint.java:194)
>>>        at 
>>> org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:73)
>>>        at 
>>> org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformer.transform(Input2InputTransformer.java:177)
>>>        at 
>>> org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformer.transform(Input2InputTransformer.java:43)
>>>        at 
>>> org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:73)
>>>        at 
>>> org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.transform(DataTransformationInterceptor.java:175)
>>>        at 
>>> org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:72)
>>>        at 
>>> org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:118)
>>>        ... 29 more
>>> Caused by: java.lang.NullPointerException
>>>        at 
>>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.createJavaObject(XML2JavaBeanTransformer.java:76)
>>>        at 
>>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.setFieldValueUsingSetter(XML2JavaBeanTransformer.java:164)
>>>        at 
>>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.createJavaObject(XML2JavaBeanTransformer.java:97)
>>>        ... 39 more
>>> Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 15.143 
>>> sec <<< FAILURE!
>>> testEchoFoo(org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldNoWSDLTestCase) 
>>> Time elapsed: 1.218 sec  <<< ERROR!
>>> java.lang.reflect.UndeclaredThrowableException
>>>        at $Proxy7.echoFoo(Unknown Source)
>>>        at 
>>> org.apache.tuscany.sca.binding.ws.axis2.itests.EchoComponent.echoFoo(EchoComponent.java:30)
>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>        at 
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>        at 
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>        at 
>>> org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke(JavaImplementationInvoker.java:105)
>>>        at 
>>> org.apache.tuscany.sca.core.databinding.wire.PassByValueInterceptor.invoke(PassByValueInterceptor.java:49)
>>>        at 
>>> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:233)
>>>        at 
>>> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:130)
>>>        at $Proxy7.echoFoo(Unknown Source)
>>>        at 
>>> org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldNoWSDLTestCase.testEchoFoo(HelloWorldNoWSDLTestCase.java:54)
>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>        at 
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>        at 
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>        at junit.framework.TestCase.runTest(TestCase.java:168)
>>>        at junit.framework.TestCase.runBare(TestCase.java:134)
>>>        at junit.framework.TestResult$1.protect(TestResult.java:110)
>>>        at junit.framework.TestResult.runProtected(TestResult.java:128)
>>>        at junit.framework.TestResult.run(TestResult.java:113)
>>>        at junit.framework.TestCase.run(TestCase.java:124)
>>>        at junit.framework.TestSuite.runTest(TestSuite.java:232)
>>>        at junit.framework.TestSuite.run(TestSuite.java:227)
>>>        at 
>>> org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
>>>        at 
>>> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
>>>        at 
>>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
>>>        at 
>>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
>>>        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>        at 
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>        at 
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>        at 
>>> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:299)
>>>        at 
>>> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:837)
>>> Caused by: org.apache.tuscany.sca.interfacedef.util.FaultException: 
>>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
>>> java.lang.NullPointerException <bars>  in <class 
>>> org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
>>>        at 
>>> org.apache.tuscany.sca.binding.ws.axis2.Axis2BindingInvoker.invoke(Axis2BindingInvoker.java:79)
>>>        at 
>>> org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:74)
>>>        at 
>>> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:233)
>>>        at 
>>> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:130)
>>>        ... 35 more
>>>
>>> caused by that line in 
>>> databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer:
>>> org.apache.tuscany.sca.databinding.javabeans.JavaBean2XMLStreamReader;source=java:complexType,target=javax.xml.stream.XMLStreamReader,weight=79000
>>>
>>> I had added that line to use JavaBean2XMLStreamReader instead of 
>>> JavaBean2DOMNodeTransformer, as going through a DOM is not the most 
>>> optimized path from a JavaBean to XML :) but it looks like 
>>> JavaBean2XMLStreamReader does not work as well as 
>>> JavaBean2DOMNodeTransformer... After removing it the build is successful 
>>> again.
>>>
>>> -- 
>>> Jean-Sebastien
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>>
>>
>
>
> -- 
> Jean-Sebastien
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: DataBinding issues - ClassCastException

Posted by Jean-Sebastien Delfino <js...@apache.org>.
Raymond Feng wrote:
> What problem did you see with JavaBean2XMLStreamReader? How to 
> reproduce the problem? I can take a quick look.

Great. Add that line to 
databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer: 

org.apache.tuscany.sca.databinding.javabeans.JavaBean2XMLStreamReader;source=java:complexType,target=javax.xml.stream.XMLStreamReader,weight=79000 


Build the databinding module. You should get the exception at the bottom 
of that email.

Thanks.

>
> Thanks,
> Raymond
>
> ----- Original Message ----- From: "Jean-Sebastien Delfino" 
> <js...@apache.org>
> To: <tu...@ws.apache.org>
> Sent: Monday, November 12, 2007 12:05 PM
> Subject: Re: DataBinding issues - ClassCastException
>
>
>> Jean-Sebastien Delfino wrote:
>>> Jean-Sebastien Delfino wrote:
>>>> I'm trying to add some support for business objects to the Tutorial 
>>>> (instead of just flowing the catalog and cart items as strings).
>>>>
>>>> My business objects are simple JavaBeans with an empty constructor. 
>>>> I need to flow them as Java objects through local service calls, 
>>>> XML (in Atom payloads) and JSON.
>>>>
>>>> It should have been a simple exercise, but I've been running into a 
>>>> number of issues with the DataBinding framework. Here they are:
>>>>
>>>> 1. Some of the Bean2* and *2Bean transformers were missing to 
>>>> META-INF/services I added them.
>>>>
>>>> 2. The Databinding framework was not finding the transformers in 
>>>> XML <-> registrations. I changed all instances of java.lang.String 
>>>> to xml.string in the registrations of the *2String and String2* 
>>>> transformer to fix that.
>>>>
>>>> 3. Next I ran into a ClassCastException in XML2JavaBeanTransformer at
>>>> public Object transform(T source, TransformationContext context) {
>>>> - ->       XMLType xmlType = (XMLType) 
>>>> context.getSourceDataType().getLogical();
>>>> as the logical type was Class instead of XMLType
>>>>
>>>> 4. I had to add "implements Serializable" to my business object 
>>>> class as it looks like we are using Java serialization to enforce 
>>>> pass by value in local service calls. I don't think it's right as 
>>>> we are not using Java serialization to pass the same business 
>>>> object through a remote call. We should change to use the same XML 
>>>> transformation to enforce pass by value with local calls as well, 
>>>> and not require the business objects to be Serializable.
>>>>
>>>> 5. After changes (1), (2), (3) and (4) I am now running into a 
>>>> build issue:
>>>> testTransform1(org.apache.tuscany.sca.databinding.impl.MediatorImplTestCase) 
>>>> Time elapsed: 0.02 sec  <<< ERROR!
>>>> java.lang.ClassCastException: 
>>>> org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer 
>>>> cannot be cast to 
>>>> org.apache.tuscany.sca.databinding.DataPipeTransformer
>>>>        at 
>>>> org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:75) 
>>>>
>>>>        at 
>>>> org.apache.tuscany.sca.databinding.impl.MediatorImplTestCase.testTransform1(MediatorImplTestCase.java:104) 
>>>>
>>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>        at 
>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
>>>>
>>>>        at 
>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
>>>>
>>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>>        at junit.framework.TestCase.runTest(TestCase.java:168)
>>>>        at junit.framework.TestCase.runBare(TestCase.java:134)
>>>>        at junit.framework.TestResult$1.protect(TestResult.java:110)
>>>>        at junit.framework.TestResult.runProtected(TestResult.java:128)
>>>>        at junit.framework.TestResult.run(TestResult.java:113)
>>>>        at junit.framework.TestCase.run(TestCase.java:124)
>>>>        at junit.framework.TestSuite.runTest(TestSuite.java:232)
>>>>        at junit.framework.TestSuite.run(TestSuite.java:227)
>>>>        at 
>>>> org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35) 
>>>>
>>>>        at 
>>>> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) 
>>>>
>>>>        at 
>>>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138) 
>>>>
>>>>        at 
>>>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125) 
>>>>
>>>>        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
>>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>        at 
>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
>>>>
>>>>        at 
>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
>>>>
>>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>>        at 
>>>> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:299) 
>>>>
>>>>        at 
>>>> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:837) 
>>>>
>>>>
>>>> I'm getting to the end of the rope here... does anyone know what 
>>>> can cause error (5)?
>>>>
>>>> Thanks
>>>>
>>>
>>> A little more info:
>>>
>>> The ClassCastException is on:
>>>            } else if (transformer instanceof PushTransformer) {
>>>                DataPipeTransformer dataPipeFactory = (i < size - 1) 
>>> ? (DataPipeTransformer)path.get(++i) : null;
>>>
>>> path =
>>> [org.apache.tuscany.sca.databinding.xml.String2SAX@15a6029,
>>> org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer@5f6303;className=org.apache.tuscany.sca.databinding.xml.SAX2DOMPipe] 
>>>
>>>
>>> sourceDataType = class java.lang.String java.lang.String class 
>>> java.lang.String
>>> targetDataType = interface org.w3c.dom.Node org.w3c.dom.Node 
>>> interface org.w3c.dom.Node
>>>
>>
>> Next stop on the road to databinding happiness:  Revert changes (2) 
>> as registering the transformers with xml.string seems to confuse all 
>> the code that uses java.lang.String instead of xml.string as 
>> databinding name or id.
>>
>> I then get the following exception:
>> Running 
>> org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldNoWSDLTestCase
>> info: Added Servlet mapping: 
>> http://delfinoj60.burlingame.ibm.com:8085/helloWorld
>> info: Added Servlet mapping: 
>> http://delfinoj60.burlingame.ibm.com:8085/Echo
>> info: Added Servlet mapping: 
>> http://delfinoj60.burlingame.ibm.com:8085/helloWorld
>> info: Added Servlet mapping: 
>> http://delfinoj60.burlingame.ibm.com:8085/Echo
>> severe: 
>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
>> java.lang.NullPointerException <bars>  in <class 
>> org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
>> org.osoa.sca.ServiceRuntimeException: 
>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
>> java.lang.NullPointerException <bars>  in <class 
>> org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
>>        at 
>> org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:127) 
>>
>>        at 
>> org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:89) 
>>
>>        at 
>> org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:83) 
>>
>>        at 
>> org.apache.tuscany.sca.core.assembly.RuntimeWireImpl.invoke(RuntimeWireImpl.java:127) 
>>
>>        at 
>> org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceProvider.invokeTarget(Axis2ServiceProvider.java:567) 
>>
>>        at 
>> org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceInOutSyncMessageReceiver.invokeBusinessLogic(Axis2ServiceInOutSyncMessageReceiver.java:59) 
>>
>>        at 
>> org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:42) 
>>
>>        at 
>> org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:96) 
>>
>>        at 
>> org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
>>        at 
>> org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275) 
>>
>>        at 
>> org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120)
>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>        at 
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
>>        at 
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367)
>>        at 
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>>        at 
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
>>        at 
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>>        at org.mortbay.jetty.Server.handle(Server.java:285)
>>        at 
>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:502)
>>        at 
>> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:835) 
>>
>>        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:641)
>>        at 
>> org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:208)
>>        at 
>> org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:378)
>>        at 
>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:368) 
>>
>>        at 
>> org.apache.tuscany.sca.core.work.Jsr237Work.run(Jsr237Work.java:61)
>>        at 
>> org.apache.tuscany.sca.core.work.ThreadPoolWorkManager$DecoratingWork.run(ThreadPoolWorkManager.java:205) 
>>
>>        at 
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) 
>>
>>        at 
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) 
>>
>>        at java.lang.Thread.run(Thread.java:619)
>> Caused by: 
>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
>> java.lang.NullPointerException <bars>  in <class 
>> org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
>>        at 
>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.createJavaObject(XML2JavaBeanTransformer.java:110) 
>>
>>        at 
>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.toJavaObject(XML2JavaBeanTransformer.java:67) 
>>
>>        at 
>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.transform(XML2JavaBeanTransformer.java:59) 
>>
>>        at 
>> org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer.transform(DefaultTransformerExtensionPoint.java:194) 
>>
>>        at 
>> org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:73) 
>>
>>        at 
>> org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformer.transform(Input2InputTransformer.java:177) 
>>
>>        at 
>> org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformer.transform(Input2InputTransformer.java:43) 
>>
>>        at 
>> org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:73) 
>>
>>        at 
>> org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.transform(DataTransformationInterceptor.java:175) 
>>
>>        at 
>> org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:72) 
>>
>>        at 
>> org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:118) 
>>
>>        ... 29 more
>> Caused by: java.lang.NullPointerException
>>        at 
>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.createJavaObject(XML2JavaBeanTransformer.java:76) 
>>
>>        at 
>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.setFieldValueUsingSetter(XML2JavaBeanTransformer.java:164) 
>>
>>        at 
>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.createJavaObject(XML2JavaBeanTransformer.java:97) 
>>
>>        ... 39 more
>> Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 
>> 15.143 sec <<< FAILURE!
>> testEchoFoo(org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldNoWSDLTestCase) 
>> Time elapsed: 1.218 sec  <<< ERROR!
>> java.lang.reflect.UndeclaredThrowableException
>>        at $Proxy7.echoFoo(Unknown Source)
>>        at 
>> org.apache.tuscany.sca.binding.ws.axis2.itests.EchoComponent.echoFoo(EchoComponent.java:30) 
>>
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at 
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
>>
>>        at 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
>>
>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>        at 
>> org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke(JavaImplementationInvoker.java:105) 
>>
>>        at 
>> org.apache.tuscany.sca.core.databinding.wire.PassByValueInterceptor.invoke(PassByValueInterceptor.java:49) 
>>
>>        at 
>> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:233) 
>>
>>        at 
>> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:130) 
>>
>>        at $Proxy7.echoFoo(Unknown Source)
>>        at 
>> org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldNoWSDLTestCase.testEchoFoo(HelloWorldNoWSDLTestCase.java:54) 
>>
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at 
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
>>
>>        at 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
>>
>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>        at junit.framework.TestCase.runTest(TestCase.java:168)
>>        at junit.framework.TestCase.runBare(TestCase.java:134)
>>        at junit.framework.TestResult$1.protect(TestResult.java:110)
>>        at junit.framework.TestResult.runProtected(TestResult.java:128)
>>        at junit.framework.TestResult.run(TestResult.java:113)
>>        at junit.framework.TestCase.run(TestCase.java:124)
>>        at junit.framework.TestSuite.runTest(TestSuite.java:232)
>>        at junit.framework.TestSuite.run(TestSuite.java:227)
>>        at 
>> org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35) 
>>
>>        at 
>> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) 
>>
>>        at 
>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138) 
>>
>>        at 
>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125) 
>>
>>        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at 
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
>>
>>        at 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
>>
>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>        at 
>> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:299) 
>>
>>        at 
>> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:837) 
>>
>> Caused by: org.apache.tuscany.sca.interfacedef.util.FaultException: 
>> org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
>> java.lang.NullPointerException <bars>  in <class 
>> org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
>>        at 
>> org.apache.tuscany.sca.binding.ws.axis2.Axis2BindingInvoker.invoke(Axis2BindingInvoker.java:79) 
>>
>>        at 
>> org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:74) 
>>
>>        at 
>> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:233) 
>>
>>        at 
>> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:130) 
>>
>>        ... 35 more
>>
>> caused by that line in 
>> databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer: 
>>
>> org.apache.tuscany.sca.databinding.javabeans.JavaBean2XMLStreamReader;source=java:complexType,target=javax.xml.stream.XMLStreamReader,weight=79000 
>>
>>
>> I had added that line to use JavaBean2XMLStreamReader instead of 
>> JavaBean2DOMNodeTransformer, as going through a DOM is not the most 
>> optimized path from a JavaBean to XML :) but it looks like 
>> JavaBean2XMLStreamReader does not work as well as 
>> JavaBean2DOMNodeTransformer... After removing it the build is 
>> successful again.
>>
>> -- 
>> Jean-Sebastien
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
>
>


-- 
Jean-Sebastien


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: DataBinding issues - ClassCastException

Posted by Raymond Feng <en...@gmail.com>.
What problem did you see with JavaBean2XMLStreamReader? How to reproduce the 
problem? I can take a quick look.

Thanks,
Raymond

----- Original Message ----- 
From: "Jean-Sebastien Delfino" <js...@apache.org>
To: <tu...@ws.apache.org>
Sent: Monday, November 12, 2007 12:05 PM
Subject: Re: DataBinding issues - ClassCastException


> Jean-Sebastien Delfino wrote:
>> Jean-Sebastien Delfino wrote:
>>> I'm trying to add some support for business objects to the Tutorial 
>>> (instead of just flowing the catalog and cart items as strings).
>>>
>>> My business objects are simple JavaBeans with an empty constructor. I 
>>> need to flow them as Java objects through local service calls, XML (in 
>>> Atom payloads) and JSON.
>>>
>>> It should have been a simple exercise, but I've been running into a 
>>> number of issues with the DataBinding framework. Here they are:
>>>
>>> 1. Some of the Bean2* and *2Bean transformers were missing to 
>>> META-INF/services I added them.
>>>
>>> 2. The Databinding framework was not finding the transformers in XML <-> 
>>> registrations. I changed all instances of java.lang.String to xml.string 
>>> in the registrations of the *2String and String2* transformer to fix 
>>> that.
>>>
>>> 3. Next I ran into a ClassCastException in XML2JavaBeanTransformer at
>>> public Object transform(T source, TransformationContext context) {
>>> - ->       XMLType xmlType = (XMLType) 
>>> context.getSourceDataType().getLogical();
>>> as the logical type was Class instead of XMLType
>>>
>>> 4. I had to add "implements Serializable" to my business object class as 
>>> it looks like we are using Java serialization to enforce pass by value 
>>> in local service calls. I don't think it's right as we are not using 
>>> Java serialization to pass the same business object through a remote 
>>> call. We should change to use the same XML transformation to enforce 
>>> pass by value with local calls as well, and not require the business 
>>> objects to be Serializable.
>>>
>>> 5. After changes (1), (2), (3) and (4) I am now running into a build 
>>> issue:
>>> testTransform1(org.apache.tuscany.sca.databinding.impl.MediatorImplTestCase) 
>>> Time elapsed: 0.02 sec  <<< ERROR!
>>> java.lang.ClassCastException: 
>>> org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer 
>>> cannot be cast to org.apache.tuscany.sca.databinding.DataPipeTransformer
>>>        at 
>>> org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:75)
>>>        at 
>>> org.apache.tuscany.sca.databinding.impl.MediatorImplTestCase.testTransform1(MediatorImplTestCase.java:104)
>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>        at 
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>        at 
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>        at junit.framework.TestCase.runTest(TestCase.java:168)
>>>        at junit.framework.TestCase.runBare(TestCase.java:134)
>>>        at junit.framework.TestResult$1.protect(TestResult.java:110)
>>>        at junit.framework.TestResult.runProtected(TestResult.java:128)
>>>        at junit.framework.TestResult.run(TestResult.java:113)
>>>        at junit.framework.TestCase.run(TestCase.java:124)
>>>        at junit.framework.TestSuite.runTest(TestSuite.java:232)
>>>        at junit.framework.TestSuite.run(TestSuite.java:227)
>>>        at 
>>> org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
>>>        at 
>>> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
>>>        at 
>>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
>>>        at 
>>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
>>>        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
>>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>        at 
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>>        at 
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>>        at 
>>> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:299)
>>>        at 
>>> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:837)
>>>
>>> I'm getting to the end of the rope here... does anyone know what can 
>>> cause error (5)?
>>>
>>> Thanks
>>>
>>
>> A little more info:
>>
>> The ClassCastException is on:
>>            } else if (transformer instanceof PushTransformer) {
>>                DataPipeTransformer dataPipeFactory = (i < size - 1) ? 
>> (DataPipeTransformer)path.get(++i) : null;
>>
>> path =
>> [org.apache.tuscany.sca.databinding.xml.String2SAX@15a6029,
>> org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer@5f6303;className=org.apache.tuscany.sca.databinding.xml.SAX2DOMPipe]
>>
>> sourceDataType = class java.lang.String java.lang.String class 
>> java.lang.String
>> targetDataType = interface org.w3c.dom.Node org.w3c.dom.Node interface 
>> org.w3c.dom.Node
>>
>
> Next stop on the road to databinding happiness:  Revert changes (2) as 
> registering the transformers with xml.string seems to confuse all the code 
> that uses java.lang.String instead of xml.string as databinding name or 
> id.
>
> I then get the following exception:
> Running 
> org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldNoWSDLTestCase
> info: Added Servlet mapping: 
> http://delfinoj60.burlingame.ibm.com:8085/helloWorld
> info: Added Servlet mapping: 
> http://delfinoj60.burlingame.ibm.com:8085/Echo
> info: Added Servlet mapping: 
> http://delfinoj60.burlingame.ibm.com:8085/helloWorld
> info: Added Servlet mapping: 
> http://delfinoj60.burlingame.ibm.com:8085/Echo
> severe: 
> org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
> java.lang.NullPointerException <bars>  in <class 
> org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
> org.osoa.sca.ServiceRuntimeException: 
> org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
> java.lang.NullPointerException <bars>  in <class 
> org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
>        at 
> org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:127)
>        at 
> org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:89)
>        at 
> org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:83)
>        at 
> org.apache.tuscany.sca.core.assembly.RuntimeWireImpl.invoke(RuntimeWireImpl.java:127)
>        at 
> org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceProvider.invokeTarget(Axis2ServiceProvider.java:567)
>        at 
> org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceInOutSyncMessageReceiver.invokeBusinessLogic(Axis2ServiceInOutSyncMessageReceiver.java:59)
>        at 
> org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:42)
>        at 
> org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:96)
>        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
>        at 
> org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
>        at 
> org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>        at 
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
>        at 
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367)
>        at 
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
>        at 
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
>        at 
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
>        at org.mortbay.jetty.Server.handle(Server.java:285)
>        at 
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:502)
>        at 
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:835)
>        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:641)
>        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:208)
>        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:378)
>        at 
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:368)
>        at 
> org.apache.tuscany.sca.core.work.Jsr237Work.run(Jsr237Work.java:61)
>        at 
> org.apache.tuscany.sca.core.work.ThreadPoolWorkManager$DecoratingWork.run(ThreadPoolWorkManager.java:205)
>        at 
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
>        at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
>        at java.lang.Thread.run(Thread.java:619)
> Caused by: 
> org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
> java.lang.NullPointerException <bars>  in <class 
> org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
>        at 
> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.createJavaObject(XML2JavaBeanTransformer.java:110)
>        at 
> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.toJavaObject(XML2JavaBeanTransformer.java:67)
>        at 
> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.transform(XML2JavaBeanTransformer.java:59)
>        at 
> org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer.transform(DefaultTransformerExtensionPoint.java:194)
>        at 
> org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:73)
>        at 
> org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformer.transform(Input2InputTransformer.java:177)
>        at 
> org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformer.transform(Input2InputTransformer.java:43)
>        at 
> org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:73)
>        at 
> org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.transform(DataTransformationInterceptor.java:175)
>        at 
> org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:72)
>        at 
> org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:118)
>        ... 29 more
> Caused by: java.lang.NullPointerException
>        at 
> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.createJavaObject(XML2JavaBeanTransformer.java:76)
>        at 
> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.setFieldValueUsingSetter(XML2JavaBeanTransformer.java:164)
>        at 
> org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.createJavaObject(XML2JavaBeanTransformer.java:97)
>        ... 39 more
> Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 15.143 sec 
> <<< FAILURE!
> testEchoFoo(org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldNoWSDLTestCase) 
> Time elapsed: 1.218 sec  <<< ERROR!
> java.lang.reflect.UndeclaredThrowableException
>        at $Proxy7.echoFoo(Unknown Source)
>        at 
> org.apache.tuscany.sca.binding.ws.axis2.itests.EchoComponent.echoFoo(EchoComponent.java:30)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at 
> org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke(JavaImplementationInvoker.java:105)
>        at 
> org.apache.tuscany.sca.core.databinding.wire.PassByValueInterceptor.invoke(PassByValueInterceptor.java:49)
>        at 
> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:233)
>        at 
> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:130)
>        at $Proxy7.echoFoo(Unknown Source)
>        at 
> org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldNoWSDLTestCase.testEchoFoo(HelloWorldNoWSDLTestCase.java:54)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at junit.framework.TestCase.runTest(TestCase.java:168)
>        at junit.framework.TestCase.runBare(TestCase.java:134)
>        at junit.framework.TestResult$1.protect(TestResult.java:110)
>        at junit.framework.TestResult.runProtected(TestResult.java:128)
>        at junit.framework.TestResult.run(TestResult.java:113)
>        at junit.framework.TestCase.run(TestCase.java:124)
>        at junit.framework.TestSuite.runTest(TestSuite.java:232)
>        at junit.framework.TestSuite.run(TestSuite.java:227)
>        at 
> org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
>        at 
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
>        at 
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
>        at 
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
>        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at 
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:299)
>        at 
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:837)
> Caused by: org.apache.tuscany.sca.interfacedef.util.FaultException: 
> org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
> java.lang.NullPointerException <bars>  in <class 
> org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
>        at 
> org.apache.tuscany.sca.binding.ws.axis2.Axis2BindingInvoker.invoke(Axis2BindingInvoker.java:79)
>        at 
> org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:74)
>        at 
> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:233)
>        at 
> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:130)
>        ... 35 more
>
> caused by that line in 
> databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer:
> org.apache.tuscany.sca.databinding.javabeans.JavaBean2XMLStreamReader;source=java:complexType,target=javax.xml.stream.XMLStreamReader,weight=79000
>
> I had added that line to use JavaBean2XMLStreamReader instead of 
> JavaBean2DOMNodeTransformer, as going through a DOM is not the most 
> optimized path from a JavaBean to XML :) but it looks like 
> JavaBean2XMLStreamReader does not work as well as 
> JavaBean2DOMNodeTransformer... After removing it the build is successful 
> again.
>
> -- 
> Jean-Sebastien
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-dev-help@ws.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: DataBinding issues - ClassCastException

Posted by Jean-Sebastien Delfino <js...@apache.org>.
Jean-Sebastien Delfino wrote:
> Jean-Sebastien Delfino wrote:
>> I'm trying to add some support for business objects to the Tutorial 
>> (instead of just flowing the catalog and cart items as strings).
>>
>> My business objects are simple JavaBeans with an empty constructor. I 
>> need to flow them as Java objects through local service calls, XML 
>> (in Atom payloads) and JSON.
>>
>> It should have been a simple exercise, but I've been running into a 
>> number of issues with the DataBinding framework. Here they are:
>>
>> 1. Some of the Bean2* and *2Bean transformers were missing to 
>> META-INF/services I added them.
>>
>> 2. The Databinding framework was not finding the transformers in XML 
>> <-> registrations. I changed all instances of java.lang.String to 
>> xml.string in the registrations of the *2String and String2* 
>> transformer to fix that.
>>
>> 3. Next I ran into a ClassCastException in XML2JavaBeanTransformer at
>> public Object transform(T source, TransformationContext context) {
>> - ->       XMLType xmlType = (XMLType) 
>> context.getSourceDataType().getLogical();
>> as the logical type was Class instead of XMLType
>>
>> 4. I had to add "implements Serializable" to my business object class 
>> as it looks like we are using Java serialization to enforce pass by 
>> value in local service calls. I don't think it's right as we are not 
>> using Java serialization to pass the same business object through a 
>> remote call. We should change to use the same XML transformation to 
>> enforce pass by value with local calls as well, and not require the 
>> business objects to be Serializable.
>>
>> 5. After changes (1), (2), (3) and (4) I am now running into a build 
>> issue:
>> testTransform1(org.apache.tuscany.sca.databinding.impl.MediatorImplTestCase)  
>> Time elapsed: 0.02 sec  <<< ERROR!
>> java.lang.ClassCastException: 
>> org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer 
>> cannot be cast to org.apache.tuscany.sca.databinding.DataPipeTransformer
>>        at 
>> org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:75) 
>>
>>        at 
>> org.apache.tuscany.sca.databinding.impl.MediatorImplTestCase.testTransform1(MediatorImplTestCase.java:104) 
>>
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at 
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
>>
>>        at 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
>>
>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>        at junit.framework.TestCase.runTest(TestCase.java:168)
>>        at junit.framework.TestCase.runBare(TestCase.java:134)
>>        at junit.framework.TestResult$1.protect(TestResult.java:110)
>>        at junit.framework.TestResult.runProtected(TestResult.java:128)
>>        at junit.framework.TestResult.run(TestResult.java:113)
>>        at junit.framework.TestCase.run(TestCase.java:124)
>>        at junit.framework.TestSuite.runTest(TestSuite.java:232)
>>        at junit.framework.TestSuite.run(TestSuite.java:227)
>>        at 
>> org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35) 
>>
>>        at 
>> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) 
>>
>>        at 
>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138) 
>>
>>        at 
>> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125) 
>>
>>        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
>>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>        at 
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
>>
>>        at 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
>>
>>        at java.lang.reflect.Method.invoke(Method.java:597)
>>        at 
>> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:299) 
>>
>>        at 
>> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:837) 
>>
>>
>> I'm getting to the end of the rope here... does anyone know what can 
>> cause error (5)?
>>
>> Thanks
>>
>
> A little more info:
>
> The ClassCastException is on:
>            } else if (transformer instanceof PushTransformer) {
>                DataPipeTransformer dataPipeFactory = (i < size - 1) ? 
> (DataPipeTransformer)path.get(++i) : null;
>
> path =
> [org.apache.tuscany.sca.databinding.xml.String2SAX@15a6029,
> org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer@5f6303;className=org.apache.tuscany.sca.databinding.xml.SAX2DOMPipe] 
>
>
> sourceDataType = class java.lang.String java.lang.String class 
> java.lang.String
> targetDataType = interface org.w3c.dom.Node org.w3c.dom.Node interface 
> org.w3c.dom.Node
>

Next stop on the road to databinding happiness:  Revert changes (2) as 
registering the transformers with xml.string seems to confuse all the 
code that uses java.lang.String instead of xml.string as databinding 
name or id.

I then get the following exception:
Running 
org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldNoWSDLTestCase
info: Added Servlet mapping: 
http://delfinoj60.burlingame.ibm.com:8085/helloWorld
info: Added Servlet mapping: http://delfinoj60.burlingame.ibm.com:8085/Echo
info: Added Servlet mapping: 
http://delfinoj60.burlingame.ibm.com:8085/helloWorld
info: Added Servlet mapping: http://delfinoj60.burlingame.ibm.com:8085/Echo
severe: 
org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
java.lang.NullPointerException <bars>  in <class 
org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
org.osoa.sca.ServiceRuntimeException: 
org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
java.lang.NullPointerException <bars>  in <class 
org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
        at 
org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:127)
        at 
org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:89)
        at 
org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:83)
        at 
org.apache.tuscany.sca.core.assembly.RuntimeWireImpl.invoke(RuntimeWireImpl.java:127)
        at 
org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceProvider.invokeTarget(Axis2ServiceProvider.java:567)
        at 
org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceInOutSyncMessageReceiver.invokeBusinessLogic(Axis2ServiceInOutSyncMessageReceiver.java:59)
        at 
org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:42)
        at 
org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:96)
        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145)
        at 
org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
        at 
org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        at 
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
        at 
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367)
        at 
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at 
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
        at 
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
        at org.mortbay.jetty.Server.handle(Server.java:285)
        at 
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:502)
        at 
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:835)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:641)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:208)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:378)
        at 
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:368)
        at 
org.apache.tuscany.sca.core.work.Jsr237Work.run(Jsr237Work.java:61)
        at 
org.apache.tuscany.sca.core.work.ThreadPoolWorkManager$DecoratingWork.run(ThreadPoolWorkManager.java:205)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
        at java.lang.Thread.run(Thread.java:619)
Caused by: 
org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
java.lang.NullPointerException <bars>  in <class 
org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
        at 
org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.createJavaObject(XML2JavaBeanTransformer.java:110)
        at 
org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.toJavaObject(XML2JavaBeanTransformer.java:67)
        at 
org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.transform(XML2JavaBeanTransformer.java:59)
        at 
org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer.transform(DefaultTransformerExtensionPoint.java:194)
        at 
org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:73)
        at 
org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformer.transform(Input2InputTransformer.java:177)
        at 
org.apache.tuscany.sca.core.databinding.transformers.Input2InputTransformer.transform(Input2InputTransformer.java:43)
        at 
org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:73)
        at 
org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.transform(DataTransformationInterceptor.java:175)
        at 
org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:72)
        at 
org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker.invoke(RuntimeWireInvoker.java:118)
        ... 29 more
Caused by: java.lang.NullPointerException
        at 
org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.createJavaObject(XML2JavaBeanTransformer.java:76)
        at 
org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.setFieldValueUsingSetter(XML2JavaBeanTransformer.java:164)
        at 
org.apache.tuscany.sca.databinding.javabeans.XML2JavaBeanTransformer.createJavaObject(XML2JavaBeanTransformer.java:97)
        ... 39 more
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 15.143 
sec <<< FAILURE!
testEchoFoo(org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldNoWSDLTestCase)  
Time elapsed: 1.218 sec  <<< ERROR!
java.lang.reflect.UndeclaredThrowableException
        at $Proxy7.echoFoo(Unknown Source)
        at 
org.apache.tuscany.sca.binding.ws.axis2.itests.EchoComponent.echoFoo(EchoComponent.java:30)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke(JavaImplementationInvoker.java:105)
        at 
org.apache.tuscany.sca.core.databinding.wire.PassByValueInterceptor.invoke(PassByValueInterceptor.java:49)
        at 
org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:233)
        at 
org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:130)
        at $Proxy7.echoFoo(Unknown Source)
        at 
org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldNoWSDLTestCase.testEchoFoo(HelloWorldNoWSDLTestCase.java:54)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at junit.framework.TestCase.runTest(TestCase.java:168)
        at junit.framework.TestCase.runBare(TestCase.java:134)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:124)
        at junit.framework.TestSuite.runTest(TestSuite.java:232)
        at junit.framework.TestSuite.run(TestSuite.java:227)
        at 
org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35)
        at 
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
        at 
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
        at 
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at 
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:299)
        at 
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:837)
Caused by: org.apache.tuscany.sca.interfacedef.util.FaultException: 
org.apache.tuscany.sca.databinding.javabeans.XML2JavaMapperException: 
java.lang.NullPointerException <bars>  in <class 
org.apache.tuscany.sca.binding.ws.axis2.itests.Foo>
        at 
org.apache.tuscany.sca.binding.ws.axis2.Axis2BindingInvoker.invoke(Axis2BindingInvoker.java:79)
        at 
org.apache.tuscany.sca.core.databinding.wire.DataTransformationInterceptor.invoke(DataTransformationInterceptor.java:74)
        at 
org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:233)
        at 
org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:130)
        ... 35 more

caused by that line in 
databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer:
org.apache.tuscany.sca.databinding.javabeans.JavaBean2XMLStreamReader;source=java:complexType,target=javax.xml.stream.XMLStreamReader,weight=79000

I had added that line to use JavaBean2XMLStreamReader instead of 
JavaBean2DOMNodeTransformer, as going through a DOM is not the most 
optimized path from a JavaBean to XML :) but it looks like 
JavaBean2XMLStreamReader does not work as well as 
JavaBean2DOMNodeTransformer... After removing it the build is successful 
again.

-- 
Jean-Sebastien


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org


Re: DataBinding issues - ClassCastException

Posted by Jean-Sebastien Delfino <js...@apache.org>.
Jean-Sebastien Delfino wrote:
> I'm trying to add some support for business objects to the Tutorial 
> (instead of just flowing the catalog and cart items as strings).
>
> My business objects are simple JavaBeans with an empty constructor. I 
> need to flow them as Java objects through local service calls, XML (in 
> Atom payloads) and JSON.
>
> It should have been a simple exercise, but I've been running into a 
> number of issues with the DataBinding framework. Here they are:
>
> 1. Some of the Bean2* and *2Bean transformers were missing to 
> META-INF/services I added them.
>
> 2. The Databinding framework was not finding the transformers in XML 
> <-> registrations. I changed all instances of java.lang.String to 
> xml.string in the registrations of the *2String and String2* 
> transformer to fix that.
>
> 3. Next I ran into a ClassCastException in XML2JavaBeanTransformer at
> public Object transform(T source, TransformationContext context) {
> - ->       XMLType xmlType = (XMLType) 
> context.getSourceDataType().getLogical();
> as the logical type was Class instead of XMLType
>
> 4. I had to add "implements Serializable" to my business object class 
> as it looks like we are using Java serialization to enforce pass by 
> value in local service calls. I don't think it's right as we are not 
> using Java serialization to pass the same business object through a 
> remote call. We should change to use the same XML transformation to 
> enforce pass by value with local calls as well, and not require the 
> business objects to be Serializable.
>
> 5. After changes (1), (2), (3) and (4) I am now running into a build 
> issue:
> testTransform1(org.apache.tuscany.sca.databinding.impl.MediatorImplTestCase)  
> Time elapsed: 0.02 sec  <<< ERROR!
> java.lang.ClassCastException: 
> org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer 
> cannot be cast to org.apache.tuscany.sca.databinding.DataPipeTransformer
>        at 
> org.apache.tuscany.sca.databinding.impl.MediatorImpl.mediate(MediatorImpl.java:75) 
>
>        at 
> org.apache.tuscany.sca.databinding.impl.MediatorImplTestCase.testTransform1(MediatorImplTestCase.java:104) 
>
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
>
>        at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
>
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at junit.framework.TestCase.runTest(TestCase.java:168)
>        at junit.framework.TestCase.runBare(TestCase.java:134)
>        at junit.framework.TestResult$1.protect(TestResult.java:110)
>        at junit.framework.TestResult.runProtected(TestResult.java:128)
>        at junit.framework.TestResult.run(TestResult.java:113)
>        at junit.framework.TestCase.run(TestCase.java:124)
>        at junit.framework.TestSuite.runTest(TestSuite.java:232)
>        at junit.framework.TestSuite.run(TestSuite.java:227)
>        at 
> org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35) 
>
>        at 
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) 
>
>        at 
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138) 
>
>        at 
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125) 
>
>        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
>
>        at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
>
>        at java.lang.reflect.Method.invoke(Method.java:597)
>        at 
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:299) 
>
>        at 
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:837) 
>
>
> I'm getting to the end of the rope here... does anyone know what can 
> cause error (5)?
>
> Thanks
>

A little more info:

The ClassCastException is on:
            } else if (transformer instanceof PushTransformer) {
                DataPipeTransformer dataPipeFactory = (i < size - 1) ? 
(DataPipeTransformer)path.get(++i) : null;

path =
[org.apache.tuscany.sca.databinding.xml.String2SAX@15a6029,
 org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint$LazyPullTransformer@5f6303;className=org.apache.tuscany.sca.databinding.xml.SAX2DOMPipe]

sourceDataType = class java.lang.String java.lang.String class 
java.lang.String
targetDataType = interface org.w3c.dom.Node org.w3c.dom.Node interface 
org.w3c.dom.Node

-- 
Jean-Sebastien


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org