tuscany-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastián Groh <sebastiang...@gmail.com>
Subject Re: WS bindings and SDO
Date Mon, 01 Jun 2009 03:09:28 GMT
Hello,
           Thanks Ant Elder, your Apache Tuscany SCA Java 1.5 released
announce mail responded my last question on this list.

           Raymond, the problem was fixed in version tuscany 1.5. I
didn't need comment the service promotion.
I have had the same exception when I tried something like this:

0.  public class BiochemicalCircleImpl implements BiochemicalCircle{
1.
2.     public Laboratory getLaboratory(String name) {
3.        if (name.length() < 5)
4.  	       return null;
5.        Laboratory lab = EntityFactory.INSTANCE.createLaboratory();
6.        lab.setName("Main Laboratory");
7.        return lab;
8.     }
9.  }

If condition was true in line 3, null was returned an the exception was:
Exception in thread "main" java.lang.ClassCastException:
org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl

otherwhise, all works perfectly!

My solution was, create a Laboratory object with properties setted in
null and change invocation logic assuming that always will return a
Laboratory object. Empty Laboratories were considered when any of its
properties was null.


Thanks Raymond, and all people who responded to my earlier concerns.
Best Regards,

                         Sebastián Groh



2009/5/30 Sebastián Groh <sebastiangroh@gmail.com>
>
> Hello,
>            Raymond, thanks for your answer. I've checked my mail late, I see
that you can test my example without my source files.
> At the moment, I commented the service promotion as you suggest, and I'm trying to download
the latest 1.5 code
> but I can't found that.
>
> Someone here knows how to download that version? I was reading Continuum and in version
says "1.6-SNAPSHOT" .
>
> Have Tuscany SCA version 2.X implemented the same functionality that version 1.x?
>
> Raymond, will I found my errors fixed in version 2.X?
>
> Thanks,
>
>                Sebastián Groh
>
>
>
>
> On Sat, May 30, 2009 at 3:57 AM, Raymond Feng <enjoyjava@gmail.com> wrote:
>>
>> Hi,
>>
>> I just tried your test case (adding the classes/resources to the helloworld-ws-sdo
sample) with the latest 1.5 code. It works after I fixed an issue in the composite file:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <sca:composite xmlns:federation="http://eclipse.org/SCAExample1/src/resources/federation"
>>   xmlns:sca="http://www.osoa.org/xmlns/sca/1.0" name="clinicalLaboratory"
>>   targetNamespace="http://eclipse.org/SCAExample1/src/resources/clinicalLaboratory">
>>
>>   <sca:component name="BiochemicalCircleComponent">
>>       <sca:implementation.java class="services.bcircle.BiochemicalCircleImpl"
/>
>>       <sca:service name="BiochemicalCircle">
>>           <sca:interface.java interface="services.bcircle.BiochemicalCircle"
/>
>>           <sca:binding.ws uri="http://localhost:8080/SCA1/MyServiceComponent"
/>
>>       </sca:service>
>>   </sca:component>
>>   <!--
>>   <sca:service name="BiochemicalCircle" promote="BiochemicalCircleComponent/BiochemicalCircle"
/>
>>    -->
>> </sca:composite>
>>
>> Please note the service promotion is commented out as it triggers an issue in Tuscany
where the service promotion has the same URI as the internal binding.ws.
>>
>> Thanks,
>> Raymond
>>
>> From: Sebastián Groh
>> Sent: Friday, May 29, 2009 3:38 PM
>> To: user@tuscany.apache.org
>> Subject: Re: WS bindings and SDO
>>
>>
>> Raymond,
>>                hello again, I follow your advice  " I suggest that you open
a JIRA and attach the test case there so that we can debug.". I opened a JIRA (link). This
is my first bug there. Can you tell me if I've posted enough information?
>> Thanks,
>>              Sebastián Groh
>>
>> 2009/5/26 Sebastián Groh <sebastiangroh@gmail.com>:
>>>
>>> Hi Raymond,
>>>                    thanks for your answer. I debug my application and
sca
>>> source.
>>> Next I will try to explain the invocation chain:
>>>
>>> When JDKInvocationHandler calls method invoke(InvocationChain chain,
>>> Object[] args, RuntimeWire wire, EndpointReference source)
>>>
>>> line 288: Message resp = headInvoker.invoke(msg); // invocation occurs
>>> without errors
>>> line 289: Object body = resp.getBody(); // Returns an
>>> org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl object
>>>
>>> It seems that body was not instantiated with the correct class.
>>>
>>>
>>> Cite:
>>>        " I suggest that you open a JIRA and attach the test case there so
>>> that we can debug."
>>> I'll try this, i never did that before. What I need to post there?
>>>
>>> For the moment I'll publish my problem here.
>>>
>>> My XSD file is:
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <schema xmlns="http://www.w3.org/2001/XMLSchema"
>>>
>>>
>>> targetNamespace="http://eclipse.org/SCAExample1/src/resources/clinicalLaboratory"
>>>
>>>
>>> xmlns:tns="http://eclipse.org/SCAExample1/src/resources/clinicalLaboratory"
>>>   elementFormDefault="qualified">
>>>   <complexType name="Practice">
>>>       <sequence>
>>>           <element name="name" type="string" />
>>>       </sequence>
>>>   </complexType>
>>>   <complexType name="Laboratory">
>>>       <sequence>
>>>           <element name="name" type="string" />
>>>           <element name="practices" type="tns:Practice"
>>> maxOccurs="unbounded"/>
>>>        </sequence>
>>>   </complexType>
>>> </schema>
>>>
>>> Composite file:
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <sca:composite
>>> xmlns:federation="http://eclipse.org/SCAExample1/src/resources/federation"
>>> xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
>>> name="clinicalLaboratory"
>>> targetNamespace="http://eclipse.org/SCAExample1/src/resources/clinicalLaboratory">
>>> <sca:component name="BiochemicalCircleComponent">
>>>   <sca:implementation.java class="services.bcircle.BiochemicalCircleImpl"/>
>>>   <sca:service name="BiochemicalCircle">
>>>    <sca:interface.java interface="services.bcircle.BiochemicalCircle"/>
>>>    <sca:binding.ws uri="http://localhost:8080/SCA1/MyServiceComponent"/>
>>>   </sca:service>
>>>  </sca:component>
>>>  <sca:service name="BiochemicalCircle"
>>> promote="BiochemicalCircleComponent/BiochemicalCircle"/>
>>> </sca:composite>
>>>
>>> Interface file:
>>> package services.bcircle;
>>> import java.util.ArrayList;
>>> import javax.xml.bind.annotation.XmlType;
>>> import model.sdo.EntityFactory;
>>> import org.apache.tuscany.sca.databinding.annotation.DataBinding;
>>> import org.osoa.sca.annotations.Remotable;
>>>
>>> @Remotable
>>> public interface BiochemicalCircle{
>>>    void setLaboratory(model.sdo.Laboratory lab);
>>>    model.sdo.Laboratory getLaboratory(String name);
>>> }
>>>
>>> Interface implementation:
>>>
>>> package services.bcircle;
>>> import model.sdo.EntityFactory;
>>> import model.sdo.Laboratory;
>>> import org.osoa.sca.annotations.Service;
>>>
>>>
>>> @Service(BiochemicalCircle.class)
>>> public class BiochemicalCircleImpl implements BiochemicalCircle{
>>>   public Laboratory getLaboratory(String name) {
>>>      Laboratory lab = EntityFactory.INSTANCE.createLaboratory();
>>>      lab.setName("Main Laboratory");
>>>      return lab;
>>>   }
>>>
>>>   public void setLaboratory(Laboratory lab) {
>>>      //sad method
>>>      System.out.println(lab.getName());
>>>   }
>>> }
>>>
>>> My Test class:
>>> package test;
>>>
>>> import model.sdo.EntityFactory;
>>> import model.sdo.Laboratory;
>>>
>>> import org.apache.tuscany.sca.host.embedded.SCADomain;
>>> import services.bcircle.BiochemicalCircle;
>>> import services.bcircle.BiochemicalCircleImpl;
>>>
>>>
>>> public class Test {
>>>
>>>    /**
>>>     * @param args
>>>     */
>>>    public static void main(String[] args) {
>>>        BiochemicalCircle biochemicalCircl = new BiochemicalCircleImpl();
>>>        Laboratory lab2 = biochemicalCircl.getLaboratory("Lab2"); //This
>>> invocation without use SCA works ok.
>>>
>>>
>>>        SCADomain scaDomain =
>>> SCADomain.newInstance("resources/clinicalLaboratory.composite");
>>>        BiochemicalCircle biochemicalCircle = scaDomain.getService(
>>>                BiochemicalCircle.class, "BiochemicalCircleComponent");
>>>        Laboratory lab = EntityFactory.INSTANCE.createLaboratory();
>>>        lab.setName("lab2");
>>>        biochemicalCircle.setLaboratory(lab); // this invocation works ok
>>> too
>>>
>>>        lab = biochemicalCircle.getLaboratory("Lab2"); // here I have an
>>> exception posted below.
>>>
>>>        //here I wait a moment before close scaDomain
>>>
>>>        scaDomain.close();
>>>
>>> }
>>>
>>> Exception:
>>> Exception in thread "main" java.lang.ClassCastException:
>>> org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl
>>>    at $Proxy16.getLaboratory(Unknown Source)
>>>    at test.Test.main(Test.java:28)
>>>
>>> Note:
>>> EntityFactory and sdo objects where created using
>>> org.apache.tuscany.sdo.generate.XSD2JavaGenerator.
>>>
>>> Please, tell me if something is wrong.
>>> Regards,
>>>
>>>                 Sebastián Groh
>>>
>>>
>>>
>>>
>>> On Tue, May 26, 2009 at 12:30 PM, Raymond Feng <enjoyjava@gmail.com> wrote:
>>>>
>>>> Did you check the response message from the WS? It might be the case that
>>>> XML payload is not conforming to the XSD which is used to generate the
>>>> SDO.
>>>>
>>>> I suggest that you open a JIRA and attach the test case there so that we
>>>> can
>>>> debug.
>>>>
>>>> Thanks,
>>>> Raymond
>>>>
>>>> --------------------------------------------------
>>>> From: "Sebastián Groh" <sebastiangroh@gmail.com>
>>>> Sent: Sunday, May 24, 2009 11:06 PM
>>>> To: <user@tuscany.apache.org>
>>>> Subject: Re: WS bindings and SDO
>>>>
>>>>> Hello,
>>>>>
>>>>>        Raymond I've posted my interface in my last mail, after that
>>>>> I did some tests.
>>>>> When I send a SDO Object, all runs ok, but unfortunately for all SCA
>>>>> users, return an SDO object is a problem even if HelperContext is
>>>>> used.
>>>>>
>>>>> For example:
>>>>> 1.  SCADomain scaDomain =
>>>>>             SCADomain.newInstance("clinicalLaboratory.composite");
>>>>> 2.  BiochemicalCircle service =
>>>>>
>>>>>
>>>>> scaDomain.getService(BiochemicalCircle.class,"BiochemicalCircleComponent");
>>>>> 3. Laboratory lab = EntityFactory.INSTANCE.createLaboratory();
>>>>> 4. lab.setName("lab2");
>>>>> 5. biochemicalCircle.setLaboratory(lab);
>>>>> 6. Laboratory posibleLab = (Laboratory) service.getLaboratory("Lab2");
>>>>>
>>>>> Line 5 works ok, SDO Laboratory object was send and name property was
>>>>> read ok on server side.
>>>>> Line 6 fails, I'm having always the same error:
>>>>>
>>>>>  java.lang.ClassCastException:
>>>>>  org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl
>>>>>  at $Proxy18.getLaboratory(Unknown Source)
>>>>>
>>>>> Thanks,
>>>>> Best Regards,
>>>>>
>>>>>                         Sebastián Groh
>>>>>
>>>>>
>>>>>
>>>>> 2009/5/22 Sebastián Groh <sebastiangroh@gmail.com>:
>>>>>>
>>>>>> Hello Raymond,
>>>>>>
>>>>>> My Interface is quite simple:
>>>>>>
>>>>>> package services.bcircle;
>>>>>>
>>>>>> import java.util.ArrayList;
>>>>>>
>>>>>> import org.osoa.sca.annotations.Remotable;
>>>>>>
>>>>>> @Remotable
>>>>>> public interface BiochemicalCircle{
>>>>>>
>>>>>>
>>>>>>      ArrayList<String> getLaboratoriesNames();
>>>>>>
>>>>>>      model.sdo.Laboratory getLaboratory(String name);
>>>>>>
>>>>>> }
>>>>>>
>>>>>> I think that my problem is related with SDO HelperContext but I'm
>>>>>> confused.
>>>>>>
>>>>>> Thanks,
>>>>>>            Sebastián
>>>>>>
>>>>>>
>>>>>> On Fri, May 22, 2009 at 7:50 PM, Raymond Feng <enjoyjava@gmail.com>
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> It seems that the SDO HelperContext is not correctly populated
by
>>>>>>> Tuscany
>>>>>>> based on the introspection of the Java interface that references
the
>>>>>>> SDO
>>>>>>> types. Can you post the BiochemicalCircle interface?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Raymond
>>>>>>>
>>>>>>> --------------------------------------------------
>>>>>>> From: "Sebastián Groh" <sebastiangroh@gmail.com>
>>>>>>> Sent: Friday, May 22, 2009 2:47 PM
>>>>>>> To: <user@tuscany.apache.org>
>>>>>>> Subject: Re: WS bindings and SDO
>>>>>>>
>>>>>>>> Hello Again,
>>>>>>>>
>>>>>>>> I'm getting the same error using ws binding.
>>>>>>>> If I try:
>>>>>>>>            SCADomain scaDomain =
>>>>>>>> SCADomain.newInstance("clinicalLaboratory.composite");
>>>>>>>>            BiochemicalCircle service =
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> scaDomain.getService(BiochemicalCircle.class,"BiochemicalCircleComponent");
>>>>>>>>            Laboratory lab = (Laboratory)
>>>>>>>> service.getLaboratory("Lab2");
>>>>>>>>
>>>>>>>> I have the exception:
>>>>>>>>    java.lang.ClassCastException:
>>>>>>>>   org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl
>>>>>>>>   at $Proxy18.getLaboratory(Unknown Source)
>>>>>>>>
>>>>>>>> but if I simple do:
>>>>>>>>
>>>>>>>>             BiochemicalCircle biochemicalCircle = new
>>>>>>>> BiochemicalCircleImpl();
>>>>>>>> Laboratory lab2 = biochemicalCircle.getLaboratory("Lab2");
>>>>>>>>
>>>>>>>> All runs ok.
>>>>>>>>
>>>>>>>> Invocation to BiochemicalCircle methods that not have SDO
parameters
>>>>>>>> (or return them) works fine even if SCADomain is used.
>>>>>>>>
>>>>>>>> Any in this list, know what I should do for solve this problem?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>           Sebastián
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> 2009/5/21 Sebastián Groh <sebastiangroh@gmail.com>:
>>>>>>>>>
>>>>>>>>> Hello Kevin, Simon,
>>>>>>>>>
>>>>>>>>> cite:
>>>>>>>>>        Is the XSD you generated the SDO from included
in your
>>>>>>>>> contribution?
>>>>>>>>>
>>>>>>>>> Yes I'm including the XSD, but how and when should it
be used?
>>>>>>>>> I verified if wsdl generated have included schema types
and there are
>>>>>>>>> ok. I thought that was enough if the wsdl have schemas
included. Is
>>>>>>>>> this correct?
>>>>>>>>>
>>>>>>>>> Simon, you are rigth when you see AnyTypeDataObjectImpl
instances is
>>>>>>>>> becouse "If the ServiceFactory is not registered, the
data (from the
>>>>>>>>> inline schema of the WSDL) are then represented by
>>>>>>>>> 'org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl' "
>>>>>>>>>
>>>>>>>>> What must I do? Use  commonj.sdo.helper.HelperContext
or not?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Any user in this list have errors like that?
>>>>>>>>> Thanks for yours answers,
>>>>>>>>> Regards,
>>>>>>>>>             Sebastián
>>>>>>>>>
>>>>>>>>> On Thu, May 21, 2009 at 6:50 AM, kelvin goodson
>>>>>>>>> <kelvingoodson@gmail.com>
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> I'm no expert on how SCA uses SDO, but I do understand
the SDO side
>>>>>>>>>> of
>>>>>>>>>> this, which may help you or someone else get to how
to fix this
>>>>>>>>>> within
>>>>>>>>>> SCA.  The time that you see instances of AnyTypeDataObjectImpl
>>>>>>>>>> appearing is when an SDO deserialization operation
has no metadata
>>>>>>>>>> within its operating context to describe an object
it is trying to
>>>>>>>>>> deserialize, so it falls back on a very weak default
model of data
>>>>>>>>>> embodied in the built-in AnyTypedataObject SDO class.
>>>>>>>>>>
>>>>>>>>>> Either the SCA infrastructure or you must arrange
for the generated
>>>>>>>>>> SDO factory associated with your Laboratory class
to be known to the
>>>>>>>>>> relevant instance of SDO's HelperContext class. My
feeling is there
>>>>>>>>>> is
>>>>>>>>>> most probably a way to influence SCA to do this for
you,  but I
>>>>>>>>>> don't
>>>>>>>>>> know how.  At the Tuscany SDO API level, the metadata
registration
>>>>>>>>>> is
>>>>>>>>>> done via the Factory's register(HelperContext scope)
 method, so you
>>>>>>>>>> could watch for calls to that method on the factory
impl.
>>>>>>>>>>
>>>>>>>>>> Kelvin.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 2009/5/21 Simon Laws <simonslaws@googlemail.com>:
>>>>>>>>>>>
>>>>>>>>>>> 2009/5/21 Sebastián Groh <sebastiangroh@gmail.com>:
>>>>>>>>>>>>
>>>>>>>>>>>> Hello, I'm trying to work with an SCA Composite
that use ws
>>>>>>>>>>>> binding.
>>>>>>>>>>>> My component definition:
>>>>>>>>>>>>  <sca:component name="BiochemicalCircleComponent">
>>>>>>>>>>>>  <sca:implementation.java
>>>>>>>>>>>> class="services.bcircle.BiochemicalCircleImpl"/>
>>>>>>>>>>>>  <sca:service name="BiochemicalCircle">
>>>>>>>>>>>>     <sca:interface.java
>>>>>>>>>>>> interface="services.bcircle.BiochemicalCircle"/>
>>>>>>>>>>>>     <sca:binding.ws
>>>>>>>>>>>> uri="http://localhost:8080/SCA1/MyServiceComponent"/>
>>>>>>>>>>>>  </sca:service>
>>>>>>>>>>>>  </sca:component>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> The service retrieve a SDO object (Laboratory)
that I generated
>>>>>>>>>>>> from
>>>>>>>>>>>> XSD without problems.
>>>>>>>>>>>> I deployed the project on Apache Tomcat/5.5.27
and I'm using this
>>>>>>>>>>>> service from a jsp page as follows:
>>>>>>>>>>>>
>>>>>>>>>>>> (my includes)
>>>>>>>>>>>> .
>>>>>>>>>>>> .
>>>>>>>>>>>> .
>>>>>>>>>>>> <% SCADomain scaDomain =
>>>>>>>>>>>> SCADomain.newInstance("clinicalLaboratory.composite");
>>>>>>>>>>>>    BiochemicalCircle service =
>>>>>>>>>>>> scaDomain.getService(BiochemicalCircle.class,
>>>>>>>>>>>> "BiochemicalCircleComponent");
>>>>>>>>>>>>
>>>>>>>>>>>>     Laboratory lab = (Laboratory) service.getLaboratory("Lab2");
>>>>>>>>>>>> .
>>>>>>>>>>>> .  (more logic)
>>>>>>>>>>>> .
>>>>>>>>>>>>
>>>>>>>>>>>> %>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> In line
>>>>>>>>>>>>       Laboratory lab = (Laboratory)
>>>>>>>>>>>> service.getLaboratory("Lab2");
>>>>>>>>>>>>
>>>>>>>>>>>> I have the exception:
>>>>>>>>>>>>     java.lang.ClassCastException:
>>>>>>>>>>>> org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl
>>>>>>>>>>>>     at $Proxy18.getLaboratory(Unknown Source)
>>>>>>>>>>>>
>>>>>>>>>>>> I have also tried to use the class
>>>>>>>>>>>> commonj.sdo.helper.HelperContext
>>>>>>>>>>>> to
>>>>>>>>>>>> set a scope for my SDOFactory but I'm having
the same exception.
>>>>>>>>>>>>
>>>>>>>>>>>> Anyone in this list know to solve this error?
>>>>>>>>>>>> Regards,
>>>>>>>>>>>>             Sebastián
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Hi Sebastien
>>>>>>>>>>>
>>>>>>>>>>> Is the XSD you generated the SDO from included
in your
>>>>>>>>>>> contribution?
>>>>>>>>>>> I'm looking at the 1.x sample helloworld-ws-sdo-webapp
and can't
>>>>>>>>>>> actually see that the SDO types are specified
explicitly but the
>>>>>>>>>>> XSD
>>>>>>>>>>> used to generate them is included. Any of the
SDO experts out there
>>>>>>>>>>> know how we should be describing the SDO context
in SCA?
>>>>>>>>>>>
>>>>>>>>>>> Simon
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>>
>>
>

Mime
View raw message