[Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

[Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Yasas Karunarathna
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Rajith Vitharana
Hi Yasas,

The points you have mentioned are correct, but there are small changes I would like to point out. Below are the steps you'll need to follow to achieve your goal.

1 - There is a patch release for the "axis2-json" so you'll need to check out the source from [1] instead of the svn location you have mentioned. (checkout the whole "patch0007" instead of json module, so that it'll be easy for you to build the source.)
2 - Add the classes you need to the source.
          You'll need to extend AbstractJSONMessageFormatter in your custom formatter class
          You'll need to extend AbstractJSONOMBuilder in you custom builder class
3 - Build the whole patch0007. Then go to "patch0007/dependencies/orbit/axis2-json/target" folder where you can find the osgi bundle created from "axis2-json" module.
4 - Create "patch0008" folder inside "DSS_HOME/repository/components/patches" folder and copy the osgi bundle you found in step 3 to that folder.
5 - Add "messageFormatter" and "messageBuilder" elements to the "DSS_HOME/repository/conf/axis2/axis2.xml" as you have pointed out in your step 3.
6 - Restart the server and invoke your service adding "Accept" request header to the request with new content type you mentioned in "axis2.xml", example would be "Accept:application/json/newformat".(You can find sample of how to do it in [2]) 

Thanks,


On Sun, Jul 13, 2014 at 1:45 PM, Yasas Karunarathna <[hidden email]> wrote:
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Shameera Rathnayaka-2
Hi Yasas,

Assuming you are going to customize the JSON mapped convention (Standard Mapped Json support is their with Axis2),You don't need to do anything to axis2 jar.  Implement your new JSON builder and formatter, then create a new jar(or osgi bundle) using those new classes
 and copy that jar ( or osgi bundle) to <DSS_HOME>/repository/components/lib ( or <DSS_HOME>/repository/components/dropings) directory. Finally,  you need to configure your builder and formatter in axis2.xm configuration file (like your 3rd step).

Thanks,
Shameera.




On Sun, Jul 13, 2014 at 10:35 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas,

The points you have mentioned are correct, but there are small changes I would like to point out. Below are the steps you'll need to follow to achieve your goal.

1 - There is a patch release for the "axis2-json" so you'll need to check out the source from [1] instead of the svn location you have mentioned. (checkout the whole "patch0007" instead of json module, so that it'll be easy for you to build the source.)
2 - Add the classes you need to the source.
          You'll need to extend AbstractJSONMessageFormatter in your custom formatter class
          You'll need to extend AbstractJSONOMBuilder in you custom builder class
3 - Build the whole patch0007. Then go to "patch0007/dependencies/orbit/axis2-json/target" folder where you can find the osgi bundle created from "axis2-json" module.
4 - Create "patch0008" folder inside "DSS_HOME/repository/components/patches" folder and copy the osgi bundle you found in step 3 to that folder.
5 - Add "messageFormatter" and "messageBuilder" elements to the "DSS_HOME/repository/conf/axis2/axis2.xml" as you have pointed out in your step 3.
6 - Restart the server and invoke your service adding "Accept" request header to the request with new content type you mentioned in "axis2.xml", example would be "Accept:application/json/newformat".(You can find sample of how to do it in [2]) 

Thanks,


On Sun, Jul 13, 2014 at 1:45 PM, Yasas Karunarathna <[hidden email]> wrote:
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Yasas Karunarathna
Thank you for the quick responses. I checked in sources from both the locations

Separately build without any modifications, and put generated jar to patch8 folder. Once I restart the server following message shows in the console.

"Could not start: null(reference:file:../plugins/axis2-json_1.6.1.wso2v10.jar:15). It's state is uninstalled."

After that logs the following error.

"Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.gson.JSONMessageHandler"

Any work around?



On Sun, Jul 13, 2014 at 11:30 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

Assuming you are going to customize the JSON mapped convention (Standard Mapped Json support is their with Axis2),You don't need to do anything to axis2 jar.  Implement your new JSON builder and formatter, then create a new jar(or osgi bundle) using those new classes
 and copy that jar ( or osgi bundle) to <DSS_HOME>/repository/components/lib ( or <DSS_HOME>/repository/components/dropings) directory. Finally,  you need to configure your builder and formatter in axis2.xm configuration file (like your 3rd step).

Thanks,
Shameera.




On Sun, Jul 13, 2014 at 10:35 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas,

The points you have mentioned are correct, but there are small changes I would like to point out. Below are the steps you'll need to follow to achieve your goal.

1 - There is a patch release for the "axis2-json" so you'll need to check out the source from [1] instead of the svn location you have mentioned. (checkout the whole "patch0007" instead of json module, so that it'll be easy for you to build the source.)
2 - Add the classes you need to the source.
          You'll need to extend AbstractJSONMessageFormatter in your custom formatter class
          You'll need to extend AbstractJSONOMBuilder in you custom builder class
3 - Build the whole patch0007. Then go to "patch0007/dependencies/orbit/axis2-json/target" folder where you can find the osgi bundle created from "axis2-json" module.
4 - Create "patch0008" folder inside "DSS_HOME/repository/components/patches" folder and copy the osgi bundle you found in step 3 to that folder.
5 - Add "messageFormatter" and "messageBuilder" elements to the "DSS_HOME/repository/conf/axis2/axis2.xml" as you have pointed out in your step 3.
6 - Restart the server and invoke your service adding "Accept" request header to the request with new content type you mentioned in "axis2.xml", example would be "Accept:application/json/newformat".(You can find sample of how to do it in [2]) 

Thanks,


On Sun, Jul 13, 2014 at 1:45 PM, Yasas Karunarathna <[hidden email]> wrote:
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Shameera Rathnayaka-2
Hi Yasas,

For you ClassNotFoundException, check do your axis2-json jar has required classes, BTW as i mentioned in previous reply you don't need to do any code changes to axis2 jars in order to plug your custom builders.

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 1:36 PM, Yasas Karunarathna <[hidden email]> wrote:
Thank you for the quick responses. I checked in sources from both the locations

Separately build without any modifications, and put generated jar to patch8 folder. Once I restart the server following message shows in the console.

"Could not start: null(reference:file:../plugins/axis2-json_1.6.1.wso2v10.jar:15). It's state is uninstalled."

After that logs the following error.

"Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.gson.JSONMessageHandler"

Any work around?



On Sun, Jul 13, 2014 at 11:30 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

Assuming you are going to customize the JSON mapped convention (Standard Mapped Json support is their with Axis2),You don't need to do anything to axis2 jar.  Implement your new JSON builder and formatter, then create a new jar(or osgi bundle) using those new classes
 and copy that jar ( or osgi bundle) to <DSS_HOME>/repository/components/lib ( or <DSS_HOME>/repository/components/dropings) directory. Finally,  you need to configure your builder and formatter in axis2.xm configuration file (like your 3rd step).

Thanks,
Shameera.




On Sun, Jul 13, 2014 at 10:35 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas,

The points you have mentioned are correct, but there are small changes I would like to point out. Below are the steps you'll need to follow to achieve your goal.

1 - There is a patch release for the "axis2-json" so you'll need to check out the source from [1] instead of the svn location you have mentioned. (checkout the whole "patch0007" instead of json module, so that it'll be easy for you to build the source.)
2 - Add the classes you need to the source.
          You'll need to extend AbstractJSONMessageFormatter in your custom formatter class
          You'll need to extend AbstractJSONOMBuilder in you custom builder class
3 - Build the whole patch0007. Then go to "patch0007/dependencies/orbit/axis2-json/target" folder where you can find the osgi bundle created from "axis2-json" module.
4 - Create "patch0008" folder inside "DSS_HOME/repository/components/patches" folder and copy the osgi bundle you found in step 3 to that folder.
5 - Add "messageFormatter" and "messageBuilder" elements to the "DSS_HOME/repository/conf/axis2/axis2.xml" as you have pointed out in your step 3.
6 - Restart the server and invoke your service adding "Accept" request header to the request with new content type you mentioned in "axis2.xml", example would be "Accept:application/json/newformat".(You can find sample of how to do it in [2]) 

Thanks,


On Sun, Jul 13, 2014 at 1:45 PM, Yasas Karunarathna <[hidden email]> wrote:
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  +9471 922 1454


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Rajith Vitharana
Hi Yasas, 

Try out creating a simple jar and put it in lib folder as shameera mentioned in above reply. I have tried out the scenario I have explained to you, and it worked fine for me
As I mentioned, have you build the whole patch from the pom.xml inside patch0007 folder? 
and have you created "patch0008" folder and copied the jar(axis2-json-1.6.1-wso2v10.jar) inside "patch0007/dependencies/orbit/axis2-json/target" folder to the "patch0008" folder?

Thanks,



On Mon, Jul 14, 2014 at 1:50 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

For you ClassNotFoundException, check do your axis2-json jar has required classes, BTW as i mentioned in previous reply you don't need to do any code changes to axis2 jars in order to plug your custom builders.

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 1:36 PM, Yasas Karunarathna <[hidden email]> wrote:
Thank you for the quick responses. I checked in sources from both the locations

Separately build without any modifications, and put generated jar to patch8 folder. Once I restart the server following message shows in the console.

"Could not start: null(reference:file:../plugins/axis2-json_1.6.1.wso2v10.jar:15). It's state is uninstalled."

After that logs the following error.

"Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.gson.JSONMessageHandler"

Any work around?



On Sun, Jul 13, 2014 at 11:30 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

Assuming you are going to customize the JSON mapped convention (Standard Mapped Json support is their with Axis2),You don't need to do anything to axis2 jar.  Implement your new JSON builder and formatter, then create a new jar(or osgi bundle) using those new classes
 and copy that jar ( or osgi bundle) to <DSS_HOME>/repository/components/lib ( or <DSS_HOME>/repository/components/dropings) directory. Finally,  you need to configure your builder and formatter in axis2.xm configuration file (like your 3rd step).

Thanks,
Shameera.




On Sun, Jul 13, 2014 at 10:35 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas,

The points you have mentioned are correct, but there are small changes I would like to point out. Below are the steps you'll need to follow to achieve your goal.

1 - There is a patch release for the "axis2-json" so you'll need to check out the source from [1] instead of the svn location you have mentioned. (checkout the whole "patch0007" instead of json module, so that it'll be easy for you to build the source.)
2 - Add the classes you need to the source.
          You'll need to extend AbstractJSONMessageFormatter in your custom formatter class
          You'll need to extend AbstractJSONOMBuilder in you custom builder class
3 - Build the whole patch0007. Then go to "patch0007/dependencies/orbit/axis2-json/target" folder where you can find the osgi bundle created from "axis2-json" module.
4 - Create "patch0008" folder inside "DSS_HOME/repository/components/patches" folder and copy the osgi bundle you found in step 3 to that folder.
5 - Add "messageFormatter" and "messageBuilder" elements to the "DSS_HOME/repository/conf/axis2/axis2.xml" as you have pointed out in your step 3.
6 - Restart the server and invoke your service adding "Accept" request header to the request with new content type you mentioned in "axis2.xml", example would be "Accept:application/json/newformat".(You can find sample of how to do it in [2]) 

Thanks,


On Sun, Jul 13, 2014 at 1:45 PM, Yasas Karunarathna <[hidden email]> wrote:
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Shameera Rathnayaka-2
Hi Rajith,

Why are you asking him to build the patches , can't he work on already released DSs pack, Here i am trying to understand which issue Yasas trying to address by implementing a new JSON builder and formatter, we have plenty of Builders and formatters for JSON :) . May i know the real use case and requirement ?

Thanks,
Shameera


On Mon, Jul 14, 2014 at 2:51 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas, 

Try out creating a simple jar and put it in lib folder as shameera mentioned in above reply. I have tried out the scenario I have explained to you, and it worked fine for me
As I mentioned, have you build the whole patch from the pom.xml inside patch0007 folder? 
and have you created "patch0008" folder and copied the jar(axis2-json-1.6.1-wso2v10.jar) inside "patch0007/dependencies/orbit/axis2-json/target" folder to the "patch0008" folder?

Thanks,



On Mon, Jul 14, 2014 at 1:50 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

For you ClassNotFoundException, check do your axis2-json jar has required classes, BTW as i mentioned in previous reply you don't need to do any code changes to axis2 jars in order to plug your custom builders.

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 1:36 PM, Yasas Karunarathna <[hidden email]> wrote:
Thank you for the quick responses. I checked in sources from both the locations

Separately build without any modifications, and put generated jar to patch8 folder. Once I restart the server following message shows in the console.

"Could not start: null(reference:file:../plugins/axis2-json_1.6.1.wso2v10.jar:15). It's state is uninstalled."

After that logs the following error.

"Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.gson.JSONMessageHandler"

Any work around?



On Sun, Jul 13, 2014 at 11:30 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

Assuming you are going to customize the JSON mapped convention (Standard Mapped Json support is their with Axis2),You don't need to do anything to axis2 jar.  Implement your new JSON builder and formatter, then create a new jar(or osgi bundle) using those new classes
 and copy that jar ( or osgi bundle) to <DSS_HOME>/repository/components/lib ( or <DSS_HOME>/repository/components/dropings) directory. Finally,  you need to configure your builder and formatter in axis2.xm configuration file (like your 3rd step).

Thanks,
Shameera.




On Sun, Jul 13, 2014 at 10:35 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas,

The points you have mentioned are correct, but there are small changes I would like to point out. Below are the steps you'll need to follow to achieve your goal.

1 - There is a patch release for the "axis2-json" so you'll need to check out the source from [1] instead of the svn location you have mentioned. (checkout the whole "patch0007" instead of json module, so that it'll be easy for you to build the source.)
2 - Add the classes you need to the source.
          You'll need to extend AbstractJSONMessageFormatter in your custom formatter class
          You'll need to extend AbstractJSONOMBuilder in you custom builder class
3 - Build the whole patch0007. Then go to "patch0007/dependencies/orbit/axis2-json/target" folder where you can find the osgi bundle created from "axis2-json" module.
4 - Create "patch0008" folder inside "DSS_HOME/repository/components/patches" folder and copy the osgi bundle you found in step 3 to that folder.
5 - Add "messageFormatter" and "messageBuilder" elements to the "DSS_HOME/repository/conf/axis2/axis2.xml" as you have pointed out in your step 3.
6 - Restart the server and invoke your service adding "Accept" request header to the request with new content type you mentioned in "axis2.xml", example would be "Accept:application/json/newformat".(You can find sample of how to do it in [2]) 

Thanks,


On Sun, Jul 13, 2014 at 1:45 PM, Yasas Karunarathna <[hidden email]> wrote:
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--
Software Engineer - WSO2 Inc.
phone:  +9471 922 1454


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Rajith Vitharana
Hi,

I have tried with putting a jar file as a library to the repository/conf/lib folder. But it throws an exception when initializing axis2.xml file with class not found exception. Maybe axis2.xml get loaded before loading the classes in lib folder. Below is the exception which was thrown.

[2014-07-14 16:24:48,583] FATAL {org.wso2.carbon.core.init.CarbonServerManager} -  WSO2 Carbon initialization Failed
org.apache.axis2.AxisFault: Exception occured while loading the Axis configuration from /media/rajith/Office/Wso2/team/product/wso2dss-3.2.1/repository/conf/axis2/axis2.xml
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:190)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
at org.wso2.carbon.core.CarbonConfigurationContextFactory.createNewConfigurationContext(CarbonConfigurationContextFactory.java:65)
at org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:398)
at org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219)
at org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:77)
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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
at org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81)
at org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40)
at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1267)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1186)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1081)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.axis2.deployment.DeploymentException: org/apache/axis2/json/JSONMMyFormatter
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:775)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:236)
at org.wso2.carbon.core.CarbonAxisConfigurator.populateAxisConfiguration(CarbonAxisConfigurator.java:308)
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:188)
... 42 more
Caused by: java.lang.NoClassDefFoundError: org/apache/axis2/json/JSONMMyFormatter
at org.wso2.training.custom.json.JSONMyBuilder.<init>(JSONMyBuilder.java:35)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:310)
at org.apache.axis2.deployment.DescriptionBuilder.processMessageBuilders(DescriptionBuilder.java:230)
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:772)
... 45 more
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.JSONMMyFormatter
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:455)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 54 more


Thanks,


On Mon, Jul 14, 2014 at 3:17 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Rajith,

Why are you asking him to build the patches , can't he work on already released DSs pack, Here i am trying to understand which issue Yasas trying to address by implementing a new JSON builder and formatter, we have plenty of Builders and formatters for JSON :) . May i know the real use case and requirement ?

Thanks,
Shameera


On Mon, Jul 14, 2014 at 2:51 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas, 

Try out creating a simple jar and put it in lib folder as shameera mentioned in above reply. I have tried out the scenario I have explained to you, and it worked fine for me
As I mentioned, have you build the whole patch from the pom.xml inside patch0007 folder? 
and have you created "patch0008" folder and copied the jar(axis2-json-1.6.1-wso2v10.jar) inside "patch0007/dependencies/orbit/axis2-json/target" folder to the "patch0008" folder?

Thanks,



On Mon, Jul 14, 2014 at 1:50 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

For you ClassNotFoundException, check do your axis2-json jar has required classes, BTW as i mentioned in previous reply you don't need to do any code changes to axis2 jars in order to plug your custom builders.

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 1:36 PM, Yasas Karunarathna <[hidden email]> wrote:
Thank you for the quick responses. I checked in sources from both the locations

Separately build without any modifications, and put generated jar to patch8 folder. Once I restart the server following message shows in the console.

"Could not start: null(reference:file:../plugins/axis2-json_1.6.1.wso2v10.jar:15). It's state is uninstalled."

After that logs the following error.

"Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.gson.JSONMessageHandler"

Any work around?



On Sun, Jul 13, 2014 at 11:30 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

Assuming you are going to customize the JSON mapped convention (Standard Mapped Json support is their with Axis2),You don't need to do anything to axis2 jar.  Implement your new JSON builder and formatter, then create a new jar(or osgi bundle) using those new classes
 and copy that jar ( or osgi bundle) to <DSS_HOME>/repository/components/lib ( or <DSS_HOME>/repository/components/dropings) directory. Finally,  you need to configure your builder and formatter in axis2.xm configuration file (like your 3rd step).

Thanks,
Shameera.




On Sun, Jul 13, 2014 at 10:35 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas,

The points you have mentioned are correct, but there are small changes I would like to point out. Below are the steps you'll need to follow to achieve your goal.

1 - There is a patch release for the "axis2-json" so you'll need to check out the source from [1] instead of the svn location you have mentioned. (checkout the whole "patch0007" instead of json module, so that it'll be easy for you to build the source.)
2 - Add the classes you need to the source.
          You'll need to extend AbstractJSONMessageFormatter in your custom formatter class
          You'll need to extend AbstractJSONOMBuilder in you custom builder class
3 - Build the whole patch0007. Then go to "patch0007/dependencies/orbit/axis2-json/target" folder where you can find the osgi bundle created from "axis2-json" module.
4 - Create "patch0008" folder inside "DSS_HOME/repository/components/patches" folder and copy the osgi bundle you found in step 3 to that folder.
5 - Add "messageFormatter" and "messageBuilder" elements to the "DSS_HOME/repository/conf/axis2/axis2.xml" as you have pointed out in your step 3.
6 - Restart the server and invoke your service adding "Accept" request header to the request with new content type you mentioned in "axis2.xml", example would be "Accept:application/json/newformat".(You can find sample of how to do it in [2]) 

Thanks,


On Sun, Jul 13, 2014 at 1:45 PM, Yasas Karunarathna <[hidden email]> wrote:
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Yasas Karunarathna
@Ragith I checked out whole patch0007, couldn't build from the root(created some dependency problems with "dependencies/orbit/axis2-json" module... some relative path dependency pom files... i'm working on it nw ). So build only "dependencies/axis2/modules/json" module, copy the generated jar to the folder called 'patch0008' under wso2dss-3.2.1/repository/components/patches Not "dependencies/orbit/axis2-json".

@Shameera Thanks for asking that, problem is DSS json response is not uniform, so not convenient for the consumer. As an example, for a given select-query-operation there can be 3 types of responses. 

1) There are no records. 
{"Entries";""}

2) Only one record.
{"Entries":{"Entry":{"col1":"val1","col2":"val2"}}}

3) More than one records.
{"Entries":{"Entry":[{"col1":"val1","col2":"val2"}{"col1":"val3","col2":"val4"}]}}

When consuming the service there are few validation checks we have to do. No1 is partially OK, simple null check. But in No2 & No3, when we are getting the value of key "Entry" we have to check whether is it an array of objects or just an object, which i think is not convenient for the consumer. 

So I want to come up with a uniform type of response as below.

1) {"Entries":{"Entry":[]}}
2) {"Entries":{"Entry":[{"col1":"val1","col2":"val2"}]}}
3) {"Entries":{"Entry":[{"col1":"val1","col2":"val2"}{"col1":"val3","col2":"val4"}]}}

Any thoughts?


On Mon, Jul 14, 2014 at 4:28 PM, Rajith Vitharana <[hidden email]> wrote:
Hi,

I have tried with putting a jar file as a library to the repository/conf/lib folder. But it throws an exception when initializing axis2.xml file with class not found exception. Maybe axis2.xml get loaded before loading the classes in lib folder. Below is the exception which was thrown.

[2014-07-14 16:24:48,583] FATAL {org.wso2.carbon.core.init.CarbonServerManager} -  WSO2 Carbon initialization Failed
org.apache.axis2.AxisFault: Exception occured while loading the Axis configuration from /media/rajith/Office/Wso2/team/product/wso2dss-3.2.1/repository/conf/axis2/axis2.xml
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:190)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
at org.wso2.carbon.core.CarbonConfigurationContextFactory.createNewConfigurationContext(CarbonConfigurationContextFactory.java:65)
at org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:398)
at org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219)
at org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:77)
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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
at org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81)
at org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40)
at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1267)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1186)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1081)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.axis2.deployment.DeploymentException: org/apache/axis2/json/JSONMMyFormatter
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:775)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:236)
at org.wso2.carbon.core.CarbonAxisConfigurator.populateAxisConfiguration(CarbonAxisConfigurator.java:308)
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:188)
... 42 more
Caused by: java.lang.NoClassDefFoundError: org/apache/axis2/json/JSONMMyFormatter
at org.wso2.training.custom.json.JSONMyBuilder.<init>(JSONMyBuilder.java:35)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:310)
at org.apache.axis2.deployment.DescriptionBuilder.processMessageBuilders(DescriptionBuilder.java:230)
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:772)
... 45 more
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.JSONMMyFormatter
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:455)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 54 more


Thanks,


On Mon, Jul 14, 2014 at 3:17 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Rajith,

Why are you asking him to build the patches , can't he work on already released DSs pack, Here i am trying to understand which issue Yasas trying to address by implementing a new JSON builder and formatter, we have plenty of Builders and formatters for JSON :) . May i know the real use case and requirement ?

Thanks,
Shameera


On Mon, Jul 14, 2014 at 2:51 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas, 

Try out creating a simple jar and put it in lib folder as shameera mentioned in above reply. I have tried out the scenario I have explained to you, and it worked fine for me
As I mentioned, have you build the whole patch from the pom.xml inside patch0007 folder? 
and have you created "patch0008" folder and copied the jar(axis2-json-1.6.1-wso2v10.jar) inside "patch0007/dependencies/orbit/axis2-json/target" folder to the "patch0008" folder?

Thanks,



On Mon, Jul 14, 2014 at 1:50 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

For you ClassNotFoundException, check do your axis2-json jar has required classes, BTW as i mentioned in previous reply you don't need to do any code changes to axis2 jars in order to plug your custom builders.

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 1:36 PM, Yasas Karunarathna <[hidden email]> wrote:
Thank you for the quick responses. I checked in sources from both the locations

Separately build without any modifications, and put generated jar to patch8 folder. Once I restart the server following message shows in the console.

"Could not start: null(reference:file:../plugins/axis2-json_1.6.1.wso2v10.jar:15). It's state is uninstalled."

After that logs the following error.

"Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.gson.JSONMessageHandler"

Any work around?



On Sun, Jul 13, 2014 at 11:30 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

Assuming you are going to customize the JSON mapped convention (Standard Mapped Json support is their with Axis2),You don't need to do anything to axis2 jar.  Implement your new JSON builder and formatter, then create a new jar(or osgi bundle) using those new classes
 and copy that jar ( or osgi bundle) to <DSS_HOME>/repository/components/lib ( or <DSS_HOME>/repository/components/dropings) directory. Finally,  you need to configure your builder and formatter in axis2.xm configuration file (like your 3rd step).

Thanks,
Shameera.




On Sun, Jul 13, 2014 at 10:35 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas,

The points you have mentioned are correct, but there are small changes I would like to point out. Below are the steps you'll need to follow to achieve your goal.

1 - There is a patch release for the "axis2-json" so you'll need to check out the source from [1] instead of the svn location you have mentioned. (checkout the whole "patch0007" instead of json module, so that it'll be easy for you to build the source.)
2 - Add the classes you need to the source.
          You'll need to extend AbstractJSONMessageFormatter in your custom formatter class
          You'll need to extend AbstractJSONOMBuilder in you custom builder class
3 - Build the whole patch0007. Then go to "patch0007/dependencies/orbit/axis2-json/target" folder where you can find the osgi bundle created from "axis2-json" module.
4 - Create "patch0008" folder inside "DSS_HOME/repository/components/patches" folder and copy the osgi bundle you found in step 3 to that folder.
5 - Add "messageFormatter" and "messageBuilder" elements to the "DSS_HOME/repository/conf/axis2/axis2.xml" as you have pointed out in your step 3.
6 - Restart the server and invoke your service adding "Accept" request header to the request with new content type you mentioned in "axis2.xml", example would be "Accept:application/json/newformat".(You can find sample of how to do it in [2]) 

Thanks,


On Sun, Jul 13, 2014 at 1:45 PM, Yasas Karunarathna <[hidden email]> wrote:
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Shameera Rathnayaka-2
Hi Yasas,

did you try org.apache.axis2.json.gson.JsonBuilder and org.apache.axis2.json.gson.JsonFormatter ? What are the outputs you getting for above scenarios with that builder and formatter ?

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 4:50 PM, Yasas Karunarathna <[hidden email]> wrote:
@Ragith I checked out whole patch0007, couldn't build from the root(created some dependency problems with "dependencies/orbit/axis2-json" module... some relative path dependency pom files... i'm working on it nw ). So build only "dependencies/axis2/modules/json" module, copy the generated jar to the folder called 'patch0008' under wso2dss-3.2.1/repository/components/patches Not "dependencies/orbit/axis2-json".

@Shameera Thanks for asking that, problem is DSS json response is not uniform, so not convenient for the consumer. As an example, for a given select-query-operation there can be 3 types of responses. 

1) There are no records. 
{"Entries";""}

2) Only one record.
{"Entries":{"Entry":{"col1":"val1","col2":"val2"}}}

3) More than one records.
{"Entries":{"Entry":[{"col1":"val1","col2":"val2"}{"col1":"val3","col2":"val4"}]}}

When consuming the service there are few validation checks we have to do. No1 is partially OK, simple null check. But in No2 & No3, when we are getting the value of key "Entry" we have to check whether is it an array of objects or just an object, which i think is not convenient for the consumer. 

So I want to come up with a uniform type of response as below.

1) {"Entries":{"Entry":[]}}
2) {"Entries":{"Entry":[{"col1":"val1","col2":"val2"}]}}
3) {"Entries":{"Entry":[{"col1":"val1","col2":"val2"}{"col1":"val3","col2":"val4"}]}}

Any thoughts?


On Mon, Jul 14, 2014 at 4:28 PM, Rajith Vitharana <[hidden email]> wrote:
Hi,

I have tried with putting a jar file as a library to the repository/conf/lib folder. But it throws an exception when initializing axis2.xml file with class not found exception. Maybe axis2.xml get loaded before loading the classes in lib folder. Below is the exception which was thrown.

[2014-07-14 16:24:48,583] FATAL {org.wso2.carbon.core.init.CarbonServerManager} -  WSO2 Carbon initialization Failed
org.apache.axis2.AxisFault: Exception occured while loading the Axis configuration from /media/rajith/Office/Wso2/team/product/wso2dss-3.2.1/repository/conf/axis2/axis2.xml
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:190)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
at org.wso2.carbon.core.CarbonConfigurationContextFactory.createNewConfigurationContext(CarbonConfigurationContextFactory.java:65)
at org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:398)
at org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219)
at org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:77)
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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
at org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81)
at org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40)
at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1267)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1186)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1081)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.axis2.deployment.DeploymentException: org/apache/axis2/json/JSONMMyFormatter
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:775)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:236)
at org.wso2.carbon.core.CarbonAxisConfigurator.populateAxisConfiguration(CarbonAxisConfigurator.java:308)
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:188)
... 42 more
Caused by: java.lang.NoClassDefFoundError: org/apache/axis2/json/JSONMMyFormatter
at org.wso2.training.custom.json.JSONMyBuilder.<init>(JSONMyBuilder.java:35)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:310)
at org.apache.axis2.deployment.DescriptionBuilder.processMessageBuilders(DescriptionBuilder.java:230)
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:772)
... 45 more
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.JSONMMyFormatter
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:455)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 54 more


Thanks,


On Mon, Jul 14, 2014 at 3:17 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Rajith,

Why are you asking him to build the patches , can't he work on already released DSs pack, Here i am trying to understand which issue Yasas trying to address by implementing a new JSON builder and formatter, we have plenty of Builders and formatters for JSON :) . May i know the real use case and requirement ?

Thanks,
Shameera


On Mon, Jul 14, 2014 at 2:51 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas, 

Try out creating a simple jar and put it in lib folder as shameera mentioned in above reply. I have tried out the scenario I have explained to you, and it worked fine for me
As I mentioned, have you build the whole patch from the pom.xml inside patch0007 folder? 
and have you created "patch0008" folder and copied the jar(axis2-json-1.6.1-wso2v10.jar) inside "patch0007/dependencies/orbit/axis2-json/target" folder to the "patch0008" folder?

Thanks,



On Mon, Jul 14, 2014 at 1:50 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

For you ClassNotFoundException, check do your axis2-json jar has required classes, BTW as i mentioned in previous reply you don't need to do any code changes to axis2 jars in order to plug your custom builders.

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 1:36 PM, Yasas Karunarathna <[hidden email]> wrote:
Thank you for the quick responses. I checked in sources from both the locations

Separately build without any modifications, and put generated jar to patch8 folder. Once I restart the server following message shows in the console.

"Could not start: null(reference:file:../plugins/axis2-json_1.6.1.wso2v10.jar:15). It's state is uninstalled."

After that logs the following error.

"Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.gson.JSONMessageHandler"

Any work around?



On Sun, Jul 13, 2014 at 11:30 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

Assuming you are going to customize the JSON mapped convention (Standard Mapped Json support is their with Axis2),You don't need to do anything to axis2 jar.  Implement your new JSON builder and formatter, then create a new jar(or osgi bundle) using those new classes
 and copy that jar ( or osgi bundle) to <DSS_HOME>/repository/components/lib ( or <DSS_HOME>/repository/components/dropings) directory. Finally,  you need to configure your builder and formatter in axis2.xm configuration file (like your 3rd step).

Thanks,
Shameera.




On Sun, Jul 13, 2014 at 10:35 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas,

The points you have mentioned are correct, but there are small changes I would like to point out. Below are the steps you'll need to follow to achieve your goal.

1 - There is a patch release for the "axis2-json" so you'll need to check out the source from [1] instead of the svn location you have mentioned. (checkout the whole "patch0007" instead of json module, so that it'll be easy for you to build the source.)
2 - Add the classes you need to the source.
          You'll need to extend AbstractJSONMessageFormatter in your custom formatter class
          You'll need to extend AbstractJSONOMBuilder in you custom builder class
3 - Build the whole patch0007. Then go to "patch0007/dependencies/orbit/axis2-json/target" folder where you can find the osgi bundle created from "axis2-json" module.
4 - Create "patch0008" folder inside "DSS_HOME/repository/components/patches" folder and copy the osgi bundle you found in step 3 to that folder.
5 - Add "messageFormatter" and "messageBuilder" elements to the "DSS_HOME/repository/conf/axis2/axis2.xml" as you have pointed out in your step 3.
6 - Restart the server and invoke your service adding "Accept" request header to the request with new content type you mentioned in "axis2.xml", example would be "Accept:application/json/newformat".(You can find sample of how to do it in [2]) 

Thanks,


On Sun, Jul 13, 2014 at 1:45 PM, Yasas Karunarathna <[hidden email]> wrote:
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  +9471 922 1454


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Yasas Karunarathna
As i remember, above configuration is the default configuration in DSS 3.2.1, which is what I tried initially. But experienced it's not stable
(for some json conversions it's giving errors. http://stackoverflow.com/questions/24367280/error-in-getting-json-response-from-dss-server-error-while-writing-to-the-outp). Changing Formatter and Builder worked for me(Tried with different operations, and perfectly worked) 


On Mon, Jul 14, 2014 at 5:02 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

did you try org.apache.axis2.json.gson.JsonBuilder and org.apache.axis2.json.gson.JsonFormatter ? What are the outputs you getting for above scenarios with that builder and formatter ?

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 4:50 PM, Yasas Karunarathna <[hidden email]> wrote:
@Ragith I checked out whole patch0007, couldn't build from the root(created some dependency problems with "dependencies/orbit/axis2-json" module... some relative path dependency pom files... i'm working on it nw ). So build only "dependencies/axis2/modules/json" module, copy the generated jar to the folder called 'patch0008' under wso2dss-3.2.1/repository/components/patches Not "dependencies/orbit/axis2-json".

@Shameera Thanks for asking that, problem is DSS json response is not uniform, so not convenient for the consumer. As an example, for a given select-query-operation there can be 3 types of responses. 

1) There are no records. 
{"Entries";""}

2) Only one record.
{"Entries":{"Entry":{"col1":"val1","col2":"val2"}}}

3) More than one records.
{"Entries":{"Entry":[{"col1":"val1","col2":"val2"}{"col1":"val3","col2":"val4"}]}}

When consuming the service there are few validation checks we have to do. No1 is partially OK, simple null check. But in No2 & No3, when we are getting the value of key "Entry" we have to check whether is it an array of objects or just an object, which i think is not convenient for the consumer. 

So I want to come up with a uniform type of response as below.

1) {"Entries":{"Entry":[]}}
2) {"Entries":{"Entry":[{"col1":"val1","col2":"val2"}]}}
3) {"Entries":{"Entry":[{"col1":"val1","col2":"val2"}{"col1":"val3","col2":"val4"}]}}

Any thoughts?


On Mon, Jul 14, 2014 at 4:28 PM, Rajith Vitharana <[hidden email]> wrote:
Hi,

I have tried with putting a jar file as a library to the repository/conf/lib folder. But it throws an exception when initializing axis2.xml file with class not found exception. Maybe axis2.xml get loaded before loading the classes in lib folder. Below is the exception which was thrown.

[2014-07-14 16:24:48,583] FATAL {org.wso2.carbon.core.init.CarbonServerManager} -  WSO2 Carbon initialization Failed
org.apache.axis2.AxisFault: Exception occured while loading the Axis configuration from /media/rajith/Office/Wso2/team/product/wso2dss-3.2.1/repository/conf/axis2/axis2.xml
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:190)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
at org.wso2.carbon.core.CarbonConfigurationContextFactory.createNewConfigurationContext(CarbonConfigurationContextFactory.java:65)
at org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:398)
at org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219)
at org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:77)
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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
at org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81)
at org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40)
at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1267)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1186)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1081)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.axis2.deployment.DeploymentException: org/apache/axis2/json/JSONMMyFormatter
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:775)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:236)
at org.wso2.carbon.core.CarbonAxisConfigurator.populateAxisConfiguration(CarbonAxisConfigurator.java:308)
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:188)
... 42 more
Caused by: java.lang.NoClassDefFoundError: org/apache/axis2/json/JSONMMyFormatter
at org.wso2.training.custom.json.JSONMyBuilder.<init>(JSONMyBuilder.java:35)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:310)
at org.apache.axis2.deployment.DescriptionBuilder.processMessageBuilders(DescriptionBuilder.java:230)
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:772)
... 45 more
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.JSONMMyFormatter
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:455)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 54 more


Thanks,


On Mon, Jul 14, 2014 at 3:17 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Rajith,

Why are you asking him to build the patches , can't he work on already released DSs pack, Here i am trying to understand which issue Yasas trying to address by implementing a new JSON builder and formatter, we have plenty of Builders and formatters for JSON :) . May i know the real use case and requirement ?

Thanks,
Shameera


On Mon, Jul 14, 2014 at 2:51 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas, 

Try out creating a simple jar and put it in lib folder as shameera mentioned in above reply. I have tried out the scenario I have explained to you, and it worked fine for me
As I mentioned, have you build the whole patch from the pom.xml inside patch0007 folder? 
and have you created "patch0008" folder and copied the jar(axis2-json-1.6.1-wso2v10.jar) inside "patch0007/dependencies/orbit/axis2-json/target" folder to the "patch0008" folder?

Thanks,



On Mon, Jul 14, 2014 at 1:50 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

For you ClassNotFoundException, check do your axis2-json jar has required classes, BTW as i mentioned in previous reply you don't need to do any code changes to axis2 jars in order to plug your custom builders.

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 1:36 PM, Yasas Karunarathna <[hidden email]> wrote:
Thank you for the quick responses. I checked in sources from both the locations

Separately build without any modifications, and put generated jar to patch8 folder. Once I restart the server following message shows in the console.

"Could not start: null(reference:file:../plugins/axis2-json_1.6.1.wso2v10.jar:15). It's state is uninstalled."

After that logs the following error.

"Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.gson.JSONMessageHandler"

Any work around?



On Sun, Jul 13, 2014 at 11:30 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

Assuming you are going to customize the JSON mapped convention (Standard Mapped Json support is their with Axis2),You don't need to do anything to axis2 jar.  Implement your new JSON builder and formatter, then create a new jar(or osgi bundle) using those new classes
 and copy that jar ( or osgi bundle) to <DSS_HOME>/repository/components/lib ( or <DSS_HOME>/repository/components/dropings) directory. Finally,  you need to configure your builder and formatter in axis2.xm configuration file (like your 3rd step).

Thanks,
Shameera.




On Sun, Jul 13, 2014 at 10:35 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas,

The points you have mentioned are correct, but there are small changes I would like to point out. Below are the steps you'll need to follow to achieve your goal.

1 - There is a patch release for the "axis2-json" so you'll need to check out the source from [1] instead of the svn location you have mentioned. (checkout the whole "patch0007" instead of json module, so that it'll be easy for you to build the source.)
2 - Add the classes you need to the source.
          You'll need to extend AbstractJSONMessageFormatter in your custom formatter class
          You'll need to extend AbstractJSONOMBuilder in you custom builder class
3 - Build the whole patch0007. Then go to "patch0007/dependencies/orbit/axis2-json/target" folder where you can find the osgi bundle created from "axis2-json" module.
4 - Create "patch0008" folder inside "DSS_HOME/repository/components/patches" folder and copy the osgi bundle you found in step 3 to that folder.
5 - Add "messageFormatter" and "messageBuilder" elements to the "DSS_HOME/repository/conf/axis2/axis2.xml" as you have pointed out in your step 3.
6 - Restart the server and invoke your service adding "Accept" request header to the request with new content type you mentioned in "axis2.xml", example would be "Accept:application/json/newformat".(You can find sample of how to do it in [2]) 

Thanks,


On Sun, Jul 13, 2014 at 1:45 PM, Yasas Karunarathna <[hidden email]> wrote:
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Shameera Rathnayaka-2
Gson based Json implementation purely based on message schemas, As i remember we replaced this with previous Json builder and formatter issue came with json arrays with one value. Instead of writing an another build can't you improve above builders and formatter with the above feature?

According to the reply of author for the above SO questtoin, that is not an issue with JSON. 


On Mon, Jul 14, 2014 at 5:23 PM, Yasas Karunarathna <[hidden email]> wrote:
As i remember, above configuration is the default configuration in DSS 3.2.1, which is what I tried initially. But experienced it's not stable
(for some json conversions it's giving errors. http://stackoverflow.com/questions/24367280/error-in-getting-json-response-from-dss-server-error-while-writing-to-the-outp). Changing Formatter and Builder worked for me(Tried with different operations, and perfectly worked) 


On Mon, Jul 14, 2014 at 5:02 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

did you try org.apache.axis2.json.gson.JsonBuilder and org.apache.axis2.json.gson.JsonFormatter ? What are the outputs you getting for above scenarios with that builder and formatter ?

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 4:50 PM, Yasas Karunarathna <[hidden email]> wrote:
@Ragith I checked out whole patch0007, couldn't build from the root(created some dependency problems with "dependencies/orbit/axis2-json" module... some relative path dependency pom files... i'm working on it nw ). So build only "dependencies/axis2/modules/json" module, copy the generated jar to the folder called 'patch0008' under wso2dss-3.2.1/repository/components/patches Not "dependencies/orbit/axis2-json".

@Shameera Thanks for asking that, problem is DSS json response is not uniform, so not convenient for the consumer. As an example, for a given select-query-operation there can be 3 types of responses. 

1) There are no records. 
{"Entries";""}

2) Only one record.
{"Entries":{"Entry":{"col1":"val1","col2":"val2"}}}

3) More than one records.
{"Entries":{"Entry":[{"col1":"val1","col2":"val2"}{"col1":"val3","col2":"val4"}]}}

When consuming the service there are few validation checks we have to do. No1 is partially OK, simple null check. But in No2 & No3, when we are getting the value of key "Entry" we have to check whether is it an array of objects or just an object, which i think is not convenient for the consumer. 

So I want to come up with a uniform type of response as below.

1) {"Entries":{"Entry":[]}}
2) {"Entries":{"Entry":[{"col1":"val1","col2":"val2"}]}}
3) {"Entries":{"Entry":[{"col1":"val1","col2":"val2"}{"col1":"val3","col2":"val4"}]}}

Any thoughts?


On Mon, Jul 14, 2014 at 4:28 PM, Rajith Vitharana <[hidden email]> wrote:
Hi,

I have tried with putting a jar file as a library to the repository/conf/lib folder. But it throws an exception when initializing axis2.xml file with class not found exception. Maybe axis2.xml get loaded before loading the classes in lib folder. Below is the exception which was thrown.

[2014-07-14 16:24:48,583] FATAL {org.wso2.carbon.core.init.CarbonServerManager} -  WSO2 Carbon initialization Failed
org.apache.axis2.AxisFault: Exception occured while loading the Axis configuration from /media/rajith/Office/Wso2/team/product/wso2dss-3.2.1/repository/conf/axis2/axis2.xml
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:190)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
at org.wso2.carbon.core.CarbonConfigurationContextFactory.createNewConfigurationContext(CarbonConfigurationContextFactory.java:65)
at org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:398)
at org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219)
at org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:77)
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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
at org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81)
at org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40)
at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1267)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1186)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1081)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.axis2.deployment.DeploymentException: org/apache/axis2/json/JSONMMyFormatter
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:775)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:236)
at org.wso2.carbon.core.CarbonAxisConfigurator.populateAxisConfiguration(CarbonAxisConfigurator.java:308)
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:188)
... 42 more
Caused by: java.lang.NoClassDefFoundError: org/apache/axis2/json/JSONMMyFormatter
at org.wso2.training.custom.json.JSONMyBuilder.<init>(JSONMyBuilder.java:35)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:310)
at org.apache.axis2.deployment.DescriptionBuilder.processMessageBuilders(DescriptionBuilder.java:230)
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:772)
... 45 more
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.JSONMMyFormatter
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:455)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 54 more


Thanks,


On Mon, Jul 14, 2014 at 3:17 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Rajith,

Why are you asking him to build the patches , can't he work on already released DSs pack, Here i am trying to understand which issue Yasas trying to address by implementing a new JSON builder and formatter, we have plenty of Builders and formatters for JSON :) . May i know the real use case and requirement ?

Thanks,
Shameera


On Mon, Jul 14, 2014 at 2:51 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas, 

Try out creating a simple jar and put it in lib folder as shameera mentioned in above reply. I have tried out the scenario I have explained to you, and it worked fine for me
As I mentioned, have you build the whole patch from the pom.xml inside patch0007 folder? 
and have you created "patch0008" folder and copied the jar(axis2-json-1.6.1-wso2v10.jar) inside "patch0007/dependencies/orbit/axis2-json/target" folder to the "patch0008" folder?

Thanks,



On Mon, Jul 14, 2014 at 1:50 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

For you ClassNotFoundException, check do your axis2-json jar has required classes, BTW as i mentioned in previous reply you don't need to do any code changes to axis2 jars in order to plug your custom builders.

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 1:36 PM, Yasas Karunarathna <[hidden email]> wrote:
Thank you for the quick responses. I checked in sources from both the locations

Separately build without any modifications, and put generated jar to patch8 folder. Once I restart the server following message shows in the console.

"Could not start: null(reference:file:../plugins/axis2-json_1.6.1.wso2v10.jar:15). It's state is uninstalled."

After that logs the following error.

"Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.gson.JSONMessageHandler"

Any work around?



On Sun, Jul 13, 2014 at 11:30 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

Assuming you are going to customize the JSON mapped convention (Standard Mapped Json support is their with Axis2),You don't need to do anything to axis2 jar.  Implement your new JSON builder and formatter, then create a new jar(or osgi bundle) using those new classes
 and copy that jar ( or osgi bundle) to <DSS_HOME>/repository/components/lib ( or <DSS_HOME>/repository/components/dropings) directory. Finally,  you need to configure your builder and formatter in axis2.xm configuration file (like your 3rd step).

Thanks,
Shameera.




On Sun, Jul 13, 2014 at 10:35 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas,

The points you have mentioned are correct, but there are small changes I would like to point out. Below are the steps you'll need to follow to achieve your goal.

1 - There is a patch release for the "axis2-json" so you'll need to check out the source from [1] instead of the svn location you have mentioned. (checkout the whole "patch0007" instead of json module, so that it'll be easy for you to build the source.)
2 - Add the classes you need to the source.
          You'll need to extend AbstractJSONMessageFormatter in your custom formatter class
          You'll need to extend AbstractJSONOMBuilder in you custom builder class
3 - Build the whole patch0007. Then go to "patch0007/dependencies/orbit/axis2-json/target" folder where you can find the osgi bundle created from "axis2-json" module.
4 - Create "patch0008" folder inside "DSS_HOME/repository/components/patches" folder and copy the osgi bundle you found in step 3 to that folder.
5 - Add "messageFormatter" and "messageBuilder" elements to the "DSS_HOME/repository/conf/axis2/axis2.xml" as you have pointed out in your step 3.
6 - Restart the server and invoke your service adding "Accept" request header to the request with new content type you mentioned in "axis2.xml", example would be "Accept:application/json/newformat".(You can find sample of how to do it in [2]) 

Thanks,


On Sun, Jul 13, 2014 at 1:45 PM, Yasas Karunarathna <[hidden email]> wrote:
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  +9471 922 1454


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Yasas Karunarathna
Actually for me... gson implementation causing problems. I configured both gson and json formatter/builder in axis.xml as follows

<messageFormatter contentType="application/json"
                          class="org.apache.axis2.json.JSONMessageFormatter"/>
<messageFormatter contentType="application/json/gson"
                          class="org.apache.axis2.json.gson.JsonFormatter" />

<messageBuilder contentType="application/json"
                        class="org.apache.axis2.json.JSONOMBuilder"/>
<messageBuilder contentType="application/json/gson"
                        class="org.apache.axis2.json.gson.JsonBuilder" /> 

Then call the "customerAddress" service method in "samples/RDBMSSample" data service which comes with DSS3.2.1 by default using soapUI as follows

   <soapenv:Header/>
   <soapenv:Body>
      <rdb:customerAddress>
         <rdb:lastName>King</rdb:lastName>
         <rdb:firstName>Jean</rdb:firstName>
      </rdb:customerAddress>
   </soapenv:Body>
</soapenv:Envelope>

application/json returns

{"customer-addresses":{"customer-address":{"customer-number":"112","contact-last-name":"King","contact-first-name":"Jean","address-line1":"8489 Strong St.","address-line2":{"@nil":"true"},"city":"Las Vegas","state":"NV","postal-code":"83030","country":"USA"}}}

application/json/gson returns

{"Fault":{"faultcode":"soapenv:Server","faultstring":"Error while writing to the output stream using JsonWriter","detail":""}}

But when i called the service method "customersInBoston" in the same service it returns correct json response for both the headers.

This is the issue which made me drop the gson implementation.

Any thoughts? Am I doing something wrong?

On Mon, Jul 14, 2014 at 5:39 PM, Shameera Rathnayaka <[hidden email]> wrote:
Gson based Json implementation purely based on message schemas, As i remember we replaced this with previous Json builder and formatter issue came with json arrays with one value. Instead of writing an another build can't you improve above builders and formatter with the above feature?

According to the reply of author for the above SO questtoin, that is not an issue with JSON. 


On Mon, Jul 14, 2014 at 5:23 PM, Yasas Karunarathna <[hidden email]> wrote:
As i remember, above configuration is the default configuration in DSS 3.2.1, which is what I tried initially. But experienced it's not stable
(for some json conversions it's giving errors. http://stackoverflow.com/questions/24367280/error-in-getting-json-response-from-dss-server-error-while-writing-to-the-outp). Changing Formatter and Builder worked for me(Tried with different operations, and perfectly worked) 


On Mon, Jul 14, 2014 at 5:02 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

did you try org.apache.axis2.json.gson.JsonBuilder and org.apache.axis2.json.gson.JsonFormatter ? What are the outputs you getting for above scenarios with that builder and formatter ?

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 4:50 PM, Yasas Karunarathna <[hidden email]> wrote:
@Ragith I checked out whole patch0007, couldn't build from the root(created some dependency problems with "dependencies/orbit/axis2-json" module... some relative path dependency pom files... i'm working on it nw ). So build only "dependencies/axis2/modules/json" module, copy the generated jar to the folder called 'patch0008' under wso2dss-3.2.1/repository/components/patches Not "dependencies/orbit/axis2-json".

@Shameera Thanks for asking that, problem is DSS json response is not uniform, so not convenient for the consumer. As an example, for a given select-query-operation there can be 3 types of responses. 

1) There are no records. 
{"Entries";""}

2) Only one record.
{"Entries":{"Entry":{"col1":"val1","col2":"val2"}}}

3) More than one records.
{"Entries":{"Entry":[{"col1":"val1","col2":"val2"}{"col1":"val3","col2":"val4"}]}}

When consuming the service there are few validation checks we have to do. No1 is partially OK, simple null check. But in No2 & No3, when we are getting the value of key "Entry" we have to check whether is it an array of objects or just an object, which i think is not convenient for the consumer. 

So I want to come up with a uniform type of response as below.

1) {"Entries":{"Entry":[]}}
2) {"Entries":{"Entry":[{"col1":"val1","col2":"val2"}]}}
3) {"Entries":{"Entry":[{"col1":"val1","col2":"val2"}{"col1":"val3","col2":"val4"}]}}

Any thoughts?


On Mon, Jul 14, 2014 at 4:28 PM, Rajith Vitharana <[hidden email]> wrote:
Hi,

I have tried with putting a jar file as a library to the repository/conf/lib folder. But it throws an exception when initializing axis2.xml file with class not found exception. Maybe axis2.xml get loaded before loading the classes in lib folder. Below is the exception which was thrown.

[2014-07-14 16:24:48,583] FATAL {org.wso2.carbon.core.init.CarbonServerManager} -  WSO2 Carbon initialization Failed
org.apache.axis2.AxisFault: Exception occured while loading the Axis configuration from /media/rajith/Office/Wso2/team/product/wso2dss-3.2.1/repository/conf/axis2/axis2.xml
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:190)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
at org.wso2.carbon.core.CarbonConfigurationContextFactory.createNewConfigurationContext(CarbonConfigurationContextFactory.java:65)
at org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:398)
at org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219)
at org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:77)
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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
at org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81)
at org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40)
at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1267)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1186)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1081)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.axis2.deployment.DeploymentException: org/apache/axis2/json/JSONMMyFormatter
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:775)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:236)
at org.wso2.carbon.core.CarbonAxisConfigurator.populateAxisConfiguration(CarbonAxisConfigurator.java:308)
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:188)
... 42 more
Caused by: java.lang.NoClassDefFoundError: org/apache/axis2/json/JSONMMyFormatter
at org.wso2.training.custom.json.JSONMyBuilder.<init>(JSONMyBuilder.java:35)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:310)
at org.apache.axis2.deployment.DescriptionBuilder.processMessageBuilders(DescriptionBuilder.java:230)
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:772)
... 45 more
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.JSONMMyFormatter
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:455)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 54 more


Thanks,


On Mon, Jul 14, 2014 at 3:17 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Rajith,

Why are you asking him to build the patches , can't he work on already released DSs pack, Here i am trying to understand which issue Yasas trying to address by implementing a new JSON builder and formatter, we have plenty of Builders and formatters for JSON :) . May i know the real use case and requirement ?

Thanks,
Shameera


On Mon, Jul 14, 2014 at 2:51 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas, 

Try out creating a simple jar and put it in lib folder as shameera mentioned in above reply. I have tried out the scenario I have explained to you, and it worked fine for me
As I mentioned, have you build the whole patch from the pom.xml inside patch0007 folder? 
and have you created "patch0008" folder and copied the jar(axis2-json-1.6.1-wso2v10.jar) inside "patch0007/dependencies/orbit/axis2-json/target" folder to the "patch0008" folder?

Thanks,



On Mon, Jul 14, 2014 at 1:50 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

For you ClassNotFoundException, check do your axis2-json jar has required classes, BTW as i mentioned in previous reply you don't need to do any code changes to axis2 jars in order to plug your custom builders.

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 1:36 PM, Yasas Karunarathna <[hidden email]> wrote:
Thank you for the quick responses. I checked in sources from both the locations

Separately build without any modifications, and put generated jar to patch8 folder. Once I restart the server following message shows in the console.

"Could not start: null(reference:file:../plugins/axis2-json_1.6.1.wso2v10.jar:15). It's state is uninstalled."

After that logs the following error.

"Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.gson.JSONMessageHandler"

Any work around?



On Sun, Jul 13, 2014 at 11:30 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

Assuming you are going to customize the JSON mapped convention (Standard Mapped Json support is their with Axis2),You don't need to do anything to axis2 jar.  Implement your new JSON builder and formatter, then create a new jar(or osgi bundle) using those new classes
 and copy that jar ( or osgi bundle) to <DSS_HOME>/repository/components/lib ( or <DSS_HOME>/repository/components/dropings) directory. Finally,  you need to configure your builder and formatter in axis2.xm configuration file (like your 3rd step).

Thanks,
Shameera.




On Sun, Jul 13, 2014 at 10:35 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas,

The points you have mentioned are correct, but there are small changes I would like to point out. Below are the steps you'll need to follow to achieve your goal.

1 - There is a patch release for the "axis2-json" so you'll need to check out the source from [1] instead of the svn location you have mentioned. (checkout the whole "patch0007" instead of json module, so that it'll be easy for you to build the source.)
2 - Add the classes you need to the source.
          You'll need to extend AbstractJSONMessageFormatter in your custom formatter class
          You'll need to extend AbstractJSONOMBuilder in you custom builder class
3 - Build the whole patch0007. Then go to "patch0007/dependencies/orbit/axis2-json/target" folder where you can find the osgi bundle created from "axis2-json" module.
4 - Create "patch0008" folder inside "DSS_HOME/repository/components/patches" folder and copy the osgi bundle you found in step 3 to that folder.
5 - Add "messageFormatter" and "messageBuilder" elements to the "DSS_HOME/repository/conf/axis2/axis2.xml" as you have pointed out in your step 3.
6 - Restart the server and invoke your service adding "Accept" request header to the request with new content type you mentioned in "axis2.xml", example would be "Accept:application/json/newformat".(You can find sample of how to do it in [2]) 

Thanks,


On Sun, Jul 13, 2014 at 1:45 PM, Yasas Karunarathna <[hidden email]> wrote:
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Anjana Fernando-2
Rajith, with the help of Shameera, check what is the issue with the gson based approach, as we are doing a bug fix release soon, we can fix any issues that is there.

Cheers,
Anjana.


On Mon, Jul 14, 2014 at 7:03 PM, Yasas Karunarathna <[hidden email]> wrote:
Actually for me... gson implementation causing problems. I configured both gson and json formatter/builder in axis.xml as follows

<messageFormatter contentType="application/json"
                          class="org.apache.axis2.json.JSONMessageFormatter"/>
<messageFormatter contentType="application/json/gson"
                          class="org.apache.axis2.json.gson.JsonFormatter" />

<messageBuilder contentType="application/json"
                        class="org.apache.axis2.json.JSONOMBuilder"/>
<messageBuilder contentType="application/json/gson"
                        class="org.apache.axis2.json.gson.JsonBuilder" /> 

Then call the "customerAddress" service method in "samples/RDBMSSample" data service which comes with DSS3.2.1 by default using soapUI as follows

   <soapenv:Header/>
   <soapenv:Body>
      <rdb:customerAddress>
         <rdb:lastName>King</rdb:lastName>
         <rdb:firstName>Jean</rdb:firstName>
      </rdb:customerAddress>
   </soapenv:Body>
</soapenv:Envelope>

application/json returns

{"customer-addresses":{"customer-address":{"customer-number":"112","contact-last-name":"King","contact-first-name":"Jean","address-line1":"8489 Strong St.","address-line2":{"@nil":"true"},"city":"Las Vegas","state":"NV","postal-code":"83030","country":"USA"}}}

application/json/gson returns

{"Fault":{"faultcode":"soapenv:Server","faultstring":"Error while writing to the output stream using JsonWriter","detail":""}}

But when i called the service method "customersInBoston" in the same service it returns correct json response for both the headers.

This is the issue which made me drop the gson implementation.

Any thoughts? Am I doing something wrong?


On Mon, Jul 14, 2014 at 5:39 PM, Shameera Rathnayaka <[hidden email]> wrote:
Gson based Json implementation purely based on message schemas, As i remember we replaced this with previous Json builder and formatter issue came with json arrays with one value. Instead of writing an another build can't you improve above builders and formatter with the above feature?

According to the reply of author for the above SO questtoin, that is not an issue with JSON. 


On Mon, Jul 14, 2014 at 5:23 PM, Yasas Karunarathna <[hidden email]> wrote:
As i remember, above configuration is the default configuration in DSS 3.2.1, which is what I tried initially. But experienced it's not stable
(for some json conversions it's giving errors. http://stackoverflow.com/questions/24367280/error-in-getting-json-response-from-dss-server-error-while-writing-to-the-outp). Changing Formatter and Builder worked for me(Tried with different operations, and perfectly worked) 


On Mon, Jul 14, 2014 at 5:02 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

did you try org.apache.axis2.json.gson.JsonBuilder and org.apache.axis2.json.gson.JsonFormatter ? What are the outputs you getting for above scenarios with that builder and formatter ?

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 4:50 PM, Yasas Karunarathna <[hidden email]> wrote:
@Ragith I checked out whole patch0007, couldn't build from the root(created some dependency problems with "dependencies/orbit/axis2-json" module... some relative path dependency pom files... i'm working on it nw ). So build only "dependencies/axis2/modules/json" module, copy the generated jar to the folder called 'patch0008' under wso2dss-3.2.1/repository/components/patches Not "dependencies/orbit/axis2-json".

@Shameera Thanks for asking that, problem is DSS json response is not uniform, so not convenient for the consumer. As an example, for a given select-query-operation there can be 3 types of responses. 

1) There are no records. 
{"Entries";""}

2) Only one record.
{"Entries":{"Entry":{"col1":"val1","col2":"val2"}}}

3) More than one records.
{"Entries":{"Entry":[{"col1":"val1","col2":"val2"}{"col1":"val3","col2":"val4"}]}}

When consuming the service there are few validation checks we have to do. No1 is partially OK, simple null check. But in No2 & No3, when we are getting the value of key "Entry" we have to check whether is it an array of objects or just an object, which i think is not convenient for the consumer. 

So I want to come up with a uniform type of response as below.

1) {"Entries":{"Entry":[]}}
2) {"Entries":{"Entry":[{"col1":"val1","col2":"val2"}]}}
3) {"Entries":{"Entry":[{"col1":"val1","col2":"val2"}{"col1":"val3","col2":"val4"}]}}

Any thoughts?


On Mon, Jul 14, 2014 at 4:28 PM, Rajith Vitharana <[hidden email]> wrote:
Hi,

I have tried with putting a jar file as a library to the repository/conf/lib folder. But it throws an exception when initializing axis2.xml file with class not found exception. Maybe axis2.xml get loaded before loading the classes in lib folder. Below is the exception which was thrown.

[2014-07-14 16:24:48,583] FATAL {org.wso2.carbon.core.init.CarbonServerManager} -  WSO2 Carbon initialization Failed
org.apache.axis2.AxisFault: Exception occured while loading the Axis configuration from /media/rajith/Office/Wso2/team/product/wso2dss-3.2.1/repository/conf/axis2/axis2.xml
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:190)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
at org.wso2.carbon.core.CarbonConfigurationContextFactory.createNewConfigurationContext(CarbonConfigurationContextFactory.java:65)
at org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:398)
at org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219)
at org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:77)
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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
at org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81)
at org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40)
at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1267)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1186)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1081)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.axis2.deployment.DeploymentException: org/apache/axis2/json/JSONMMyFormatter
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:775)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:236)
at org.wso2.carbon.core.CarbonAxisConfigurator.populateAxisConfiguration(CarbonAxisConfigurator.java:308)
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:188)
... 42 more
Caused by: java.lang.NoClassDefFoundError: org/apache/axis2/json/JSONMMyFormatter
at org.wso2.training.custom.json.JSONMyBuilder.<init>(JSONMyBuilder.java:35)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:310)
at org.apache.axis2.deployment.DescriptionBuilder.processMessageBuilders(DescriptionBuilder.java:230)
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:772)
... 45 more
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.JSONMMyFormatter
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:455)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 54 more


Thanks,


On Mon, Jul 14, 2014 at 3:17 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Rajith,

Why are you asking him to build the patches , can't he work on already released DSs pack, Here i am trying to understand which issue Yasas trying to address by implementing a new JSON builder and formatter, we have plenty of Builders and formatters for JSON :) . May i know the real use case and requirement ?

Thanks,
Shameera


On Mon, Jul 14, 2014 at 2:51 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas, 

Try out creating a simple jar and put it in lib folder as shameera mentioned in above reply. I have tried out the scenario I have explained to you, and it worked fine for me
As I mentioned, have you build the whole patch from the pom.xml inside patch0007 folder? 
and have you created "patch0008" folder and copied the jar(axis2-json-1.6.1-wso2v10.jar) inside "patch0007/dependencies/orbit/axis2-json/target" folder to the "patch0008" folder?

Thanks,



On Mon, Jul 14, 2014 at 1:50 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

For you ClassNotFoundException, check do your axis2-json jar has required classes, BTW as i mentioned in previous reply you don't need to do any code changes to axis2 jars in order to plug your custom builders.

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 1:36 PM, Yasas Karunarathna <[hidden email]> wrote:
Thank you for the quick responses. I checked in sources from both the locations

Separately build without any modifications, and put generated jar to patch8 folder. Once I restart the server following message shows in the console.

"Could not start: null(reference:file:../plugins/axis2-json_1.6.1.wso2v10.jar:15). It's state is uninstalled."

After that logs the following error.

"Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.gson.JSONMessageHandler"

Any work around?



On Sun, Jul 13, 2014 at 11:30 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

Assuming you are going to customize the JSON mapped convention (Standard Mapped Json support is their with Axis2),You don't need to do anything to axis2 jar.  Implement your new JSON builder and formatter, then create a new jar(or osgi bundle) using those new classes
 and copy that jar ( or osgi bundle) to <DSS_HOME>/repository/components/lib ( or <DSS_HOME>/repository/components/dropings) directory. Finally,  you need to configure your builder and formatter in axis2.xm configuration file (like your 3rd step).

Thanks,
Shameera.




On Sun, Jul 13, 2014 at 10:35 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas,

The points you have mentioned are correct, but there are small changes I would like to point out. Below are the steps you'll need to follow to achieve your goal.

1 - There is a patch release for the "axis2-json" so you'll need to check out the source from [1] instead of the svn location you have mentioned. (checkout the whole "patch0007" instead of json module, so that it'll be easy for you to build the source.)
2 - Add the classes you need to the source.
          You'll need to extend AbstractJSONMessageFormatter in your custom formatter class
          You'll need to extend AbstractJSONOMBuilder in you custom builder class
3 - Build the whole patch0007. Then go to "patch0007/dependencies/orbit/axis2-json/target" folder where you can find the osgi bundle created from "axis2-json" module.
4 - Create "patch0008" folder inside "DSS_HOME/repository/components/patches" folder and copy the osgi bundle you found in step 3 to that folder.
5 - Add "messageFormatter" and "messageBuilder" elements to the "DSS_HOME/repository/conf/axis2/axis2.xml" as you have pointed out in your step 3.
6 - Restart the server and invoke your service adding "Accept" request header to the request with new content type you mentioned in "axis2.xml", example would be "Accept:application/json/newformat".(You can find sample of how to do it in [2]) 

Thanks,


On Sun, Jul 13, 2014 at 1:45 PM, Yasas Karunarathna <[hidden email]> wrote:
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Anjana Fernando
Senior Technical Lead
WSO2 Inc. | http://wso2.com
lean . enterprise . middleware

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: [Dev] [DSS][AXIS2][AXIS2-JSON] Writing a new XML to JSON conversion

Shameera Rathnayaka-2
In reply to this post by Yasas Karunarathna
Hi Yasas,

Did you debug and check what went wrong with gson implementations? This might be a minor bug fix for the gson implementation, we already faced few issue when we integrate it to DSS, but doing fixes we could overcome those issues. IMO instead of writing another builder and formatter fix the issue and use the current implementation is best option here.  This gson implementation is not mature as normal json support in Axis2.

Thanks,
Shameera.




On Mon, Jul 14, 2014 at 7:03 PM, Yasas Karunarathna <[hidden email]> wrote:
Actually for me... gson implementation causing problems. I configured both gson and json formatter/builder in axis.xml as follows

<messageFormatter contentType="application/json"
                          class="org.apache.axis2.json.JSONMessageFormatter"/>
<messageFormatter contentType="application/json/gson"
                          class="org.apache.axis2.json.gson.JsonFormatter" />

<messageBuilder contentType="application/json"
                        class="org.apache.axis2.json.JSONOMBuilder"/>
<messageBuilder contentType="application/json/gson"
                        class="org.apache.axis2.json.gson.JsonBuilder" /> 

Then call the "customerAddress" service method in "samples/RDBMSSample" data service which comes with DSS3.2.1 by default using soapUI as follows

   <soapenv:Header/>
   <soapenv:Body>
      <rdb:customerAddress>
         <rdb:lastName>King</rdb:lastName>
         <rdb:firstName>Jean</rdb:firstName>
      </rdb:customerAddress>
   </soapenv:Body>
</soapenv:Envelope>

application/json returns

{"customer-addresses":{"customer-address":{"customer-number":"112","contact-last-name":"King","contact-first-name":"Jean","address-line1":"8489 Strong St.","address-line2":{"@nil":"true"},"city":"Las Vegas","state":"NV","postal-code":"83030","country":"USA"}}}

application/json/gson returns

{"Fault":{"faultcode":"soapenv:Server","faultstring":"Error while writing to the output stream using JsonWriter","detail":""}}

But when i called the service method "customersInBoston" in the same service it returns correct json response for both the headers.

This is the issue which made me drop the gson implementation.

Any thoughts? Am I doing something wrong?


On Mon, Jul 14, 2014 at 5:39 PM, Shameera Rathnayaka <[hidden email]> wrote:
Gson based Json implementation purely based on message schemas, As i remember we replaced this with previous Json builder and formatter issue came with json arrays with one value. Instead of writing an another build can't you improve above builders and formatter with the above feature?

According to the reply of author for the above SO questtoin, that is not an issue with JSON. 


On Mon, Jul 14, 2014 at 5:23 PM, Yasas Karunarathna <[hidden email]> wrote:
As i remember, above configuration is the default configuration in DSS 3.2.1, which is what I tried initially. But experienced it's not stable
(for some json conversions it's giving errors. http://stackoverflow.com/questions/24367280/error-in-getting-json-response-from-dss-server-error-while-writing-to-the-outp). Changing Formatter and Builder worked for me(Tried with different operations, and perfectly worked) 


On Mon, Jul 14, 2014 at 5:02 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

did you try org.apache.axis2.json.gson.JsonBuilder and org.apache.axis2.json.gson.JsonFormatter ? What are the outputs you getting for above scenarios with that builder and formatter ?

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 4:50 PM, Yasas Karunarathna <[hidden email]> wrote:
@Ragith I checked out whole patch0007, couldn't build from the root(created some dependency problems with "dependencies/orbit/axis2-json" module... some relative path dependency pom files... i'm working on it nw ). So build only "dependencies/axis2/modules/json" module, copy the generated jar to the folder called 'patch0008' under wso2dss-3.2.1/repository/components/patches Not "dependencies/orbit/axis2-json".

@Shameera Thanks for asking that, problem is DSS json response is not uniform, so not convenient for the consumer. As an example, for a given select-query-operation there can be 3 types of responses. 

1) There are no records. 
{"Entries";""}

2) Only one record.
{"Entries":{"Entry":{"col1":"val1","col2":"val2"}}}

3) More than one records.
{"Entries":{"Entry":[{"col1":"val1","col2":"val2"}{"col1":"val3","col2":"val4"}]}}

When consuming the service there are few validation checks we have to do. No1 is partially OK, simple null check. But in No2 & No3, when we are getting the value of key "Entry" we have to check whether is it an array of objects or just an object, which i think is not convenient for the consumer. 

So I want to come up with a uniform type of response as below.

1) {"Entries":{"Entry":[]}}
2) {"Entries":{"Entry":[{"col1":"val1","col2":"val2"}]}}
3) {"Entries":{"Entry":[{"col1":"val1","col2":"val2"}{"col1":"val3","col2":"val4"}]}}

Any thoughts?


On Mon, Jul 14, 2014 at 4:28 PM, Rajith Vitharana <[hidden email]> wrote:
Hi,

I have tried with putting a jar file as a library to the repository/conf/lib folder. But it throws an exception when initializing axis2.xml file with class not found exception. Maybe axis2.xml get loaded before loading the classes in lib folder. Below is the exception which was thrown.

[2014-07-14 16:24:48,583] FATAL {org.wso2.carbon.core.init.CarbonServerManager} -  WSO2 Carbon initialization Failed
org.apache.axis2.AxisFault: Exception occured while loading the Axis configuration from /media/rajith/Office/Wso2/team/product/wso2dss-3.2.1/repository/conf/axis2/axis2.xml
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:190)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:64)
at org.wso2.carbon.core.CarbonConfigurationContextFactory.createNewConfigurationContext(CarbonConfigurationContextFactory.java:65)
at org.wso2.carbon.core.init.CarbonServerManager.initializeCarbon(CarbonServerManager.java:398)
at org.wso2.carbon.core.init.CarbonServerManager.start(CarbonServerManager.java:219)
at org.wso2.carbon.core.internal.CarbonCoreServiceComponent.activate(CarbonCoreServiceComponent.java:77)
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.eclipse.equinox.internal.ds.model.ServiceComponent.activate(ServiceComponent.java:260)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.activate(ServiceComponentProp.java:146)
at org.eclipse.equinox.internal.ds.model.ServiceComponentProp.build(ServiceComponentProp.java:347)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponent(InstanceProcess.java:620)
at org.eclipse.equinox.internal.ds.InstanceProcess.buildComponents(InstanceProcess.java:197)
at org.eclipse.equinox.internal.ds.Resolver.getEligible(Resolver.java:343)
at org.eclipse.equinox.internal.ds.SCRManager.serviceChanged(SCRManager.java:222)
at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:107)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
at org.eclipse.equinox.http.servlet.internal.Activator.registerHttpService(Activator.java:81)
at org.eclipse.equinox.http.servlet.internal.Activator.addProxyServlet(Activator.java:60)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.init(ProxyServlet.java:40)
at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.init(DelegationServlet.java:38)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1267)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1186)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1081)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.axis2.deployment.DeploymentException: org/apache/axis2/json/JSONMMyFormatter
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:775)
at org.apache.axis2.deployment.AxisConfigBuilder.populateConfig(AxisConfigBuilder.java:236)
at org.wso2.carbon.core.CarbonAxisConfigurator.populateAxisConfiguration(CarbonAxisConfigurator.java:308)
at org.wso2.carbon.core.CarbonAxisConfigurator.getAxisConfiguration(CarbonAxisConfigurator.java:188)
... 42 more
Caused by: java.lang.NoClassDefFoundError: org/apache/axis2/json/JSONMMyFormatter
at org.wso2.training.custom.json.JSONMyBuilder.<init>(JSONMyBuilder.java:35)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:357)
at java.lang.Class.newInstance(Class.java:310)
at org.apache.axis2.deployment.DescriptionBuilder.processMessageBuilders(DescriptionBuilder.java:230)
at org.apache.axis2.deployment.AxisConfigBuilder.processMessageBuilders(AxisConfigBuilder.java:772)
... 45 more
Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.JSONMMyFormatter
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:455)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 54 more


Thanks,


On Mon, Jul 14, 2014 at 3:17 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Rajith,

Why are you asking him to build the patches , can't he work on already released DSs pack, Here i am trying to understand which issue Yasas trying to address by implementing a new JSON builder and formatter, we have plenty of Builders and formatters for JSON :) . May i know the real use case and requirement ?

Thanks,
Shameera


On Mon, Jul 14, 2014 at 2:51 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas, 

Try out creating a simple jar and put it in lib folder as shameera mentioned in above reply. I have tried out the scenario I have explained to you, and it worked fine for me
As I mentioned, have you build the whole patch from the pom.xml inside patch0007 folder? 
and have you created "patch0008" folder and copied the jar(axis2-json-1.6.1-wso2v10.jar) inside "patch0007/dependencies/orbit/axis2-json/target" folder to the "patch0008" folder?

Thanks,



On Mon, Jul 14, 2014 at 1:50 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

For you ClassNotFoundException, check do your axis2-json jar has required classes, BTW as i mentioned in previous reply you don't need to do any code changes to axis2 jars in order to plug your custom builders.

Thanks,
Shameera.


On Mon, Jul 14, 2014 at 1:36 PM, Yasas Karunarathna <[hidden email]> wrote:
Thank you for the quick responses. I checked in sources from both the locations

Separately build without any modifications, and put generated jar to patch8 folder. Once I restart the server following message shows in the console.

"Could not start: null(reference:file:../plugins/axis2-json_1.6.1.wso2v10.jar:15). It's state is uninstalled."

After that logs the following error.

"Caused by: java.lang.ClassNotFoundException: org.apache.axis2.json.gson.JSONMessageHandler"

Any work around?



On Sun, Jul 13, 2014 at 11:30 PM, Shameera Rathnayaka <[hidden email]> wrote:
Hi Yasas,

Assuming you are going to customize the JSON mapped convention (Standard Mapped Json support is their with Axis2),You don't need to do anything to axis2 jar.  Implement your new JSON builder and formatter, then create a new jar(or osgi bundle) using those new classes
 and copy that jar ( or osgi bundle) to <DSS_HOME>/repository/components/lib ( or <DSS_HOME>/repository/components/dropings) directory. Finally,  you need to configure your builder and formatter in axis2.xm configuration file (like your 3rd step).

Thanks,
Shameera.




On Sun, Jul 13, 2014 at 10:35 PM, Rajith Vitharana <[hidden email]> wrote:
Hi Yasas,

The points you have mentioned are correct, but there are small changes I would like to point out. Below are the steps you'll need to follow to achieve your goal.

1 - There is a patch release for the "axis2-json" so you'll need to check out the source from [1] instead of the svn location you have mentioned. (checkout the whole "patch0007" instead of json module, so that it'll be easy for you to build the source.)
2 - Add the classes you need to the source.
          You'll need to extend AbstractJSONMessageFormatter in your custom formatter class
          You'll need to extend AbstractJSONOMBuilder in you custom builder class
3 - Build the whole patch0007. Then go to "patch0007/dependencies/orbit/axis2-json/target" folder where you can find the osgi bundle created from "axis2-json" module.
4 - Create "patch0008" folder inside "DSS_HOME/repository/components/patches" folder and copy the osgi bundle you found in step 3 to that folder.
5 - Add "messageFormatter" and "messageBuilder" elements to the "DSS_HOME/repository/conf/axis2/axis2.xml" as you have pointed out in your step 3.
6 - Restart the server and invoke your service adding "Accept" request header to the request with new content type you mentioned in "axis2.xml", example would be "Accept:application/json/newformat".(You can find sample of how to do it in [2]) 

Thanks,


On Sun, Jul 13, 2014 at 1:45 PM, Yasas Karunarathna <[hidden email]> wrote:
Hi there,

I want to do a small change to the json response returned from DSS 3.2.1. I'm using JSONMessageFormatter & JSONOMBuilder in org.apache.axis2.json package.(not gson implementations)
My requirements are as follows

1) Implement new JSONMessageFormatter, JSONOMBuilder etc. 
And additional method accepting the Mapped json response and format it accordingly, call it at the end of mapped json conversion.
2) Build axis2-json-1.6.1-wso2v10.jar adding new classes.

3) State new Formatter and Builder in axis2.xml & call it with new header
<messageFormatter contentType="application/json/newformat"
                          class="org.apache.axis2.json.newJSONMessageFormatter"/>
 
<messageBuilder contentType="application/json/newformat"
                        class="org.apache.axis2.json.newJSONOMBuilder"/>
Can anybody advice me on achieving the above requirements?

-- 

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/

_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev




--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--
Rajith Vitharana

Software Engineer,
WSO2 Inc. : wso2.com
Mobile : +94715883223
Blog : http://lankavitharana.blogspot.com/



--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  <a href="tel:%2B9471%20922%201454" value="+94719221454" target="_blank">+9471 922 1454




--

Thanks

 

Yasas Karunarathna

yasasblog.wordpress.com



--
Software Engineer - WSO2 Inc.
phone:  +9471 922 1454


_______________________________________________
Dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/dev