[Dev] JMS Synchronous Invocations : Dual Channel HTTP-to-JMS - WSO2 ESB + WSO2 Message Broker

2015-02-07 Thread Hasitha Hiranya
Hi,

Tested and wrote an blog post on $Subject [1]. Used MB 3.0.0 Milestone 2
pack.
Noted following.

1. I saw *for each message* it creates a subscription to queue indicated by
reply destination. Is this acceptable? In a loaded scenario this will not
work.


2. Sometimes MB gives following errors (intermittent).

[2015-02-08 09:39:00,094]  INFO
{org.wso2.andes.subscription.SubscriptionStore} -  New Local Subscription
Added [SMSReceiveNotificationStore]ID=4@NODESUNRISE-LINUX/
127.0.1.1/D=true/X=false/O=null/E=amq.direct/ET=org.wso2.andes.server.exchange.DirectExchange$1@72fa4b2a/EUD=0/S=true
[2015-02-08 09:39:02,185] ERROR
{org.wso2.andes.server.cassandra.MessageFlusher} -  Error occurred while
sending messages to subscribers from buffer
java.lang.NullPointerException
at
org.wso2.andes.server.cassandra.OnflightMessageTracker.getNotAckedMessageCount(OnflightMessageTracker.java:728)
at
org.wso2.andes.server.cassandra.MessageFlusher.isThisSubscriptionHasRoom(MessageFlusher.java:364)
at
org.wso2.andes.server.cassandra.MessageFlusher.sendMessagesToSubscriptions(MessageFlusher.java:441)
at
org.wso2.andes.server.cassandra.MessageFlusher.sendMessagesInBuffer(MessageFlusher.java:335)
at
org.wso2.andes.server.cassandra.MessageFlusher.sendMessageToFlusher(MessageFlusher.java:297)
at
org.wso2.andes.server.slot.SlotDeliveryWorker.run(SlotDeliveryWorker.java:229)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
[2015-02-08 09:39:07,188] FATAL
{org.wso2.andes.server.cassandra.MessageFlusher} -  Error running Cassandra
Message FlusherError occurred while sending messages to subscribers from
message bufferjava.lang.NullPointerException
org.wso2.andes.kernel.AndesException: Error occurred while sending messages
to subscribers from message bufferjava.lang.NullPointerException
at
org.wso2.andes.server.cassandra.MessageFlusher.sendMessagesInBuffer(MessageFlusher.java:339)
at
org.wso2.andes.server.cassandra.MessageFlusher.sendMessageToFlusher(MessageFlusher.java:297)
at
org.wso2.andes.server.slot.SlotDeliveryWorker.run(SlotDeliveryWorker.java:229)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
[2015-02-08 09:39:07,224]  INFO
{org.wso2.andes.subscription.SubscriptionStore} -  Local Subscription
Removed [SMSReceiveNotificationStore]ID=4@NODESUNRISE-LINUX/
127.0.1.1/D=true/X=false/O=null/E=amq.direct/ET=org.wso2.andes.server.exchange.DirectExchange$1@72fa4b2a/EUD=0/S=false



[1].
http://abeykoon.blogspot.com/2015/02/jms-synchronous-invocations-dual.html



-- 
*Hasitha Abeykoon*
Senior Software Engineer; WSO2, Inc.; http://wso2.com
*cell:* *+94 719363063*
*blog: **abeykoon.blogspot.com* 
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Converting JSON to SOAP and vise versa in ESB

2015-02-07 Thread Harsha Kumara
Hi Uvindra,

I checked with this with esb 4.8.1 fresh pack. It worked fine with below
config. Please find my api config and response.

 
  
 

   





   
  http://www.w3schools.com/webservices/";>
 $1
  
   
   
  
   


   
  http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit
"
   format="soap11"/>
   

 
 

   


var temp =
mc.getPayloadXML()..*::CelsiusToFahrenheitResult.toString();
mc.setPayloadJSON({"Temp" : {"Faran" : temp}});

 
  
   

curl -i -POST -H 'Accept: application/json' -H
'Content-Type:application/json' -d '{"celsius":12}'
http://192.168.1.4:8280/temp

HTTP/1.1 200 OK
X-AspNet-Version: 4.0.30319
Content-Type: application/json
X-Powered-By: ASP.NET
Cache-Control: private, max-age=0,public
Date: Sun, 08 Feb 2015 03:48:50 GMT
Server: WSO2-PassThrough-HTTP
Transfer-Encoding: chunked

{"Temp":{"Faran":"53.6"}}

Thanks,
Harsha

On Sat, Feb 7, 2015 at 9:55 PM, Uvindra Dias Jayasinha 
wrote:

> With wire logs on the issue becomes a bit more clear,
>
>
>
>
>
> 21:34:56,129 > "POST /temp HTTP/1.1[\r][\n]"
> 21:34:56,130 > "User-Agent: curl/7.35.0[\r][\n]"
> 21:34:56,130 > "Host: 10.0.3.1:8281[\r][\n]"
> 21:34:56,130 > "Accept: application/json[\r][\n]"
> 21:34:56,130 > "Content-Type:application/json[\r][\n]"
> 21:34:56,130 > "Content-Length: 14[\r][\n]"
> 21:34:56,130 > "[\r][\n]"
> 21:34:56,131 > "{"celsius":12}"
> 21:34:56,175 LogMediator  IN_MESSAGE =
> >;;>;;>;;>;;>;;>;;>;;>;;IN_MESSAGE
> 21:34:56,216 TimeoutHandler  This engine will expire all callbacks after :
> 120 seconds, irrespective of the timeout action, after the specified or
> optional timeout
> 21:34:56,296 < "POST /webservices/tempconvert.asmx?op=CelsiusToFahrenheit
> HTTP/1.0[\r][\n]"
> 21:34:56,297 < "Content-Type: text/xml[\r][\n]"
> 21:34:56,297 < "Accept: application/json[\r][\n]"
> 21:34:56,297 < "Content-Length: 292[\r][\n]"
> 21:34:56,297 < "Host: www.w3schools.com:80[\r][\n]"
> 21:34:56,298 < "Connection: Keep-Alive[\r][\n]"
> 21:34:56,298 < "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
> 21:34:56,298 < "[\r][\n]"
> 21:34:56,298 < " xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:web="
> http://www.w3schools.com/webservices/
> ">12<
> "
> 21:34:56,423 > "HTTP/1.0 400 Bad Request[\r][\n]"
> 21:34:56,423 > "Cache-Control: private,public[\r][\n]"
> 21:34:56,423 > "Content-Type: text/xml; charset=utf-8[\r][\n]"
> 21:34:56,423 > "Date: Sat, 07 Feb 2015 16:04:55 GMT[\r][\n]"
> 21:34:56,423 > "Server: Microsoft-IIS/7.5[\r][\n]"
> 21:34:56,423 > "X-AspNet-Version: 4.0.30319[\r][\n]"
> 21:34:56,423 > "X-Powered-By: ASP.NET[\r][\n]"
> 21:34:56,424 > "Content-Length: 0[\r][\n]"
> 21:34:56,424 > "Connection: keep-alive[\r][\n]"
> 21:34:56,424 > "[\r][\n]"
> 21:34:56,437 RelayUtils  Error while building Passthrough stream
> org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException:
> ParseError at [row,col]:[1,1]
> Message: Premature end of file.
> at
> org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
> at
> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
> at
> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.(StAXSOAPModelBuilder.java:154)
>
>
> The SOAP request being sent out is not valid XML at the end(seems like its
> getting chopped off) so the SOAP service is rejecting the message, any idea
> why this is happening? Here is the Synapse config again for reference,
>
>
> http://ws.apache.org/ns/synapse"; name="tempAPI"
> context="/temp">
>
>   
>  
>  value=">;;;>;;;>;;;>;;;>;;;>;;;>;;;>;;;IN_MESSAGE">
>  
>   scope="axis2">
>   scope="axis2">
>   scope="axis2">
>   scope="axis2">
>   scope="axis2">
>  
> 
>http://schemas.xmlsoap.org/soap/envelope/"; xmlns:web="
> http://www.w3schools.com/webservices/";>
>   
>   
>  
> $1
>  
>   
>
> 
> 
>
> 
>  
>  
> 
>http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit";
> format="soap11">
> 
>  
>   
>   
>  
>  value=">

Re: [Dev] [MB] Unable to run test cases due to ClassNotFoundException: org.wso2.andes.jndi.PropertiesFileInitialContextFactory

2015-02-07 Thread Hemika Kodikara
Found the issue. Add the following dependency to
modules/integration/tests-common/admin-clients/pom.xml.


org.wso2.andes.wso2
andes-client


PR at https://github.com/wso2/product-mb/pull/20/files

Regards,
Hemika


Hemika Kodikara
Software Engineer
WSO2 Inc.
lean . enterprise . middleware
http://wso2.com

Mobile : +9477762

On Sat, Feb 7, 2015 at 1:08 AM, Hemika Kodikara  wrote:

> Hi All,
>
> I am unable to run the product-mb test cases due to a
> ClassNotFoundException.
> See the following log.
>
>
> Exception in thread "Thread-6" java.lang.NullPointerException
> at
> org.wso2.mb.integration.common.clients.operations.queue.QueueMessageReceiver.run(QueueMessageReceiver.java:203)
> at java.lang.Thread.run(Thread.java:695)
> ERROR
> [org.wso2.mb.integration.common.clients.operations.queue.QueueMessageSender]
> - Error while looking up for queue
> javax.naming.NoInitialContextException: Cannot instantiate class:
> org.wso2.andes.jndi.PropertiesFileInitialContextFactory [Root exception is
> java.lang.ClassNotFoundException:
> org.wso2.andes.jndi.PropertiesFileInitialContextFactory]
> at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
> at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
> at javax.naming.InitialContext.init(InitialContext.java:223)
> at javax.naming.InitialContext.(InitialContext.java:197)
> at
> org.wso2.mb.integration.common.clients.operations.queue.QueueMessageSender.(QueueMessageSender.java:97)
> at
> org.wso2.mb.integration.common.clients.AndesClient.startWorking(AndesClient.java:283)
> at
> org.wso2.mb.integration.tests.amqp.functional.ClientAcknowledgementsTestCase.performClientAcknowledgementsTestCase(ClientAcknowledgementsTestCase.java:59)
> 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
> at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
> at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
> at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
> at
> org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
> at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
> at org.testng.TestRunner.privateRun(TestRunner.java:767)
> at org.testng.TestRunner.run(TestRunner.java:617)
> at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
> at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
> at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
> at org.testng.SuiteRunner.run(SuiteRunner.java:240)
> at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
> at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
> at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
> at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
> at org.testng.TestNG.run(TestNG.java:1057)
> at
> org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:178)
> at
> org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92)
> at
> org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:96)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
> at
> org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
> at
> org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
> at
> org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
> at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
> Caused by: java.lang.ClassNotFoundException:
> org.wso2.andes.jndi.PropertiesFileInitialContextFactory
> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:249)
> at
> com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
> at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
> ... 39 more
> Exception in thread "Thread-7" java.lang.NullPointerException

Re: [Dev] Converting JSON to SOAP and vise versa in ESB

2015-02-07 Thread Uvindra Dias Jayasinha
With wire logs on the issue becomes a bit more clear,





21:34:56,129 > "POST /temp HTTP/1.1[\r][\n]"
21:34:56,130 > "User-Agent: curl/7.35.0[\r][\n]"
21:34:56,130 > "Host: 10.0.3.1:8281[\r][\n]"
21:34:56,130 > "Accept: application/json[\r][\n]"
21:34:56,130 > "Content-Type:application/json[\r][\n]"
21:34:56,130 > "Content-Length: 14[\r][\n]"
21:34:56,130 > "[\r][\n]"
21:34:56,131 > "{"celsius":12}"
21:34:56,175 LogMediator  IN_MESSAGE =
>;;>;;>;;>;;>;;>;;>;;>;;IN_MESSAGE
21:34:56,216 TimeoutHandler  This engine will expire all callbacks after :
120 seconds, irrespective of the timeout action, after the specified or
optional timeout
21:34:56,296 < "POST /webservices/tempconvert.asmx?op=CelsiusToFahrenheit
HTTP/1.0[\r][\n]"
21:34:56,297 < "Content-Type: text/xml[\r][\n]"
21:34:56,297 < "Accept: application/json[\r][\n]"
21:34:56,297 < "Content-Length: 292[\r][\n]"
21:34:56,297 < "Host: www.w3schools.com:80[\r][\n]"
21:34:56,298 < "Connection: Keep-Alive[\r][\n]"
21:34:56,298 < "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
21:34:56,298 < "[\r][\n]"
21:34:56,298 < "http://schemas.xmlsoap.org/soap/envelope/"; xmlns:web="
http://www.w3schools.com/webservices/
">12<
"
21:34:56,423 > "HTTP/1.0 400 Bad Request[\r][\n]"
21:34:56,423 > "Cache-Control: private,public[\r][\n]"
21:34:56,423 > "Content-Type: text/xml; charset=utf-8[\r][\n]"
21:34:56,423 > "Date: Sat, 07 Feb 2015 16:04:55 GMT[\r][\n]"
21:34:56,423 > "Server: Microsoft-IIS/7.5[\r][\n]"
21:34:56,423 > "X-AspNet-Version: 4.0.30319[\r][\n]"
21:34:56,423 > "X-Powered-By: ASP.NET[\r][\n]"
21:34:56,424 > "Content-Length: 0[\r][\n]"
21:34:56,424 > "Connection: keep-alive[\r][\n]"
21:34:56,424 > "[\r][\n]"
21:34:56,437 RelayUtils  Error while building Passthrough stream
org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException:
ParseError at [row,col]:[1,1]
Message: Premature end of file.
at
org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at
org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
at
org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.(StAXSOAPModelBuilder.java:154)


The SOAP request being sent out is not valid XML at the end(seems like its
getting chopped off) so the SOAP service is rejecting the message, any idea
why this is happening? Here is the Synapse config again for reference,


http://ws.apache.org/ns/synapse"; name="tempAPI" context="/temp">
   
  
 

 
 
 
 
 
 
 

   http://schemas.xmlsoap.org/soap/envelope/"; xmlns:web="
http://www.w3schools.com/webservices/";>
  
  
 
$1
 
  
   


   

 
 

   http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit";
format="soap11">

 
  
  
 

 
 
 

   $1


   http://www.w3schools.com/webservices/";
evaluator="xml"
expression="//foo:CelsiusToFahrenheitResponse/foo:CelsiusToFahrenheitResult">

 
 
  
   


Using fresh ESB 4.8.1 pack without any config changes.



On 7 February 2015 at 20:48, Dushan Abeyruwan  wrote:

> Guys it worked for me with my config I mean how Uvindra can't ?
>
> *xxx-MacBook-Pro:bin dushan$ curl -i -POST -H 'Accept: application/json'
> -H 'Content-Type:application/json' -d
> '{"celsius":12}' http://192.168.56.1:8281/temp
> *
> *HTTP/1.1 200 OK*
> *X-AspNet-Version: 4.0.30319*
> *Content-Type: application/json*
> *X-Powered-By: ASP.NET *
> *Cache-Control: private, max-age=0,public*
> *Date: Fri, 06 Feb 2015 17:19:20 GMT*
> *Server: WSO2-PassThrough-HTTP*
> *Transfer-Encoding: chunked*
>
> *{"Temp":53.6}xxx-xxx-Pro:bin xx$*
>
>
>
> On Sat, Feb 7, 2015 at 9:51 AM, Malaka Silva  wrote:
>
>> Can you share the wire logs?
>>
>> On Sat, Feb 7, 2015 at 12:50 PM, Uvindra Dias Jayasinha > > wrote:
>>
>>> The "Premature end of file" exception is still happening even when I add
>>> those two properties in, this is a parser error happening on our end in the
>>> insequence itself. I still cant understand why this isnt working.
>>>
>>> On 7 February 2015 at 12:15, Chanaka Fernando  wrote:
>>>
 Hi Uvindra,

 According to the website, they expect content-length header in the
 request. You can use the below two property mediators to send the
 content-length always.

 >>> scope="axis2">
  >>> value="true" scope="axis2">


 Try the above properties prior to the send mediator.


 Thanks,
>>>

Re: [Dev] Converting JSON to SOAP and vise versa in ESB

2015-02-07 Thread Dushan Abeyruwan
Guys it worked for me with my config I mean how Uvindra can't ?

*xxx-MacBook-Pro:bin dushan$ curl -i -POST -H 'Accept: application/json' -H
'Content-Type:application/json' -d
'{"celsius":12}' http://192.168.56.1:8281/temp
*
*HTTP/1.1 200 OK*
*X-AspNet-Version: 4.0.30319*
*Content-Type: application/json*
*X-Powered-By: ASP.NET *
*Cache-Control: private, max-age=0,public*
*Date: Fri, 06 Feb 2015 17:19:20 GMT*
*Server: WSO2-PassThrough-HTTP*
*Transfer-Encoding: chunked*

*{"Temp":53.6}xxx-xxx-Pro:bin xx$*



On Sat, Feb 7, 2015 at 9:51 AM, Malaka Silva  wrote:

> Can you share the wire logs?
>
> On Sat, Feb 7, 2015 at 12:50 PM, Uvindra Dias Jayasinha 
> wrote:
>
>> The "Premature end of file" exception is still happening even when I add
>> those two properties in, this is a parser error happening on our end in the
>> insequence itself. I still cant understand why this isnt working.
>>
>> On 7 February 2015 at 12:15, Chanaka Fernando  wrote:
>>
>>> Hi Uvindra,
>>>
>>> According to the website, they expect content-length header in the
>>> request. You can use the below two property mediators to send the
>>> content-length always.
>>>
>>> >> scope="axis2">
>>>  >> scope="axis2">
>>>
>>>
>>> Try the above properties prior to the send mediator.
>>>
>>>
>>> Thanks,
>>> Chanaka
>>>
>>> On Fri, Feb 6, 2015 at 11:28 PM, Uvindra Dias Jayasinha <
>>> uvin...@wso2.com> wrote:
>>>
 Ok tried that Dushan, but now I get a different exception when I hit
 the insequence


 23:24:38,849 LogMediator  IN_MESSAGE =
 >>>>>>>>IN_MESSAGE
 RelayUtils  Error while building Passthrough stream
 org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException:
 ParseError at [row,col]:[1,1]
 Message: Premature end of file.
 at
 org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
 at
 org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
 at
 org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.(StAXSOAPModelBuilder.java:154)
 at
 org.apache.axiom.om.impl.AbstractOMMetaFactory.createStAXSOAPModelBuilder(AbstractOMMetaFactory.java:73)
 at
 org.apache.axiom.om.impl.AbstractOMMetaFactory.createSOAPModelBuilder(AbstractOMMetaFactory.java:79)
 at
 org.apache.axiom.om.OMXMLBuilderFactory.createSOAPModelBuilder(OMXMLBuilderFactory.java:196)
 at
 org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:55)
 at
 org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:118)
 at
 org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:107)
 at
 org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:82)
 at
 org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:68)
 at
 org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
 at
 org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
 at org.apache.synapse.rest.Resource.process(Resource.java:297)
 at org.apache.synapse.rest.API.process(API.java:298)
 at
 org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:76)
 at
 org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:50)
 at
 org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:220)
 at
 org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:488)
 at
 org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:170)
 at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
 at
 org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:225)
 at
 org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
 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: javax.xml.stream.XMLStreamException: ParseError at
 [row,col]:[1,1]
 Message: Premature end of file.
 at
 com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:594)
 at
 org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
 at
 org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDe

Re: [Dev] Accessing OSGi Service from a Web App

2015-02-07 Thread Nirmal Fernando
Thanks Kasun!

On Sat, Feb 7, 2015 at 7:53 PM, KasunG Gajasinghe  wrote:

>
> How about adding the actual logic to an osgi bundle, and then keep only
> the jax-rs resource class inside the webapp? Then the webapp will invoke
> the bundle, and that bundle can access the service references as required.
>

I think we could follow the above approach.

>
> You could also use PrivilegedCarbonContext#getOSGiServices() method if you
> need to access osgi services within a webapp.
>
> Dataholders are only supposed to be used within a component, and is not
> supposed to be exposed to other components.
>
>
> On Sat, Feb 7, 2015 at 7:30 PM, Nirmal Fernando  wrote:
>
>> One other way that I can think of is, by introducing a service component
>> which has references to all OSGi service we require and then accessing the
>> data holder via web app.
>>
>> On Sat, Feb 7, 2015 at 7:24 PM, Supun Sethunga  wrote:
>>
>>> Hi,
>>>
>>> Im trying to expose some OSGI services as REST API's. (Please refer mail
>>> thread "[Architecture] REST API for Machine Learner")
>>> For that, i want to access the Service References of the services which
>>> were registered in the OSGI context by their respective bundle activators,
>>> from the web app (.war).
>>>
>>> I tried the following methods [1] and [2], But both returns a NULL
>>> bundle contexts.
>>> (Here 'Project.class' is the web app's class name)
>>>
>>> [1] BundleContext bundleContext =
>>> FrameworkUtil.getBundle(Project.class).getBundleContext();
>>>
>>> [2] @Context
>>>   ServletContext servletContext;
>>>   BundleContext bundleContext = (BundleContext)
>>> servletContext.getAttribute("osgi-bundlecontext");
>>>
>>> AFAIU this happens because the 'Project.class' is not loaded by an OSGi
>>> bundle class loader, because it is bundled as an web app.
>>>
>>> Is there a different apporach to expose the OSGi servioce as REST API's?
>>> Can anyone please shed some light here?
>>>
>>> --
>>> *Supun Sethunga*
>>> Software Engineer
>>> WSO2, Inc.
>>> lean | enterprise | middleware
>>> Mobile : +94 716546324
>>>
>>
>>
>>
>> --
>>
>> Thanks & regards,
>> Nirmal
>>
>> Senior Software Engineer- Platform Technologies Team, WSO2 Inc.
>> Mobile: +94715779733
>> Blog: http://nirmalfdo.blogspot.com/
>>
>>
>>
>
>
> --
>
> *Kasun Gajasinghe*Senior Software Engineer, WSO2 Inc.
> email: kasung AT spamfree wso2.com
> linked-in: http://lk.linkedin.com/in/gajasinghe
> blog: http://kasunbg.org
>
>
>



-- 

Thanks & regards,
Nirmal

Senior Software Engineer- Platform Technologies Team, WSO2 Inc.
Mobile: +94715779733
Blog: http://nirmalfdo.blogspot.com/
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Converting JSON to SOAP and vise versa in ESB

2015-02-07 Thread Malaka Silva
Can you share the wire logs?

On Sat, Feb 7, 2015 at 12:50 PM, Uvindra Dias Jayasinha 
wrote:

> The "Premature end of file" exception is still happening even when I add
> those two properties in, this is a parser error happening on our end in the
> insequence itself. I still cant understand why this isnt working.
>
> On 7 February 2015 at 12:15, Chanaka Fernando  wrote:
>
>> Hi Uvindra,
>>
>> According to the website, they expect content-length header in the
>> request. You can use the below two property mediators to send the
>> content-length always.
>>
>> > scope="axis2">
>>  > scope="axis2">
>>
>>
>> Try the above properties prior to the send mediator.
>>
>>
>> Thanks,
>> Chanaka
>>
>> On Fri, Feb 6, 2015 at 11:28 PM, Uvindra Dias Jayasinha > > wrote:
>>
>>> Ok tried that Dushan, but now I get a different exception when I hit the
>>> insequence
>>>
>>>
>>> 23:24:38,849 LogMediator  IN_MESSAGE =
>>> >>>>>>>>IN_MESSAGE
>>> RelayUtils  Error while building Passthrough stream
>>> org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException:
>>> ParseError at [row,col]:[1,1]
>>> Message: Premature end of file.
>>> at
>>> org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
>>> at
>>> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
>>> at
>>> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.(StAXSOAPModelBuilder.java:154)
>>> at
>>> org.apache.axiom.om.impl.AbstractOMMetaFactory.createStAXSOAPModelBuilder(AbstractOMMetaFactory.java:73)
>>> at
>>> org.apache.axiom.om.impl.AbstractOMMetaFactory.createSOAPModelBuilder(AbstractOMMetaFactory.java:79)
>>> at
>>> org.apache.axiom.om.OMXMLBuilderFactory.createSOAPModelBuilder(OMXMLBuilderFactory.java:196)
>>> at
>>> org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:55)
>>> at
>>> org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:118)
>>> at
>>> org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:107)
>>> at
>>> org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:82)
>>> at
>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:68)
>>> at
>>> org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
>>> at
>>> org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
>>> at org.apache.synapse.rest.Resource.process(Resource.java:297)
>>> at org.apache.synapse.rest.API.process(API.java:298)
>>> at
>>> org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:76)
>>> at
>>> org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:50)
>>> at
>>> org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:220)
>>> at
>>> org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:488)
>>> at
>>> org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:170)
>>> at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
>>> at
>>> org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:225)
>>> at
>>> org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
>>> 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: javax.xml.stream.XMLStreamException: ParseError at
>>> [row,col]:[1,1]
>>> Message: Premature end of file.
>>> at
>>> com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:594)
>>> at
>>> org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
>>> at
>>> org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34)
>>> at
>>> org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
>>> at
>>> org.apache.axiom.util.stax.dialect.SJSXPStreamReaderWrapper.next(SJSXPStreamReaderWrapper.java:138)
>>> at
>>> org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
>>> at
>>> org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
>>> ... 25 more
>>> 23:24:39,141 SequenceMediator  Error while building message
>>> org.apache.axis2.AxisFault: Error while building Passthrough stream
>>> at
>>> org.apache.synapse.transport.passthru.util.RelayUtils.handleException(RelayUtils.java:236)
>>> at
>>> org.apache.sy

Re: [Dev] Concerns on how to handle exceptions in UI(JSP)

2015-02-07 Thread Hemika Kodikara
Can I get some advice on this ?

Is it necessary to put a e.printStackTrace() if an error is caught at JSP
level ?

Hemika Kodikara
Software Engineer
WSO2 Inc.
lean . enterprise . middleware
http://wso2.com

Mobile : +9477762

On Mon, Jan 26, 2015 at 11:38 AM, Hemika Kodikara  wrote:

> Hi All,
>
> What is the correct way to handle an exception when it comes to JSP pages ?
>
> Currently I have the following AJAX call on a JS file. This is called from
> another JSP file.
>
> function updatePermissions() {
> var callback =
> {
> success:function(o) {
> if (o.responseText !== undefined) {
> if (o.responseText.indexOf("Error") > -1) {
> CARBON.showErrorDialog("" + o.responseText, function()
> {
> location.href = "../queues/queue_details.jsp"
> });
> } else {
> CARBON.showInfoDialog("" + o.responseText, function() {
> location.href = "../queues/queue_details.jsp"
> });
> }
>
> }
> },
> failure:function(o) {
> if (o.responseText !== undefined) {
> alert("Error " + o.status + "\n Following is the message
> from the server.\n" + o.responseText);
> }
> }
> };
> var request = YAHOO.util.Connect.asyncRequest('POST',
> "update_queue_role_permissions_ajaxprocessor.jsp", callback);
> }
>
>
> The call is going to the the following file
> (update_queue_role_permissions_ajaxprocessor.jsp)
> update_queue_role_permissions_ajaxprocessor.jsp
> ===
> <%
> // some code
> QueueRolePermission[] queueRolePermissions = new
> QueueRolePermission[queueRolePermissionArrayList.size()];
> try {
> // some code
> stub.updatePermission(queue,
> queueRolePermissionArrayList.toArray(queueRolePermissions));
> message = "Queue added successfully";
> } catch (AndesAdminServiceBrokerManagerAdminException e) {
> // what to do here ?
> message = "Error in adding/updating permissions : " +
> e.getMessage();
> }
> %><%=message%>
>
>
> Concerns :
> 1. When an exception is caught, should the exception be logged at the JSP
> catch block or logged at where it is occurring at the higher level of code
> where the exception was thrown ?
>
> 2. If the exception is being logged at the JSP level, should it use log4j
> or an e.printStackTrace() ? e.printStackTrace usage at [1].
>
> [1] - https://docs.wso2.com/display/Governance460/Transition+UI+Sample
>
> Regards,
> Hemika
>
> Hemika Kodikara
> Software Engineer
> WSO2 Inc.
> lean . enterprise . middleware
> http://wso2.com
>
> Mobile : +9477762
>
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Accessing OSGi Service from a Web App

2015-02-07 Thread KasunG Gajasinghe
How about adding the actual logic to an osgi bundle, and then keep only the
jax-rs resource class inside the webapp? Then the webapp will invoke the
bundle, and that bundle can access the service references as required.

You could also use PrivilegedCarbonContext#getOSGiServices() method if you
need to access osgi services within a webapp.

Dataholders are only supposed to be used within a component, and is not
supposed to be exposed to other components.


On Sat, Feb 7, 2015 at 7:30 PM, Nirmal Fernando  wrote:

> One other way that I can think of is, by introducing a service component
> which has references to all OSGi service we require and then accessing the
> data holder via web app.
>
> On Sat, Feb 7, 2015 at 7:24 PM, Supun Sethunga  wrote:
>
>> Hi,
>>
>> Im trying to expose some OSGI services as REST API's. (Please refer mail
>> thread "[Architecture] REST API for Machine Learner")
>> For that, i want to access the Service References of the services which
>> were registered in the OSGI context by their respective bundle activators,
>> from the web app (.war).
>>
>> I tried the following methods [1] and [2], But both returns a NULL bundle
>> contexts.
>> (Here 'Project.class' is the web app's class name)
>>
>> [1] BundleContext bundleContext =
>> FrameworkUtil.getBundle(Project.class).getBundleContext();
>>
>> [2] @Context
>>   ServletContext servletContext;
>>   BundleContext bundleContext = (BundleContext)
>> servletContext.getAttribute("osgi-bundlecontext");
>>
>> AFAIU this happens because the 'Project.class' is not loaded by an OSGi
>> bundle class loader, because it is bundled as an web app.
>>
>> Is there a different apporach to expose the OSGi servioce as REST API's?
>> Can anyone please shed some light here?
>>
>> --
>> *Supun Sethunga*
>> Software Engineer
>> WSO2, Inc.
>> lean | enterprise | middleware
>> Mobile : +94 716546324
>>
>
>
>
> --
>
> Thanks & regards,
> Nirmal
>
> Senior Software Engineer- Platform Technologies Team, WSO2 Inc.
> Mobile: +94715779733
> Blog: http://nirmalfdo.blogspot.com/
>
>
>


-- 

*Kasun Gajasinghe*Senior Software Engineer, WSO2 Inc.
email: kasung AT spamfree wso2.com
linked-in: http://lk.linkedin.com/in/gajasinghe
blog: http://kasunbg.org
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] Accessing OSGi Service from a Web App

2015-02-07 Thread Nirmal Fernando
One other way that I can think of is, by introducing a service component
which has references to all OSGi service we require and then accessing the
data holder via web app.

On Sat, Feb 7, 2015 at 7:24 PM, Supun Sethunga  wrote:

> Hi,
>
> Im trying to expose some OSGI services as REST API's. (Please refer mail
> thread "[Architecture] REST API for Machine Learner")
> For that, i want to access the Service References of the services which
> were registered in the OSGI context by their respective bundle activators,
> from the web app (.war).
>
> I tried the following methods [1] and [2], But both returns a NULL bundle
> contexts.
> (Here 'Project.class' is the web app's class name)
>
> [1] BundleContext bundleContext =
> FrameworkUtil.getBundle(Project.class).getBundleContext();
>
> [2] @Context
>   ServletContext servletContext;
>   BundleContext bundleContext = (BundleContext)
> servletContext.getAttribute("osgi-bundlecontext");
>
> AFAIU this happens because the 'Project.class' is not loaded by an OSGi
> bundle class loader, because it is bundled as an web app.
>
> Is there a different apporach to expose the OSGi servioce as REST API's?
> Can anyone please shed some light here?
>
> --
> *Supun Sethunga*
> Software Engineer
> WSO2, Inc.
> lean | enterprise | middleware
> Mobile : +94 716546324
>



-- 

Thanks & regards,
Nirmal

Senior Software Engineer- Platform Technologies Team, WSO2 Inc.
Mobile: +94715779733
Blog: http://nirmalfdo.blogspot.com/
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[Dev] Accessing OSGi Service from a Web App

2015-02-07 Thread Supun Sethunga
Hi,

Im trying to expose some OSGI services as REST API's. (Please refer mail
thread "[Architecture] REST API for Machine Learner")
For that, i want to access the Service References of the services which
were registered in the OSGI context by their respective bundle activators,
from the web app (.war).

I tried the following methods [1] and [2], But both returns a NULL bundle
contexts.
(Here 'Project.class' is the web app's class name)

[1] BundleContext bundleContext =
FrameworkUtil.getBundle(Project.class).getBundleContext();

[2] @Context
  ServletContext servletContext;
  BundleContext bundleContext = (BundleContext)
servletContext.getAttribute("osgi-bundlecontext");

AFAIU this happens because the 'Project.class' is not loaded by an OSGi
bundle class loader, because it is bundled as an web app.

Is there a different apporach to expose the OSGi servioce as REST API's?
Can anyone please shed some light here?

-- 
*Supun Sethunga*
Software Engineer
WSO2, Inc.
lean | enterprise | middleware
Mobile : +94 716546324
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


Re: [Dev] [MB]Error when trying to run the Durable subscriber sample

2015-02-07 Thread Megala Uthayakumar
Hi,

Thanks for the info. But I am using the MB 3.0.

On Fri, Feb 6, 2015 at 6:12 PM, Shiva Balachandran  wrote:

> Hi Megala,
>
> What is the version of MB you are currently using? This was issue was
> experienced in 2.0.1 and was fixed in the later version, refer to [1].
>
> [1] -
> http://stackoverflow.com/questions/16107685/wso2-messagebrokerthrowing-org-wso2-andes-amqtimeoutexception-error-when-creati
>
> Thank you.
>
> Regards,
> Shiva Balachandran
>
> On Fri, Feb 6, 2015 at 3:28 PM, Megala Uthayakumar 
> wrote:
>
>>
>> Hi all,
>>
>> When I try to run the Durable subscriber sample in the MB I got the
>> following error.
>>
>> [
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *java] javax.jms.JMSException: Error registering consumer:
>> org.wso2.andes.AMQSecurityException: Cannot subscribe to queue
>> carbon:mySub1234567 as it already has an existing exclusive consumer [error
>> code 403: access refused] [java] at
>> org.wso2.andes.client.AMQSession$5.execute(AMQSession.java:2089) [java]
>> at org.wso2.andes.client.AMQSession$5.execute(AMQSession.java:2032)
>> [java] at
>> org.wso2.andes.client.AMQConnectionDelegate_8_0.executeRetrySupport(AMQConnectionDelegate_8_0.java:315)
>> [java] at
>> org.wso2.andes.client.AMQConnection.executeRetrySupport(AMQConnection.java:620)
>> [java] at
>> org.wso2.andes.client.failover.FailoverRetrySupport.execute(FailoverRetrySupport.java:102)
>> [java] at
>> org.wso2.andes.client.AMQSession.createConsumerImpl(AMQSession.java:2030)
>> [java] at
>> org.wso2.andes.client.AMQSession.createConsumer(AMQSession.java:1028)
>> [java] at
>> org.wso2.andes.client.AMQSession.createDurableSubscriber(AMQSession.java:1182)
>> [java] at
>> org.wso2.andes.client.AMQSession.createDurableSubscriber(AMQSession.java:1077)
>> [java] at
>> org.wso2.andes.client.AMQTopicSessionAdaptor.createDurableSubscriber(AMQTopicSessionAdaptor.java:73)
>> [java] at org.sample.jms.DurableTopicSubscriber.subscribe(Unknown
>> Source) [java] at org.sample.jms.Main.main(Unknown Source)*
>>
>> Same exception is thrown  when trying to run the integration test for the
>> durable subscribers. What may be the possible reason for this?
>>
>> Thanks
>>
>> Megala Uthayakumar
>> *Software Engineering Intern *| *WSO2 Lanka*
>> Mobile : +94 779 967 122
>> Tel  : +94 112 733 667
>> E-mail :  meg...@wso2.com
>>
>> ___
>> Dev mailing list
>> Dev@wso2.org
>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>
>>
>
>
> --
> Shiva Balachandran
> Software Engineer
> WSO2 Inc.
>
> Mobile - +94 774445788
> Blog - https://shivabalachandran.wordpress.com/
>



-- 
Megala Uthayakumar
*Software Engineering Intern *| *WSO2 Lanka*
Mobile : +94 779 967 122
Tel  : +94 112 733 667
E-mail :  meg...@wso2.com
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev