I have a proxy service that based on HTTP Method sends the request to an application hosted by WSO2 Application Server or to a data service on WSO2 Data Services Server.
Some PUT operations needs no request body, since they just change something based on URI semantics, but I can't getting this works when I PUT without a payload.
The service look like this:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="IntegrationProxy" transports="http https" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="original.content-type" expression="$trp:Content-Type" type="STRING"/>
<property name="FORCE_POST_PUT_NOBODY" value="true" scope="axis2" type="BOOLEAN"/>
<property name="Content-Type" value="get-property('original.content-type')" scope="transport"/>
<property name="as.host" value="http://as-host:9763" type="STRING"/>
<property name="dss.host" value="http://dss-host:9763" type="STRING"/>
<property name="uri.var.as.service.url" expression="fn:concat(get-property('as.host'), '/rest/integracao')"/>
<property name="uri.var.dss.service.url" expression="fn:concat(get-property('dss.host'), '/services/Integrations')"/>
<log level="custom" separator="\n">
<property name="ProxyNameIn" value="IntegrationProxy - inSequence"/>
</log>
<log level="custom" separator="\n">
<property name="Original-Content-Type" expression="get-property('original.content-type')"/>
<property name="Content-Type" expression="get-property('Content-Type')"/>
<property name="FORCE_POST_PUT_NOBODY" expression="$axis2:FORCE_POST_PUT_NOBODY"/>
<property name="Method" expression="$axis2:HTTP_METHOD"/>
</log>
<switch source="$axis2:HTTP_METHOD">
<case regex="GET">
<property name="called.url" expression="fn:concat(get-property('uri.var.dss.service.url'), $axis2:REST_URL_POSTFIX)"/>
<send>
<endpoint>
<http uri-template="{uri.var.dss.service.url}" method="$axis2:HTTP_METHOD"/>
</endpoint>
</send>
</case>
<default>
<property name="called.url" expression="fn:concat(get-property('uri.var.as.service.url'), $axis2:REST_URL_POSTFIX)"/>
<send>
<endpoint>
<http uri-template="{uri.var.as.service.url}" method="$axis2:HTTP_METHOD"/>
</endpoint>
</send>
</default>
</switch>
</inSequence>
<outSequence>
<log level="custom" separator="\n">
<property name="CalledURL" expression="get-property('called.url')" />
<property name="ProxyNameOut" value="IntegrationProxy - outSequence"/>
</log>
<send />
</outSequence>
</target>
</proxy>
Even using FORCE_POST_PUT_NOBODY we're receiving org.apache.axis2.AxisFault: No JSON payload provided. Below the full stack trace:
wso2_esb_apis | [2016-12-20 13:43:04,954] ERROR - JsonUtil #newJsonPayload. Could not save JSON payload. Invalid input stream found. MessageID: urn:uuid:222c9ec6-6085-4344-8622-d7ff76fc7d13
wso2_esb_apis | [2016-12-20 13:43:04,955] ERROR - DeferredMessageBuilder Error building message
wso2_esb_apis | org.apache.axis2.AxisFault: No JSON payload provided.
wso2_esb_apis | at org.apache.synapse.commons.json.JsonStreamBuilder.processDocument(JsonStreamBuilder.java:52)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:138)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:133)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:98)
wso2_esb_apis | at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:72)
wso2_esb_apis | at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:48)
wso2_esb_apis | at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:149)
wso2_esb_apis | at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:185)
wso2_esb_apis | at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:317)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:363)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:142)
wso2_esb_apis | at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
wso2_esb_apis | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
wso2_esb_apis | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
wso2_esb_apis | at java.lang.Thread.run(Thread.java:745)
wso2_esb_apis | [2016-12-20 13:43:04,956] ERROR - RelayUtils Error while building Passthrough stream
wso2_esb_apis | org.apache.axis2.AxisFault: No JSON payload provided.
wso2_esb_apis | at org.apache.synapse.commons.json.JsonStreamBuilder.processDocument(JsonStreamBuilder.java:52)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:138)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:133)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:98)
wso2_esb_apis | at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:72)
wso2_esb_apis | at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:48)
wso2_esb_apis | at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:149)
wso2_esb_apis | at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:185)
wso2_esb_apis | at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:317)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:363)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:142)
wso2_esb_apis | at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
wso2_esb_apis | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
wso2_esb_apis | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
wso2_esb_apis | at java.lang.Thread.run(Thread.java:745)
wso2_esb_apis | [2016-12-20 13:43:04,958] ERROR - SequenceMediator Error while building message
wso2_esb_apis | org.apache.axis2.AxisFault: Error while building Passthrough stream
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.handleException(RelayUtils.java:283)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:142)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:98)
wso2_esb_apis | at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:72)
wso2_esb_apis | at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:48)
wso2_esb_apis | at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:149)
wso2_esb_apis | at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:185)
wso2_esb_apis | at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:317)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:363)
wso2_esb_apis | at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:142)
wso2_esb_apis | at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
wso2_esb_apis | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
wso2_esb_apis | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
wso2_esb_apis | at java.lang.Thread.run(Thread.java:745)
wso2_esb_apis | Caused by: org.apache.axis2.AxisFault: No JSON payload provided.
wso2_esb_apis | at org.apache.synapse.commons.json.JsonStreamBuilder.processDocument(JsonStreamBuilder.java:52)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:138)
wso2_esb_apis | at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:133)
wso2_esb_apis | ... 13 more
wso2_esb_apis | [2016-12-20 13:43:04,960] INFO - LogMediator To: /services/SGTIntegracoesProxy/atendimentos/39679/aceito?idregional=11, MessageID: urn:uuid:222c9ec6-6085-4344-8622-d7ff76fc7d13, Direction: request, MESSAGE = Executing default 'fault' sequence, ERROR_CODE = 0, ERROR_MESSAGE = Error while building message, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body/></soapenv:Envelope>
WSO2 ESB version: 4.9.0
Java:
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
With a body like {} works fine, but I look for a "transparent" solution, without such workaround. Does anyboby have an issue like that?
UPDATE: this works with WSO2 ESB 5.0.0: https://wso2.org/jira/browse/ESBJAVA-4270. Does anyone upgraded "easily" to 5.0.0? Or better, does anyone knows a patch to this, without other changes?
Related
I have a data service exposed as a REST resource that inserts data into a MySQL table. When I call this resource directly from postman, it inserts the data successfully. However, when I call it via an endpoint it gives the following error:
ERROR {DBInOnlyMessageReceiver} - Error in in-only message receiver DS Fault Message: Error in DS non result invoke.
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Nested Exception:-
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'CallQuery.extractParams', cannot find parameter with type:query-param name:firstName
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Source Data Service:-
Name: CustomerDataService
Location: /Applications/IntegrationStudio.app/Contents/Eclipse/runtime/microesb/tmp/carbonapps/-1234/1657777407345TestCompositeApplication_1.0.0.car/CustomerDataService_1.0.0/CustomerDataService-1.0.0.dbs
Description:
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: _getcustomer_firstname
Current Params: {}
at org.wso2.micro.integrator.dataservices.core.dispatch.SingleDataServiceRequest.processSingleRequest(SingleDataServiceRequest.java:117)
at org.wso2.micro.integrator.dataservices.core.dispatch.SingleDataServiceRequest.processRequest(SingleDataServiceRequest.java:66)
at org.wso2.micro.integrator.dataservices.core.dispatch.DataServiceRequest.dispatch(DataServiceRequest.java:358)
at org.wso2.micro.integrator.dataservices.core.DataServiceProcessor.dispatch(DataServiceProcessor.java:40)
at org.wso2.micro.integrator.dataservices.core.DBInOnlyMessageReceiver.invokeBusinessLogic(DBInOnlyMessageReceiver.java:52)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:375)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:189)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'CallQuery.extractParams', cannot find parameter with type:query-param name:firstName
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Source Data Service:-
Name: CustomerDataService
Location: /Applications/IntegrationStudio.app/Contents/Eclipse/runtime/microesb/tmp/carbonapps/-1234/1657777407345TestCompositeApplication_1.0.0.car/CustomerDataService_1.0.0/CustomerDataService-1.0.0.dbs
Description:
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: _getcustomer_firstname
Current Params: {}
at org.wso2.micro.integrator.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:100)
at org.wso2.micro.integrator.dataservices.core.engine.DSOMDataSource.serialize(DSOMDataSource.java:105)
at org.wso2.micro.integrator.dataservices.core.engine.DSOMDataSource.executeInOnly(DSOMDataSource.java:78)
at org.wso2.micro.integrator.dataservices.core.dispatch.SingleDataServiceRequest.processSingleRequest(SingleDataServiceRequest.java:115)
... 12 more
Caused by: DS Fault Message: Error in 'CallQuery.extractParams', cannot find parameter with type:query-param name:firstName
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Source Data Service:-
Name: CustomerDataService
Location: /Applications/IntegrationStudio.app/Contents/Eclipse/runtime/microesb/tmp/carbonapps/-1234/1657777407345TestCompositeApplication_1.0.0.car/CustomerDataService_1.0.0/CustomerDataService-1.0.0.dbs
Description:
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: _getcustomer_firstname
Current Params: {}
at org.wso2.micro.integrator.dataservices.core.engine.CallQuery.extractParams(CallQuery.java:337)
at org.wso2.micro.integrator.dataservices.core.engine.CallQuery.executeElement(CallQuery.java:278)
at org.wso2.micro.integrator.dataservices.core.engine.OutputElement.execute(OutputElement.java:88)
at org.wso2.micro.integrator.dataservices.core.description.resource.Resource.execute(Resource.java:66)
at org.wso2.micro.integrator.dataservices.core.engine.DataService.invoke(DataService.java:613)
at org.wso2.micro.integrator.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:94)
... 15 more
[2022-07-14 11:13:54,166] ERROR {ServerWorker} - Error processing GET request for : /services/CustomerDataService.HTTPEndpoint/customer/John org.apache.axis2.AxisFault: DS Fault Message: Error in DS non result invoke.
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Nested Exception:-
javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'CallQuery.extractParams', cannot find parameter with type:query-param name:firstName
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Source Data Service:-
Name: CustomerDataService
Location: /Applications/IntegrationStudio.app/Contents/Eclipse/runtime/microesb/tmp/carbonapps/-1234/1657777407345TestCompositeApplication_1.0.0.car/CustomerDataService_1.0.0/CustomerDataService-1.0.0.dbs
Description:
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: _getcustomer_firstname
Current Params: {}
at org.wso2.micro.integrator.dataservices.core.DBUtils.createAxisFault(DBUtils.java:814)
at org.wso2.micro.integrator.dataservices.core.DBInOnlyMessageReceiver.invokeBusinessLogic(DBInOnlyMessageReceiver.java:57)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:375)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:189)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: javax.xml.stream.XMLStreamException: DS Fault Message: Error in 'CallQuery.extractParams', cannot find parameter with type:query-param name:firstName
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Source Data Service:-
Name: CustomerDataService
Location: /Applications/IntegrationStudio.app/Contents/Eclipse/runtime/microesb/tmp/carbonapps/-1234/1657777407345TestCompositeApplication_1.0.0.car/CustomerDataService_1.0.0/CustomerDataService-1.0.0.dbs
Description:
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: _getcustomer_firstname
Current Params: {}
at org.wso2.micro.integrator.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:100)
at org.wso2.micro.integrator.dataservices.core.engine.DSOMDataSource.serialize(DSOMDataSource.java:105)
at org.wso2.micro.integrator.dataservices.core.engine.DSOMDataSource.executeInOnly(DSOMDataSource.java:78)
at org.wso2.micro.integrator.dataservices.core.dispatch.SingleDataServiceRequest.processSingleRequest(SingleDataServiceRequest.java:115)
at org.wso2.micro.integrator.dataservices.core.dispatch.SingleDataServiceRequest.processRequest(SingleDataServiceRequest.java:66)
at org.wso2.micro.integrator.dataservices.core.dispatch.DataServiceRequest.dispatch(DataServiceRequest.java:358)
at org.wso2.micro.integrator.dataservices.core.DataServiceProcessor.dispatch(DataServiceProcessor.java:40)
at org.wso2.micro.integrator.dataservices.core.DBInOnlyMessageReceiver.invokeBusinessLogic(DBInOnlyMessageReceiver.java:52)
... 8 more
Caused by: DS Fault Message: Error in 'CallQuery.extractParams', cannot find parameter with type:query-param name:firstName
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Source Data Service:-
Name: CustomerDataService
Location: /Applications/IntegrationStudio.app/Contents/Eclipse/runtime/microesb/tmp/carbonapps/-1234/1657777407345TestCompositeApplication_1.0.0.car/CustomerDataService_1.0.0/CustomerDataService-1.0.0.dbs
Description:
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: _getcustomer_firstname
Current Params: {}
at org.wso2.micro.integrator.dataservices.core.engine.CallQuery.extractParams(CallQuery.java:337)
at org.wso2.micro.integrator.dataservices.core.engine.CallQuery.executeElement(CallQuery.java:278)
at org.wso2.micro.integrator.dataservices.core.engine.OutputElement.execute(OutputElement.java:88)
at org.wso2.micro.integrator.dataservices.core.description.resource.Resource.execute(Resource.java:66)
at org.wso2.micro.integrator.dataservices.core.engine.DataService.invoke(DataService.java:613)
at org.wso2.micro.integrator.dataservices.core.engine.DSOMDataSource.execute(DSOMDataSource.java:94)
... 15 more
The endpoint that calls the data service REST resource:
<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="CreateCustomerInDB" xmlns="http://ws.apache.org/ns/synapse">
<http method="get" uri-template="http://localhost:8290/services/CustomerDataService.HTTPEndpoint/customer/{uri.var.firstName}">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>1.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
The data service:
<data name="CustomerDataService" serviceNamespace="" serviceGroup="" transports="">
<description />
<config id="CustomerDatasource">
<property name="driverClassName">com.mysql.cj.jdbc.Driver</property>
<property name="url">jdbc:mysql://localhost:3306/demopresentation</property>
<property name="username">root</property>
<property name="password" />
</config>
<query id="CreateCustomerEntry" useConfig="CustomerDatasource">
<sql>insert into customers (FirstName) values (:firstName)</sql>
<param name="firstName" paramType="SCALAR" sqlType="STRING" type="IN" />
</query>
<resource path="customer/{firstName}" method="GET">
<call-query href="CreateCustomerEntry" >
<with-param name="firstName" query-param="firstName" />
</call-query>
</resource>
</data>
Point of entry into integration that then calls the above code:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/person" name="PersonAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST GET" uri-template="/customer">
<inSequence>
<log description="Full incoming msg log" level="full" separator=" >>> "/>
<propertyGroup>
<property expression="json-eval($.name.first_name)" name="uri.var.firstName" scope="default" type="STRING"/>
<property expression="json-eval($.name.last_name)" name="uri.var.lastName" scope="default" type="STRING"/>
<property expression="json-eval($.date_of_birth)" name="uri.var.dob" scope="default" type="STRING"/>
<property expression="json-eval($.email)" name="uri.var.email" scope="default" type="STRING"/>
<property name="TEST" scope="default" type="STRING" value="TEST_VALUE"/>
</propertyGroup>
<log level="custom">
<property expression="get-property('uri.var.firstName')" name="FName"/>
<property expression="get-property('uri.var.lastName')" name="LName"/>
<property expression="get-property('uri.var.dob')" name="DOB"/>
<property expression="get-property('uri.var.email')" name="Email"/>
<property expression="get-property('TEST')" name="TESTVAR"/>
</log>
<call>
<endpoint key="CreateCustomerInDB"/>
</call>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
first of all it is a very bad idea to use GET for inserting data into database. Just don't do that in that way - the practice does not follow the restfull rules.
And the problem looks like you don't pass uri.var.firstName parameter to your endpoint. Question is - how you call this endpoint? Do you have set the:uri.var.firstName, before call endpoint for example:
<property value="TestName" name="uri.var.firstName" scope="default" type="STRING"/>
Update:
For sending JSON data in POST request to DataService you can follow that documentation: Data i JSON format
It is important to have proper JSON data structure for that post.
Working with Integration Studio in Windows 10.
When I try Validate my Payload from REST API body with Sequence with Validate Mediator I get an Error.
Error:
[2020-03-10 11:07:29,295] INFO {TRACE_LOGGER} - Building message. Sequence <SequenceMediator> is content aware
[2020-03-10 11:07:29,309] ERROR {org.apache.synapse.mediators.base.SequenceMediator} - Unsupported Operation org.apache.axiom.om.OMException: Unsupported Operation
at org.apache.axiom.om.impl.llom.OMTextImpl.getInputStream(OMTextImpl.java:422)
at org.apache.synapse.mediators.builtin.ValidateMediator.mediate(ValidateMediator.java:231)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:214)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.config.xml.AnonymousListMediator.mediate(AnonymousListMediator.java:37)
at org.apache.synapse.config.xml.SwitchCase.mediate(SwitchCase.java:69)
at org.apache.synapse.mediators.filters.SwitchMediator.mediate(SwitchMediator.java:134)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.rest.Resource.process(Resource.java:331)
at org.apache.synapse.rest.API.process(API.java:440)
at org.apache.synapse.rest.RESTRequestHandler.apiProcessNonDefaultStrategy(RESTRequestHandler.java:149)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:95)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:71)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:325)
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:98)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:367)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:412)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:181)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Then I try to validate from it:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="Reserves" statistics="enable" trace="enable" xmlns="http://ws.apache.org/ns/synapse">
<validate cache-schema="false" source="json-eval($)">
<schema key="conf:/schemas/ReservesRoot.json"/>
<on-fail>
<payloadFactory media-type="json">
<format>{"Error":$1"}</format>
<args>
<arg evaluator="xml" expression="$ctx:ERROR_MESSAGE"/>
</args>
</payloadFactory>
<property name="HTTP_SC" scope="axis2" type="STRING" value="500"/>
<respond/>
</on-fail>
</validate>
</sequence>
JSON Schema:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"Type": {
"type": "string"
}
},
"required": [
"Type"
]
}
When I get the schema in property I see the schema's string.
<property value="get-property('registry', 'conf:/schemas/ReservesRoot.json')" name="ReservesSchema"/>
<log>
<property expression="get-property('ReservesSchema')" name="JSON_P"/>
</log>
This issue occurs when the JSON-schema saved in the registry does not have the correct media-type (must be application/json). Could you please double-check this in Integration studio Resources Editor view.
You can access the resources editor view by right click on registry resource project -> Registry resource editor
This issue occurs with Micro integrator. Micro integrator does not have rdbms registry artifacts. Hence we cannot specify the media type. The work around is to add local entry file with the validation json schema and refer it in synapse.
<validate cache-schema="false">
<schema key="createotpvalidate"/>
<on-fail>
<payloadFactory media-type="json">
<format>{"Error":$1"}</format>
<args>
<arg evaluator="xml" expression="$ctx:ERROR_MESSAGE"/>
</args>
</payloadFactory>
<property name="HTTP_SC" scope="axis2" type="STRING" value="500"/>
<respond/>
<!-- <schema key="conf:/schema/CreateOTPSchema.json"/> -->
</on-fail>
</validate>
Local Entry file:
<?xml version="1.0" encoding="UTF-8"?>
<localEntry key="createotpvalidate" xmlns="http://ws.apache.org/ns/synapse"><![CDATA[{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "request_type": { "type": "string" },"mobile": { "type": "string" },"otp": { "type": "string" } }, "required": [ "request_type","mobile","otp" ] }]]></localEntry>
I have a data service that contains two queries. One is a select query and the other is an insert query.
How could we call both queries in a single proxy service? Is there any way to call both queries in a single operation or by adding two call mediators in the proxy service?
As I am using call mediator, how can we call different operations? I have tried it by creating two different data services, but it is giving error "Error while building Passthrough stream"
Can any one provide a sample of both?
Source of my Proxy
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="EslSfaOfaCreateSaleOrdersPS"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<call>
<endpoint>
<address format="soap11"
uri="http://10.1.6.175:9763/services/EslSfaExtractSODataService.SOAP11Endpoint/"/>
</endpoint>
</call>
<call>
<endpoint>
<address format="soap11"
uri="http://10.1.6.175:9763/services/EslSfaInsertTempDataService.SOAP11Endpoint/"/>
</endpoint>
</call>
<log level="full"/>
<datamapper config="gov:datamapper/EslSfaOfaCreateSOMapping.dmc"
inputSchema="gov:datamapper/EslSfaOfaCreateSOMapping_inputSchema.json"
inputType="XML"
outputSchema="gov:datamapper/EslSfaOfaCreateSOMapping_outputSchema.json"
outputType="XML"/>
<log level="full"/>
<header/>
<call>
<endpoint>
<address format="soap11"
uri="https://host/soa-infra/services/default/DooDecompReceiveOrderExternalComposite/ReceiveOrderRequestService"/>
</endpoint>
</call>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
<description/>
</proxy>
The error start coming as i aded second call
TID: [-1234] [] [2017-02-25 15:08:36,060] ERROR {org.apache.synapse.transport.passthru.util.RelayUtils} - Error while building Passthrough stream {org.apache.synapse.transport.passthru.util.RelayUtils}
org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope , but found faultstring
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.constructNode(StAXSOAPModelBuilder.java:305)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createOMElement(StAXSOAPModelBuilder.java:252)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createNextOMElement(StAXSOAPModelBuilder.java:234)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:249)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(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:65)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:148)
at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:137)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:100)
at org.apache.synapse.mediators.AbstractListMediator.buildMessage(AbstractListMediator.java:140)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:83)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:260)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:766)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:282)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:554)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:188)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:261)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
TID: [-1234] [] [2017-02-25 15:08:36,065] ERROR {org.apache.synapse.mediators.base.SequenceMediator} - Error while building message {org.apache.synapse.mediators.base.SequenceMediator}
org.apache.axis2.AxisFault: Error while building Passthrough stream
at org.apache.synapse.transport.passthru.util.RelayUtils.handleException(RelayUtils.java:284)
at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:143)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:100)
at org.apache.synapse.mediators.AbstractListMediator.buildMessage(AbstractListMediator.java:140)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:83)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:260)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:766)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:282)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:554)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:188)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
I'm getting an error from the WSO2 API Manager Store when attempting to generate consumer key/secret pair.
Screenshot: Error occurred while executing the action generateApplicationKey
The logs contain about 1200 lines of stack trace, parts of which seem to repeat. Here's a representative sample:
TID: [-1234] [] [2016-09-22 13:57:11,563] ERROR {org.wso2.carbon.apimgt.impl.APIConsumerImpl} - Could not execute Workflow {org.wso2.carbon.apimgt.impl.APIConsumerImpl}
org.wso2.carbon.apimgt.impl.workflow.WorkflowException: Error occurred when updating the status of the Application creation process
at org.wso2.carbon.apimgt.impl.workflow.ApplicationRegistrationSimpleWorkflowExecutor.complete(ApplicationRegistrationSimpleWorkflowExecutor.java:82)
at org.wso2.carbon.apimgt.impl.workflow.ApplicationRegistrationSimpleWorkflowExecutor.execute(ApplicationRegistrationSimpleWorkflowExecutor.java:54)
at org.wso2.carbon.apimgt.impl.APIConsumerImpl.requestApprovalForApplicationRegistration(APIConsumerImpl.java:2790)
at org.wso2.carbon.apimgt.impl.UserAwareAPIConsumer.requestApprovalForApplicationRegistration(UserAwareAPIConsumer.java:36)
at org.wso2.carbon.apimgt.hostobjects.APIStoreHostObject.jsFunction_getApplicationKey(APIStoreHostObject.java:382)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:386)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
at org.jaggeryjs.rhino.store.modules.subscription.c3._c_anonymous_2(/store/modules/subscription/key.jag:39)
at org.jaggeryjs.rhino.store.modules.subscription.c3.call(/store/modules/subscription/key.jag)
at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2430)
at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:269)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:97)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)
at org.jaggeryjs.rhino.store.modules.subscription.c0._c_anonymous_11(/store/modules/subscription/module.jag:38)
at org.jaggeryjs.rhino.store.modules.subscription.c0.call(/store/modules/subscription/module.jag)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0._c_anonymous_1(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag:240)
at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0.call(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0.call(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag)
at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0.exec(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag)
at org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:567)
at org.jaggeryjs.scriptengine.engine.RhinoEngine.exec(RhinoEngine.java:273)
at org.jaggeryjs.jaggery.core.manager.WebAppManager.exec(WebAppManager.java:588)
at org.jaggeryjs.jaggery.core.manager.WebAppManager.execute(WebAppManager.java:508)
at org.jaggeryjs.jaggery.core.JaggeryServlet.doPost(JaggeryServlet.java:29)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:377)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)
at org.jaggeryjs.jaggery.core.JaggeryFilter.doFilter(JaggeryFilter.java:21)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:120)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:99)
at org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
at org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:57)
at org.wso2.carbon.event.receiver.core.internal.tenantmgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:48)
at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:62)
at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:159)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:57)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1749)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1708)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.wso2.carbon.apimgt.api.APIManagementException: Error occurred while executing SubscriberKeyMgtClient.
at org.wso2.carbon.apimgt.impl.utils.APIUtil.handleException(APIUtil.java:1195)
at org.wso2.carbon.apimgt.impl.workflow.AbstractApplicationRegistrationWorkflowExecutor.dogenerateKeysForApplication(AbstractApplicationRegistrationWorkflowExecutor.java:155)
at org.wso2.carbon.apimgt.impl.workflow.AbstractApplicationRegistrationWorkflowExecutor.generateKeysForApplication(AbstractApplicationRegistrationWorkflowExecutor.java:118)
at org.wso2.carbon.apimgt.impl.workflow.ApplicationRegistrationSimpleWorkflowExecutor.complete(ApplicationRegistrationSimpleWorkflowExecutor.java:78)
... 72 more
Caused by: org.wso2.carbon.apimgt.api.APIManagementException: Can not create OAuth application : DefaultApplication_PRODUCTION
at org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl.handleException(AMDefaultKeyManagerImpl.java:636)
at org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl.createApplication(AMDefaultKeyManagerImpl.java:110)
at org.wso2.carbon.apimgt.impl.workflow.AbstractApplicationRegistrationWorkflowExecutor.dogenerateKeysForApplication(AbstractApplicationRegistrationWorkflowExecutor.java:139)
... 74 more
Caused by: org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:326)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:196)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:451)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:278)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:430)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.wso2.carbon.apimgt.keymgt.stub.subscriber.APIKeyMgtSubscriberServiceStub.createOAuthApplicationByApplicationInfo(APIKeyMgtSubscriberServiceStub.java:2393)
at org.wso2.carbon.apimgt.keymgt.client.SubscriberKeyMgtClient.createOAuthApplicationbyApplicationInfo(SubscriberKeyMgtClient.java:62)
at org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl.createApplication(AMDefaultKeyManagerImpl.java:108)
... 75 more
TID: [-1234] [] [2016-09-22 13:57:11,569] ERROR {org.wso2.carbon.apimgt.hostobjects.APIStoreHostObject} - Error while obtaining the application access token for the application:DefaultApplication {org.wso2.carbon.apimgt.hostobjects.APIStoreHostObject}
org.wso2.carbon.apimgt.api.APIManagementException: Could not execute Workflow
at org.wso2.carbon.apimgt.impl.APIConsumerImpl.requestApprovalForApplicationRegistration(APIConsumerImpl.java:2815)
at org.wso2.carbon.apimgt.impl.UserAwareAPIConsumer.requestApprovalForApplicationRegistration(UserAwareAPIConsumer.java:36)
at org.wso2.carbon.apimgt.hostobjects.APIStoreHostObject.jsFunction_getApplicationKey(APIStoreHostObject.java:382)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:126)
at org.mozilla.javascript.FunctionObject.call(FunctionObject.java:386)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
at org.jaggeryjs.rhino.store.modules.subscription.c3._c_anonymous_2(/store/modules/subscription/key.jag:39)
at org.jaggeryjs.rhino.store.modules.subscription.c3.call(/store/modules/subscription/key.jag)
at org.mozilla.javascript.ScriptRuntime.applyOrCall(ScriptRuntime.java:2430)
at org.mozilla.javascript.BaseFunction.execIdCall(BaseFunction.java:269)
at org.mozilla.javascript.IdFunctionObject.call(IdFunctionObject.java:97)
at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)
at org.jaggeryjs.rhino.store.modules.subscription.c0._c_anonymous_11(/store/modules/subscription/module.jag:38)
at org.jaggeryjs.rhino.store.modules.subscription.c0.call(/store/modules/subscription/module.jag)
at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0._c_anonymous_1(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag:240)
at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0.call(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag)
at org.mozilla.javascript.optimizer.OptRuntime.call0(OptRuntime.java:23)
at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0._c_script_0(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag:3)
at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0.call(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0.call(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag)
at org.jaggeryjs.rhino.store.site.blocks.subscription.subscription_add.ajax.c0.exec(/store/site/blocks/subscription/subscription-add/ajax/subscription-add.jag)
at org.jaggeryjs.scriptengine.engine.RhinoEngine.execScript(RhinoEngine.java:567)
at org.jaggeryjs.scriptengine.engine.RhinoEngine.exec(RhinoEngine.java:273)
at org.jaggeryjs.jaggery.core.manager.WebAppManager.exec(WebAppManager.java:588)
at org.jaggeryjs.jaggery.core.manager.WebAppManager.execute(WebAppManager.java:508)
at org.jaggeryjs.jaggery.core.JaggeryServlet.doPost(JaggeryServlet.java:29)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:377)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)
at org.jaggeryjs.jaggery.core.JaggeryFilter.doFilter(JaggeryFilter.java:21)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:120)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:99)
at org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
at org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:57)
at org.wso2.carbon.event.receiver.core.internal.tenantmgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:48)
at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:62)
at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:159)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:57)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1749)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1708)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.wso2.carbon.apimgt.impl.workflow.WorkflowException: Error occurred when updating the status of the Application creation process
at org.wso2.carbon.apimgt.impl.workflow.ApplicationRegistrationSimpleWorkflowExecutor.complete(ApplicationRegistrationSimpleWorkflowExecutor.java:82)
at org.wso2.carbon.apimgt.impl.workflow.ApplicationRegistrationSimpleWorkflowExecutor.execute(ApplicationRegistrationSimpleWorkflowExecutor.java:54)
at org.wso2.carbon.apimgt.impl.APIConsumerImpl.requestApprovalForApplicationRegistration(APIConsumerImpl.java:2790)
... 70 more
Caused by: org.wso2.carbon.apimgt.api.APIManagementException: Error occurred while executing SubscriberKeyMgtClient.
at org.wso2.carbon.apimgt.impl.utils.APIUtil.handleException(APIUtil.java:1195)
at org.wso2.carbon.apimgt.impl.workflow.AbstractApplicationRegistrationWorkflowExecutor.dogenerateKeysForApplication(AbstractApplicationRegistrationWorkflowExecutor.java:155)
at org.wso2.carbon.apimgt.impl.workflow.AbstractApplicationRegistrationWorkflowExecutor.generateKeysForApplication(AbstractApplicationRegistrationWorkflowExecutor.java:118)
at org.wso2.carbon.apimgt.impl.workflow.ApplicationRegistrationSimpleWorkflowExecutor.complete(ApplicationRegistrationSimpleWorkflowExecutor.java:78)
... 72 more
Caused by: org.wso2.carbon.apimgt.api.APIManagementException: Can not create OAuth application : DefaultApplication_PRODUCTION
at org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl.handleException(AMDefaultKeyManagerImpl.java:636)
at org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl.createApplication(AMDefaultKeyManagerImpl.java:110)
at org.wso2.carbon.apimgt.impl.workflow.AbstractApplicationRegistrationWorkflowExecutor.dogenerateKeysForApplication(AbstractApplicationRegistrationWorkflowExecutor.java:139)
... 74 more
Caused by: org.apache.axis2.AxisFault: Transport error: 401 Error: Unauthorized
at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:326)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:196)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:451)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:278)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:430)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.wso2.carbon.apimgt.keymgt.stub.subscriber.APIKeyMgtSubscriberServiceStub.createOAuthApplicationByApplicationInfo(APIKeyMgtSubscriberServiceStub.java:2393)
at org.wso2.carbon.apimgt.keymgt.client.SubscriberKeyMgtClient.createOAuthApplicationbyApplicationInfo(SubscriberKeyMgtClient.java:62)
at org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl.createApplication(AMDefaultKeyManagerImpl.java:108)
... 75 more
TID: [-1234] [] [2016-09-22 13:57:11,574] ERROR {JAGGERY.site.blocks.subscription.subscription-add.ajax.subscription-add:jag} - org.jaggeryjs.scriptengine.exceptions.ScriptException: Error while obtaining the application access token for the application:DefaultApplication {JAGGERY.site.blocks.subscription.subscription-add.ajax.subscription-add:jag}
The "401 Error: Unauthorized" seems like it might be the key, but I know my credentials are correct because I used them to log in.
What's particularly interesting is, I only get this error when I'm using my company's LDAP server as the primary user store.
Here's a snippet from my {server-home}/repository/conf/user-mgt.xml:
<UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadOnlyLDAPUserStoreManager">
<Property name="TenantManager">org.wso2.carbon.user.core.tenant.CommonHybridLDAPTenantManager</Property>
<Property name="ConnectionURL">ldap://localhost:1389</Property>
<Property name="ConnectionName">CN=Steven McClellan,CN=Users,DC=Nanofluidics,DC=com</Property>
<Property name="ConnectionPassword">passwordgoeshere</Property>
<Property name="UserSearchBase">CN=Users,DC=Nanofluidics,DC=com</Property>
<Property name="UserNameAttribute">uid</Property>
<Property name="UserNameSearchFilter">(&(objectClass=person)(uid=?))</Property>
<Property name="UserNameListFilter">(objectClass=person)</Property>
<Property name="DisplayNameAttribute"/>
<Property name="ReadGroups">true</Property>
<Property name="GroupSearchBase">CN=Users,DC=Nanofluidics,DC=com</Property>
<Property name="GroupNameAttribute">cn</Property>
<Property name="GroupNameSearchFilter">(&(objectClass=group)(cn=?))</Property>
<Property name="GroupNameListFilter">(objectClass=group)</Property>
<Property name="MembershipAttribute">member</Property>
<Property name="BackLinksEnabled">false</Property>
<Property name="UsernameJavaRegEx">[a-zA-Z0-9._-|//]{3,50}$</Property>
<Property name="PasswordJavaRegEx">^[\S]{5,50}$</Property>
<Property name="RolenameJavaRegEx">[a-zA-Z0-9._-|//]{3,100}$</Property>
<Property name="SCIMEnabled">false</Property>
<Property name="PasswordHashMethod">PLAIN_TEXT</Property>
<Property name="MultiAttributeSeparator">,</Property>
<Property name="MaxUserNameListLength">100</Property>
<Property name="MaxRoleNameListLength">100</Property>
<Property name="UserRolesCacheEnabled">true</Property>
<Property name="ConnectionPoolingEnabled">true</Property>
<Property name="LDAPConnectionTimeout">5000</Property>
<Property name="ReadTimeout"/>
<Property name="RetryAttempts"/>
<Property name="ReplaceEscapeCharactersAtUserLogin">true</Property>
</UserStoreManager>
(Note that I'm connecting to the LDAP server via an ssh tunnel at localhost:1389)
When I instead configure to connect to the test ldap server at forumsys.com, I'm able to generate application key/secret pairs successfully. Here's a snippet of the user-mgt.xml for that setup:
<UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadOnlyLDAPUserStoreManager">
<Property name="TenantManager">org.wso2.carbon.user.core.tenant.CommonHybridLDAPTenantManager</Property>
<Property name="ConnectionURL">ldap://ldap.forumsys.com:389</Property>
<Property name="ConnectionName">cn=read-only-admin,dc=example,dc=com</Property>
<Property name="ConnectionPassword">password</Property>
<Property name="UserSearchBase">dc=example,dc=com</Property>
<Property name="UserNameAttribute">cn</Property>
<Property name="UserNameSearchFilter">(&(objectClass=person)(cn=?))</Property>
<Property name="UserNameListFilter">(objectClass=person)</Property>
<Property name="DisplayNameAttribute"/>
<Property name="ReadGroups">true</Property>
<Property name="GroupSearchBase">dc=example,dc=com</Property>
<Property name="GroupNameAttribute">cn</Property>
<Property name="GroupNameSearchFilter">(&(objectClass=groupOfUniqueNames)(cn=?))</Property>
<Property name="GroupNameListFilter">(objectClass=groupOfUniqueNames)</Property>
<Property name="MembershipAttribute">uniqueMember</Property>
<Property name="BackLinksEnabled">false</Property>
<Property name="UsernameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
<Property name="PasswordJavaRegEx">^[\S]{5,30}$</Property>
<Property name="RolenameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
<Property name="SCIMEnabled">false</Property>
<Property name="PasswordHashMethod">PLAIN_TEXT</Property>
<Property name="MultiAttributeSeparator">,</Property>
<Property name="MaxUserNameListLength">100</Property>
<Property name="MaxRoleNameListLength">100</Property>
<Property name="UserRolesCacheEnabled">true</Property>
<Property name="ConnectionPoolingEnabled">true</Property>
<Property name="LDAPConnectionTimeout">5000</Property>
<Property name="ReadTimeout"/>
<Property name="RetryAttempts"/>
<Property name="ReplaceEscapeCharactersAtUserLogin">true</Property>
</UserStoreManager>
Also noteworthy is the fact that this is the only operation that fails with this configuration. (That I'm aware of.) I'm able to log in to the /carbon, /publisher, and /store pages. I'm able to create, manage, publish, and subscribe to APIs. I'm able to create and manage users and roles. Etc., etc.
So I'm pretty confused. Can anyone help me out?
Faced the same error and fixed by setting correct datasource at identity.xml at IS
I am getting an error whenever I tried to redeploy the app to the esb. I am trying to merge the 2 response from different api and then map and manipulate that response. I am also using the latest 5.0.0 BETA version both esb tooling and esb.
Here is the fault reason
org.apache.axis2.deployment.DeploymentException: API deployment from
the file :
/Users/me/Downloads/wso2esb-5.0.0-BETA2/tmp/carbonapps/-1234/1468999438631movieapiApp_1.0.0.car/movieAPI_1.0.0/movieAPI-1.0.0.xml
: Failed. at
org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:213)
at
org.wso2.carbon.application.deployer.synapse.SynapseAppDeployer.deployArtifacts(SynapseAppDeployer.java:131)
at
org.wso2.carbon.application.deployer.internal.ApplicationManager.deployCarbonApp(ApplicationManager.java:263)
at
org.wso2.carbon.application.deployer.CappAxis2Deployer.deploy(CappAxis2Deployer.java:72)
at
org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:136)
at
org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:807)
at
org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:144)
at
org.apache.axis2.deployment.RepositoryListener.update(RepositoryListener.java:377)
at
org.apache.axis2.deployment.RepositoryListener.checkServices(RepositoryListener.java:254)
at
org.apache.axis2.deployment.RepositoryListener.startListener(RepositoryListener.java:371)
at
org.apache.axis2.deployment.scheduler.SchedulerTask.checkRepository(SchedulerTask.java:59)
at
org.apache.axis2.deployment.scheduler.SchedulerTask.run(SchedulerTask.java:67)
at
org.wso2.carbon.core.deployment.CarbonDeploymentSchedulerTask.runAxisDeployment(CarbonDeploymentSchedulerTask.java:93)
at
org.wso2.carbon.core.deployment.CarbonDeploymentSchedulerTask.run(CarbonDeploymentSchedulerTask.java:138)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745) Caused by:
org.apache.axis2.deployment.DeploymentException: API deployment from
the file :
/Users/me/Downloads/wso2esb-5.0.0-BETA2/tmp/carbonapps/-1234/1468999438631movieapiApp_1.0.0.car/movieAPI_1.0.0/movieAPI-1.0.0.xml
: Failed. at
org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:201)
... 20 more Caused by:
org.apache.synapse.deployers.SynapseArtifactDeploymentException: API
deployment from the file :
/Users/me/Downloads/wso2esb-5.0.0-BETA2/tmp/carbonapps/-1234/1468999438631movieapiApp_1.0.0.car/movieAPI_1.0.0/movieAPI-1.0.0.xml
: Failed. at
org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.handleSynapseArtifactDeploymentError(AbstractSynapseArtifactDeployer.java:474)
at
org.apache.synapse.deployers.APIDeployer.deploySynapseArtifact(APIDeployer.java:71)
at
org.wso2.carbon.rest.api.ApiDeployer.deploySynapseArtifact(ApiDeployer.java:34)
at
org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:194)
... 20 more Caused by: org.apache.synapse.SynapseException: Duplicate
resource definition by the name: movieapi at
org.apache.synapse.config.SynapseConfiguration.handleException(SynapseConfiguration.java:1627)
at
org.apache.synapse.config.SynapseConfiguration.addAPI(SynapseConfiguration.java:414)
at
org.apache.synapse.deployers.APIDeployer.deploySynapseArtifact(APIDeployer.java:59)
... 22 more
and here's my api
<?xml version="1.0" encoding="UTF-8"?>
<api context="/movieapi" name="movieapi" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" uri-template="/*">
<inSequence>
<property name="ROOT" scope="default">
<root:movie xmlns:root="www.wso2esb.com"/>
</property>
<log level="full"/>
<clone continueParent="true" id="movie" sequential="true">
<target>
<sequence>
<send>
<endpoint>
<address format="rest" uri="https://api.themoviedb.org/3/movie/tt0918940?api_key=code&append_to_response=casts,images%22"/>
</endpoint>
</send>
</sequence>
</target>
<target>
<sequence>
<send>
<endpoint>
<address format="rest" uri="https://www.omdbapi.com/?type=movie&i=tt0918940"/>
</endpoint>
</send>
</sequence>
</target>
</clone>
</inSequence>
<outSequence>
<aggregate id="movie">
<completeCondition>
<messageCount max="-1" min="-1"/>
</completeCondition>
<onComplete enclosingElementProperty="ROOT" expression="//jsonObject" xmlns:dummy="http://org.dummy" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<datamapper config="gov:datamapper/movieapiMapping.dmc" inputSchema="gov:datamapper/movieapiMapping_inputSchema.json" inputType="JSON" outputSchema="gov:datamapper/movieapiMapping_outputSchema.json" outputType="JSON"/>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<respond/>
</onComplete>
</aggregate>
</outSequence>
<faultSequence/>
</resource>
</api>
and this is from the terminal
[2016-07-20 15:36:48,890] ERROR - DataMapperMediator DataMapper mediator : mapping configuration is null
The error you are getting in the terminal DataMapperMediator DataMapper mediator : mapping configuration is null is because the relevant registry resources are not deployed (more precisely, the configuration .dmc file). When you are deploying the capp, make sure that all the registry resources are included as well. Also when the capp deployment fails, can you check in the management console for any faulty services/APIs?
You get the error indicating Data mapper configurations null. So you have to add relevant configurations as you given in the proxy:
<datamapper config="gov:datamapper/movieapiMapping.dmc" inputSchema="gov:datamapper/movieapiMapping_inputSchema.json" inputType="JSON" outputSchema="gov:datamapper/movieapiMapping_outputSchema.json" outputType="JSON"/>
For example: You indicated about gov:datamapper/movieapiMapping.dmc
This should be available in governance registry.Please deploy relevant configs in to ESB.
Open the pom.xml file inside your CompositeApplication.
Edit it in the Design mode.
Under dependencies, you can see the artifacts which you can include.
Tick the checkbox near your relevant Registry artifact. Save pom file.
Now redeploy the application to the server or Regenerate your car file