Hi All, Normally when we get a tenant related request first we set __MultitenantDispatcherService to AxisService, because in super tenant mode, tenant axisconfigurationss are not loaded to the axisConfigurations, Therefore we create a dummy *mainInMsgContext *with "__MultitenantDispatcherService" AxisService. That's why We can't find Schemas and ElementQname in *mainInMsgContext.* and also the targetNamespace is set as "*http://ws.apache.org/axis2 <http://ws.apache.org/axis2>*" in both *mainInMsgContext*, and *mainOutMsgContext*. In MultitenantMessageReceiver, We create *mainOutMsgContext*. according to the *mainInMsgContext*, therefore "*http://ws.apache.org/axis2 <http://ws.apache.org/axis2>*" targetNamespace is set to *mainOutMsgContext.*
Since this is a REST call, tenant configurations are loaded to the axis
configuration in MultitenantRESTServlet, after that normal process will
follow, then it will create new message context with axisService, therefore
we can find Schemas and ElementQname in that message context. That's why we
can find Schemas and ElemenQname in *tenantOutMsgContext*.
After that we set *tenantOutMsgContext* 's envelop to *mainOutMsgContext*
- line#418 in MultitenantMessageReceiver.
but we don't set Schemas and other ElementQnames to the *mainOutMsgContext *in
MultitenantMessageReceiver. therefore we get NPE.
Tenant Json formatter problem was fixed, after doing the changes that I
have mentioned in my previous mail.
Then I found NPE in super tenant mode, when I try to get a response with
request status. (there is a feature in DSS to get the status of the
request). I have attached the NPE to my previous mail
But, when I try to get a response with return generated key feature, Json
formatter works fine with super tenant mode.
because, complex type element will send in the response of return generated
key feature. Therefore we can find the schemaOfType properly. in
XMLNodeGenerator line# 69.
but in simple type element it will be null, because
*(xmlSchema.getTargetNamespace().equals(qName.getNamespaceURI()))* won't be
true.
because in simple type elements messageSchemaTypeName will be like
"*{http://www.w3.org/2001/XMLSchema}string
<http://www.w3.org/2001/XMLSchema}string>*" some thing like this line#63 in
XMLNodeGenerator.
therefore we can't find xmlSchemaType for that messageSchemaTypeName,
because normally in AxisService xmlSchemaList contains targetnamespace
as *"http://ws.wso2.org/dataservice
<http://ws.wso2.org/dataservice>"*. then it will sset null for schemaOfType
in XMLNodeGenerator line# 69.
and also in line#96 we don't do anything for simple type elements.
Then We can set XmlSchemaType where XmlSchema is available.
Please find the attached patch that I have done changes to fix these two
issues
Thanks,
Madhawa
On Wed, May 27, 2015 at 12:42 PM, Madhawa Gunasekara <[email protected]>
wrote:
> Hi Devs,
>
> After the code review, Niranjan and myself debugged the code to find a fix
> for this issue. This issue is occurring due to unavailability of
> ElementQname in mainOutMsgContext.getAxisOperation().getMessage and
> unavailability of the schema. Schemas are used by only JsonFormatters.
>
> In the code review, there were some suggestions to check the schema in
> mainInMsgContext.
> we found that targetNamespace is set as "*http://ws.apache.org/axis2
> <http://ws.apache.org/axis2>*" in both *mainInMsgContext*, and
> *mainOutMsgContext*. but the actual targetnamespace should be like
> "*http://ws.wso2.org/dataservice
> <http://ws.wso2.org/dataservice>*". both of these assigning will be done
> in AbstractDispatcher line#94 axisService = findService(msgctx);
>
> We found that the targetNamespace of *tenantOutMsgContext* is set
> correctly.
>
> Therefore we have done below changes to fix the issue in
> MultitenantMessageReceiver -line#419
>
> mainOutMsgContext.getAxisOperation().getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE).setElementQName(
>
> tenantOutMsgContext.getAxisOperation().getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE)
> .getElementQName());
> mainOutMsgContext.getAxisService().addSchema(tenantOutMsgContext.getAxisService().getSchema());
>
>
> After the above changes It works fine for GET Method in tenant mode and
> super tenant mode.
>
>
>
> but when I do testing for POST method. It works fine, when there isn't a
> response from the data service. like a request for insert query without
> expecting request status or return generated key. because It doesn't have
> to send response using json formatters.
>
> but when I try to get a response like request status or return generated
> key using POST method. I found following null pointer exception in dss log.
>
>
> Thanks,
> Madhawa
>
> On Mon, May 25, 2015 at 12:05 PM, Madhawa Gunasekara <[email protected]>
> wrote:
>
>> Please find the public jira [1] for this issue. and the patch.
>>
>> [1] https://wso2.org/jira/browse/DS-879
>>
>>
>> On Mon, May 25, 2015 at 11:49 AM, Madhawa Gunasekara <[email protected]>
>> wrote:
>>
>>> Hi all,
>>>
>>> when we are trying to get JSON response in tenant mode, exception will
>>> occur. Therefore I have done some changes to fix the issue.
>>>
>>> - set the tenantOutMsgContext's AxisOperation to mainOutMsgContext
>>> in MultitenantMessageReceiver.java (line# 415-421)
>>>
>>>
>>> - in JsonFormatter.java, I have retrieve the schemas from
>>> outMsgCtxt.getAxisOperation().getAxisService().getSchema() (line# 90)
>>>
>>>
>>> I have able to fix the issue doing above changes, But when I try to
>>> build the carbon-kernel-patch0010 with test cases. Json related test cases
>>> are failing.
>>>
>>> In test cases, the schema is set to the AxisService and the AxisService
>>> is set to MessageContext. therefore null pointer exception will occur.
>>> because AxisService can't retrieve by getAxisOperation.getAxisService
>>> method.
>>>
>>> Also I have tried to set the AxisService to mainOutMsgContext in
>>> MultitenantMessageReceiver.java then I found null pointer exception in
>>> org.wso2.carbon.statistics.module.InOutMEPHandler. I have attached the null
>>> pointer exception also
>>>
>>>
>>> as per offline chat with Jayanga, He also couldn't find any wrong in
>>> these changes, but He told me to check that, why we need to set
>>> AxisOperation, because without setting the AxisOperation, we can't retrieve
>>> the elementQname in (JsonFormatter.java -line# 87).
>>>
>>> and also I couldn't find any setAxisOperation method calls in
>>> MessageContext.java file as well.
>>>
>>>
>>> Jayanga mentioned about some life cycles for these AxisOperations and
>>> AxisServices, I have no idea about those life cycles.
>>> Do these changes will effect those life cycles ?
>>>
>>> applying above mentioned changes json response works fine, but still
>>> Json related test cases are failing.
>>>
>>>
>>> Thanks,
>>>
>>> Madhawa.
>>> --
>>> *Madhawa Gunasekara*
>>> Software Engineer
>>> WSO2 Inc.; http://wso2.com
>>> lean.enterprise.middleware
>>>
>>> mobile: +94 719411002 <+94+719411002>
>>> blog: *http://madhawa-gunasekara.blogspot.com
>>> <http://madhawa-gunasekara.blogspot.com>*
>>> linkedin: *http://lk.linkedin.com/in/mgunasekara
>>> <http://lk.linkedin.com/in/mgunasekara>*
>>>
>>
>>
>>
>> --
>> *Madhawa Gunasekara*
>> Software Engineer
>> WSO2 Inc.; http://wso2.com
>> lean.enterprise.middleware
>>
>> mobile: +94 719411002 <+94+719411002>
>> blog: *http://madhawa-gunasekara.blogspot.com
>> <http://madhawa-gunasekara.blogspot.com>*
>> linkedin: *http://lk.linkedin.com/in/mgunasekara
>> <http://lk.linkedin.com/in/mgunasekara>*
>>
>
>
>
> --
> *Madhawa Gunasekara*
> Software Engineer
> WSO2 Inc.; http://wso2.com
> lean.enterprise.middleware
>
> mobile: +94 719411002 <+94+719411002>
> blog: *http://madhawa-gunasekara.blogspot.com
> <http://madhawa-gunasekara.blogspot.com>*
> linkedin: *http://lk.linkedin.com/in/mgunasekara
> <http://lk.linkedin.com/in/mgunasekara>*
>
--
*Madhawa Gunasekara*
Software Engineer
WSO2 Inc.; http://wso2.com
lean.enterprise.middleware
mobile: +94 719411002 <+94+719411002>
blog: *http://madhawa-gunasekara.blogspot.com
<http://madhawa-gunasekara.blogspot.com>*
linkedin: *http://lk.linkedin.com/in/mgunasekara
<http://lk.linkedin.com/in/mgunasekara>*
patch
Description: Binary data
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
