Monday, August 1, 2016

[WSO2-ESB][FTP] java.io.IOException: Host attempting data connection 203.94.95.230 is not same as server 192.168.xx.xx

Issue

Following issue can occur when trying to connect to a ftp server through WSO2 ESB.


ERROR - FilePollingConsumer Error checking for existence and readability : ftp://wso2qa":***@"192.168.58.31/ESBJAVA-4493/in
org.apache.commons.vfs2.FileSystemException: Could not determine the type of file "ftp://wso2qa:***@192.168.48.231/ESBJAVA-4493/in".
 at org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:506)
 at org.apache.commons.vfs2.provider.AbstractFileObject.exists(AbstractFileObject.java:478)
 at org.wso2.carbon.inbound.endpoint.protocol.file.FilePollingConsumer.poll(FilePollingConsumer.java:172)
 at org.wso2.carbon.inbound.endpoint.protocol.file.FilePollingConsumer.execute(FilePollingConsumer.java:134)
 at org.wso2.carbon.inbound.endpoint.protocol.file.FileTask.taskExecute(FileTask.java:45)
 at org.wso2.carbon.inbound.endpoint.common.InboundTask.execute(InboundTask.java:44)
 at org.wso2.carbon.mediation.ntask.NTaskAdapter.execute(NTaskAdapter.java:90)
 at org.wso2.carbon.ntask.core.impl.TaskQuartzJobAdapter.execute(TaskQuartzJobAdapter.java:67)
 at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
 at java.util.concurrent.FutureTask.run(FutureTask.java:266)
 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: java.io.IOException: Host attempting data connection 203.94.95.230 is not same as server 192.168.xx.xx
 at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:912)
 at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:759)
 at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:3293)
 at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:3271)
 at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2930)
 at org.apache.commons.vfs2.provider.ftp.FTPClientWrapper.listFilesInDirectory(FTPClientWrapper.java:186)
 at org.apache.commons.vfs2.provider.ftp.FTPClientWrapper.listFiles(FTPClientWrapper.java:176)
 at org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetChildren(FtpFileObject.java:141)
 at org.apache.commons.vfs2.provider.ftp.FtpFileObject.getChildFile(FtpFileObject.java:111)
 at org.apache.commons.vfs2.provider.ftp.FtpFileObject.getInfo(FtpFileObject.java:200)
 at org.apache.commons.vfs2.provider.ftp.FtpFileObject.doGetType(FtpFileObject.java:335)
 at org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:497)
 ... 13 more


This error can occur when the server is trying to do a non passive connection to the FTP server.

Remedy

This issue can be avoided by making a passive connection to the ESB. You can modify the connection URL in the below format to achieve this.

ftp://wso2qa:wso2qa123@192.168.58.31/ESBJAVA-4493/in?vfs.passive=true


Tuesday, February 9, 2016

Error when invoking a secured proxy service WSO2 ESB

Issue

When invoking a secure proxy service you might come accross the following exception.




ERROR - AxisEngine The security token could not be authenticated or authorized; nested exception is: 
 javax.security.auth.callback.UnsupportedCallbackException: Check failed : System error
org.apache.axis2.AxisFault: The security token could not be authenticated or authorized; nested exception is: 
 javax.security.auth.callback.UnsupportedCallbackException: Check failed : System error
 at org.apache.rampart.handler.RampartReceiver.setFaultCodeAndThrowAxisFault(RampartReceiver.java:180)
 at org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:95)
 at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
 at org.apache.axis2.engine.Phase.invoke(Phase.java:313)
 at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:261)
 at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:167)
 at org.wso2.carbon.core.multitenancy.MultitenantMessageReceiver.doSOAP(MultitenantMessageReceiver.java:281)
 at org.wso2.carbon.core.multitenancy.MultitenantMessageReceiver.processRequest(MultitenantMessageReceiver.java:226)
 at org.wso2.carbon.core.multitenancy.MultitenantMessageReceiver.receive(MultitenantMessageReceiver.java:78)
 at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
 at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:395)
 at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:142)
 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)
Caused by: org.apache.ws.security.WSSecurityException: The security token could not be authenticated or authorized; nested exception is: 
 javax.security.auth.callback.UnsupportedCallbackException: Check failed : System error
 at org.apache.ws.security.processor.UsernameTokenProcessor.handleUsernameToken(UsernameTokenProcessor.java:180)
 at org.apache.ws.security.processor.UsernameTokenProcessor.handleToken(UsernameTokenProcessor.java:61)
 at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:332)
 at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:249)
 at org.apache.rampart.RampartEngine.process(RampartEngine.java:214)
 at org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:92)
 ... 14 more
Caused by: javax.security.auth.callback.UnsupportedCallbackException: Check failed : System error
 at org.wso2.carbon.security.util.ServicePasswordCallbackHandler.handle(ServicePasswordCallbackHandler.java:112)
 at org.apache.rampart.TokenCallbackHandler.handle(TokenCallbackHandler.java:116)
 at org.apache.ws.security.processor.UsernameTokenProcessor.handleUsernameToken(UsernameTokenProcessor.java:168)
 ... 19 more
[2016-02-09 15:15:53,616] ERROR - ServerWorker Error processing POST reguest for : /services/t/test.com/SimpleProxy.SimpleProxyHttpSoap11Endpoint. Error detail: org.apache.axiom.om.impl.dom.ElementImpl cannot be cast to org.apache.axiom.soap.SOAPHeaderBlock. 
java.lang.ClassCastException: org.apache.axiom.om.impl.dom.ElementImpl cannot be cast to org.apache.axiom.soap.SOAPHeaderBlock
 at org.wso2.carbon.security.pox.POXSecurityHandler.isSOAPWithoutSecHeader(POXSecurityHandler.java:362)
 at org.wso2.carbon.security.pox.POXSecurityHandler.invoke(POXSecurityHandler.java:102)
 at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
 at org.apache.axis2.engine.Phase.invoke(Phase.java:313)
 at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:261)
 at org.apache.axis2.engine.AxisEngine.sendFault(AxisEngine.java:515)
 at org.wso2.carbon.core.multitenancy.MultitenantMessageReceiver.doSOAP(MultitenantMessageReceiver.java:325)
 at org.wso2.carbon.core.multitenancy.MultitenantMessageReceiver.processRequest(MultitenantMessageReceiver.java:226)
 at org.wso2.carbon.core.multitenancy.MultitenantMessageReceiver.receive(MultitenantMessageReceiver.java:78)
 at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
 at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:395)
 at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:142)
 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)


Possible Reason

One possible reason for this error is that the Authentication details (User Credentials) you are parsing are incorrect. The above exception doesn't give any indication about invalid user credentials so the users might get misleaded.


Remedy

If you see the above exception double check the user credentials you are parsing in the WSS header. Also check the allowed roles and the policy. This might be the root cause of the issue.




Error When Deploying a CAR App to WSO2 ESB


Issue

When deploying a CAR File to WSO2 ESB you might come accross the following exception. In my case I came accross the following issue when uploading a secure CAR app.



ERROR - ProxyServiceDeployer ProxyService Deployment from the file : /home/yasassri/Support/MYSUP/wso2esb-4.9.0/tmp/carbonapps/-1234/1455007998187Sec_CarApp_1.0.0.car/SimpleProxy_1.0.0/SimpleProxy-1.0.0.xml : Failed.
org.apache.synapse.SynapseException: Cannot convert null to a StreamSource
 at org.apache.synapse.config.SynapseConfigUtils.handleException(SynapseConfigUtils.java:578)
 at org.apache.synapse.config.SynapseConfigUtils.getStreamSource(SynapseConfigUtils.java:79)
 at org.apache.synapse.core.axis2.ProxyService.getPolicyFromKey(ProxyService.java:822)
 at org.apache.synapse.core.axis2.ProxyService.buildAxisService(ProxyService.java:608)
 at org.apache.synapse.deployers.ProxyServiceDeployer.deploySynapseArtifact(ProxyServiceDeployer.java:80)
 at org.wso2.carbon.proxyadmin.ProxyServiceDeployer.deploySynapseArtifact(ProxyServiceDeployer.java:46)
 at org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:194)
 at org.wso2.carbon.application.deployer.synapse.SynapseAppDeployer.deployArtifacts(SynapseAppDeployer.java:130)
 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)
[2016-02-09 14:23:18,210] ERROR - AbstractSynapseArtifactDeployer Deployment of the Synapse Artifact from file : /home/yasassri/Support/MYSUP/wso2esb-4.9.0/tmp/carbonapps/-1234/1455007998187Sec_CarApp_1.0.0.car/SimpleProxy_1.0.0/SimpleProxy-1.0.0.xml : Failed!
org.apache.synapse.deployers.SynapseArtifactDeploymentException: ProxyService Deployment from the file : /home/yasassri/Support/MYSUP/wso2esb-4.9.0/tmp/carbonapps/-1234/1455007998187Sec_CarApp_1.0.0.car/SimpleProxy_1.0.0/SimpleProxy-1.0.0.xml : Failed.
 at org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.handleSynapseArtifactDeploymentError(AbstractSynapseArtifactDeployer.java:475)
 at org.apache.synapse.deployers.ProxyServiceDeployer.deploySynapseArtifact(ProxyServiceDeployer.java:112)
 at org.wso2.carbon.proxyadmin.ProxyServiceDeployer.deploySynapseArtifact(ProxyServiceDeployer.java:46)
 at org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:194)
 at org.wso2.carbon.application.deployer.synapse.SynapseAppDeployer.deployArtifacts(SynapseAppDeployer.java:130)
 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.synapse.SynapseException: Cannot convert null to a StreamSource
 at org.apache.synapse.config.SynapseConfigUtils.handleException(SynapseConfigUtils.java:578)
 at org.apache.synapse.config.SynapseConfigUtils.getStreamSource(SynapseConfigUtils.java:79)
 at org.apache.synapse.core.axis2.ProxyService.getPolicyFromKey(ProxyService.java:822)
 at org.apache.synapse.core.axis2.ProxyService.buildAxisService(ProxyService.java:608)
 at org.apache.synapse.deployers.ProxyServiceDeployer.deploySynapseArtifact(ProxyServiceDeployer.java:80)
 ... 22 more
[2016-02-09 14:23:18,211]  INFO - AbstractSynapseArtifactDeployer The file has been backed up into : NO_BACKUP_ON_WORKER.INFO
[2016-02-09 14:23:18,212] ERROR - AbstractSynapseArtifactDeployer Deployment of synapse artifact failed. Error reading /home/yasassri/Support/MYSUP/wso2esb-4.9.0/tmp/carbonapps/-1234/1455007998187Sec_CarApp_1.0.0.car/SimpleProxy_1.0.0/SimpleProxy-1.0.0.xml : ProxyService Deployment from the file : /home/yasassri/Support/MYSUP/wso2esb-4.9.0/tmp/carbonapps/-1234/1455007998187Sec_CarApp_1.0.0.car/SimpleProxy_1.0.0/SimpleProxy-1.0.0.xml : Failed.
org.apache.axis2.deployment.DeploymentException: ProxyService Deployment from the file : /home/yasassri/Support/MYSUP/wso2esb-4.9.0/tmp/carbonapps/-1234/1455007998187Sec_CarApp_1.0.0.car/SimpleProxy_1.0.0/SimpleProxy-1.0.0.xml : Failed.
 at org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:201)
 at org.wso2.carbon.application.deployer.synapse.SynapseAppDeployer.deployArtifacts(SynapseAppDeployer.java:130)
 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.synapse.deployers.SynapseArtifactDeploymentException: ProxyService Deployment from the file : /home/yasassri/Support/MYSUP/wso2esb-4.9.0/tmp/carbonapps/-1234/1455007998187Sec_CarApp_1.0.0.car/SimpleProxy_1.0.0/SimpleProxy-1.0.0.xml : Failed.
 at org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.handleSynapseArtifactDeploymentError(AbstractSynapseArtifactDeployer.java:475)
 at org.apache.synapse.deployers.ProxyServiceDeployer.deploySynapseArtifact(ProxyServiceDeployer.java:112)
 at org.wso2.carbon.proxyadmin.ProxyServiceDeployer.deploySynapseArtifact(ProxyServiceDeployer.java:46)
 at org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:194)
 ... 20 more
Caused by: org.apache.synapse.SynapseException: Cannot convert null to a StreamSource
 at org.apache.synapse.config.SynapseConfigUtils.handleException(SynapseConfigUtils.java:578)
 at org.apache.synapse.config.SynapseConfigUtils.getStreamSource(SynapseConfigUtils.java:79)
 at org.apache.synapse.core.axis2.ProxyService.getPolicyFromKey(ProxyService.java:822)
 at org.apache.synapse.core.axis2.ProxyService.buildAxisService(ProxyService.java:608)
 at org.apache.synapse.deployers.ProxyServiceDeployer.deploySynapseArtifact(ProxyServiceDeployer.java:80)
 ... 22 more
[2016-02-09 14:23:18,213] ERROR - ApplicationManager Error occurred while deploying Carbon Application
org.apache.axis2.deployment.DeploymentException: ProxyService Deployment from the file : /home/yasassri/Support/MYSUP/wso2esb-4.9.0/tmp/carbonapps/-1234/1455007998187Sec_CarApp_1.0.0.car/SimpleProxy_1.0.0/SimpleProxy-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:130)
 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: ProxyService Deployment from the file : /home/yasassri/Support/MYSUP/wso2esb-4.9.0/tmp/carbonapps/-1234/1455007998187Sec_CarApp_1.0.0.car/SimpleProxy_1.0.0/SimpleProxy-1.0.0.xml : Failed.
 at org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:201)
 ... 20 more
Caused by: org.apache.synapse.deployers.SynapseArtifactDeploymentException: ProxyService Deployment from the file : /home/yasassri/Support/MYSUP/wso2esb-4.9.0/tmp/carbonapps/-1234/1455007998187Sec_CarApp_1.0.0.car/SimpleProxy_1.0.0/SimpleProxy-1.0.0.xml : Failed.
 at org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.handleSynapseArtifactDeploymentError(AbstractSynapseArtifactDeployer.java:475)
 at org.apache.synapse.deployers.ProxyServiceDeployer.deploySynapseArtifact(ProxyServiceDeployer.java:112)
 at org.wso2.carbon.proxyadmin.ProxyServiceDeployer.deploySynapseArtifact(ProxyServiceDeployer.java:46)
 at org.apache.synapse.deployers.AbstractSynapseArtifactDeployer.deploy(AbstractSynapseArtifactDeployer.java:194)
 ... 20 more
Caused by: org.apache.synapse.SynapseException: Cannot convert null to a StreamSource
 at org.apache.synapse.config.SynapseConfigUtils.handleException(SynapseConfigUtils.java:578)
 at org.apache.synapse.config.SynapseConfigUtils.getStreamSource(SynapseConfigUtils.java:79)
 at org.apache.synapse.core.axis2.ProxyService.getPolicyFromKey(ProxyService.java:822)
 at org.apache.synapse.core.axis2.ProxyService.buildAxisService(ProxyService.java:608)
 at org.apache.synapse.deployers.ProxyServiceDeployer.deploySynapseArtifact(ProxyServiceDeployer.java:80)
 ... 22 more
[2016-02-09 14:23:18,215]  INFO - ApplicationManager Reverting successfully deployed artifcats in this CApp : Sec_CarApp_1.0.0


Possible Reason

Possible reason for this issue is that by default when you create a registry resource in Dev studio the default server role is set as governance registry. So when you try to upload a such CAR to ESB you might see the above issue.



Remedy

In order to oversome this issue you can change the server profile of the project to ESBProject. To do this follow the instructions below.

1. Create a composite application project (Whic is needed to create a CAR app) and select export as a composite application project option. This will bring up CAR app creation wizard.



2. Now click next and you will see the project selection page. In this expand the Registry resource project created for ESB and set the Server role. Refer the following





After doing the above hopefully it will solve the issue. please drop a comment if you have any queries.


Thursday, July 23, 2015

Message processor runs infinitely without dequing messages - WSO2 ESB

This issue appeared when working with ESB message processors, I had configured the message processor to listen to a ActiveMQ queue which already had messages. I was using ESB 4.9

Issue

Here I face a issue where the Message processor keeps on sending the messages infinitely. The following errors were observed.

ERROR - ForwardingService BlockingMessageSender of message processor [InMEn_Proc2] failed to send message to the endpoint
[2015-07-21 21:55:38,062]  WARN - ForwardingService Failed to send the message through the fault sequence. Sequence name does not Exist.

The reason.

The reason for this issue is the ESB is following the guaranteed delivery precautions, ESB is waiting till the message delivered successfully.

How to get this fixed

The easiest way to fix this is make the ESB ignore the message after sending the message out. You can do this by setting the following properties.

<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2" />
<property name="OUT_ONLY" value="true" />

You need to add these properties before storing the message in the store. Refer the following sample API.


<api xmlns="http://ws.apache.org/ns/synapse" name="api" context="/api">
   <resource methods="POST GET">
      <inSequence>
         <log level="custom">
            <property name="VALUE" value="********* IN GET RESOURCE *********"/>
         </log>
         <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
         <property name="OUT_ONLY" value="true"/>
         <store messageStore="ActivMQ_Store2"/>
         <send>
            <endpoint key="POSTEP"/>
         </send>
      </inSequence>
   </resource>
</api>


Monday, June 22, 2015

Swagger Definition is not getting added when Creating an API with Publisher APIs in WSO2 API Manager 1.8

When creating a API with Publisher APIs the swagger definition may not get added, actually this is a known issue in Api Manager 1.8 and this is being fixed in Api Manager 1.9 release with the added capabilities of Swagger 2.0.

So How can you get this fixed. Actually its not straight forward to fix this issue, We can follow a workaround instead. The workaround is, after creating the API with Publisher APIs, you can add the Swagger definition separately.  Please follow the following commands to achieve this.

First Lets Create the API

curl -k -X POST -b cookies https://localhost:9443/publisher/site/blocks/item-add/ajax/add.jag -d 'action=addAPI&name=MyNewAPI6&visibility=public&version=1.0&description=My New API created and published by curl&endpointType=secured&http_checked=&https_checked=https&wsdl=&tags=automated published&tier=Gold&thumbUrl=https://pbs.twimg.com/profile_images/493735622587064320/z7qZUG0E_bigger.png&context=/apicurl6&tiersCollection=Gold,Silver,Bronze,Unlimited&resourceCount=5&resourceMethod-0=GET&resourceMethodAuthType-0=Application,Application User&resourceMethodThrottlingTier-0=Unlimited&uriTemplate-0=/assignments&resourceMethod-1=OPTIONS&resourceMethodAuthType-1=None&resourceMethodThrottlingTier-1=Unlimited&uriTemplate-1=/assignments&resourceMethod-2=GET&resourceMethodAuthType-2=Application,Application User&resourceMethodThrottlingTier-2=Unlimited&uriTemplate-2=/journeys&resourceMethod-3=OPTIONS&resourceMethodAuthType-3=None&resourceMethodThrottlingTier-3=Unlimited&uriTemplate-3=/journeys&resourceMethod-4=GET&resourceMethodAuthType-4=Application,Application User&resourceMethodThrottlingTier-4=Unlimited&uriTemplate-4=/info&resourceMethod-5=OPTIONS&resourceMethodAuthType-5=None&resourceMethodThrottlingTier-5=Unlimited&uriTemplate-5=/info' -d 'endpoint_config={"production_endpoints":{"url":"https://internal-mysampleapi.com:9443","config":null}, "sandbox_endpoints": {"url":"https://internal-mysampleapi.com:9443/mock","config":null},"endpoint_type":"http"}'

Now Lets add the Swagger Definition


curl -F name="MyNewAPI6" -F version="1.0" -F provider="admin" -F action="manage" -F swagger='{"apiVersion":"1.0","swaggerVersion":"1.2","authorizations":{"oauth2":{"scopes":[],"type":"oauth2"}},"apis":[{"index":0,"file":{"apiVersion":"1.0","basePath":"http://10.100.5.112:8280/newapi2/1.0","swaggerVersion":"1.2","resourcePath":"/assignments","apis":[{"index":0,"path":"/assignments","operations":[{"nickname":"get_assignments","method":"GET","parameters":[{"dataType":"String","description":"AccessToken","name":"Authorization","allowMultiple":false,"required":true,"paramType":"header"},{"description":"RequestBody","name":"body","allowMultiple":false,"required":true,"type":"string","paramType":"body"}]},{"nickname":"options_assignments","method":"OPTIONS","parameters":[{"dataType":"String","description":"Access Token","name":"Authorization","allowMultiple":false,"required":true,"paramType":"header"},{"description":"RequestBody","name":"body","allowMultiple":false,"required":true,"type":"string","paramType":"body"}]}]}]},"description":"","path":"/assignments"},{"index":1,"file":{"apiVersion":"1.0","basePath":"http://10.100.5.112:8280/newapi2/1.0","swaggerVersion":"1.2","resourcePath":"/info","apis":[{"index":0,"path":"/info","operations":[{"nickname":"get_info","method":"GET","parameters":[{"dataType":"String","description":"AccessToken","name":"Authorization","allowMultiple":false,"required":true,"paramType":"header"},{"description":"Request Body","name":"body","allowMultiple":false,"required":true,"type":"string","paramType":"body"}]},{"nickname":"options_info","method":"OPTIONS","parameters":[{"dataType":"String","description":"AccessToken","name":"Authorization","allowMultiple":false,"required":true,"paramType":"header"},{"description":"Request Body","name":"body","allowMultiple":false,"required":true,"type":"string","paramType":"body"}]}]}]},"description":"","path":"/info"},{"index":2,"file":{"apiVersion":"1.0","basePath":"http://10.100.5.112:8280/newapi2/1.0","swaggerVersion":"1.2","resourcePath":"/journeys","apis":[{"index":0,"path":"/journeys","operations":[{"nickname":"get_journeys","method":"GET","parameters":[{"dataType":"String","description":"AccessToken","name":"Authorization","allowMultiple":false,"required":true,"paramType":"header"},{"description":"Request Body","name":"body","allowMultiple":false,"required":true,"type":"string","paramType":"body"}]},{"nickname":"options_journeys","method":"OPTIONS","parameters":[{"dataType":"String","description":"AccessToken","name":"Authorization","allowMultiple":false,"required":true,"paramType":"header"},{"description":"Request Body","name":"body","allowMultiple":false,"required":true,"type":"string","paramType":"body"}]}]}]},"description":"","path":"/journeys"}],"info":{"title":"MyNewAPI6","termsOfServiceUrl":"","description":"","license":"","contact":"","licenseUrl":""}}' -k -X POST -b cookies https://localhost:9443/publisher/site/blocks/item-design/ajax/add.jag

Here you will have to create the swagger definition manually and parse the object according to the above format, this will add the swagger definition successfully

Another workaround is to create the API with normal Api creation EP. You can follow this log to read about this.

Monday, May 25, 2015

Error when Invoking a API - WSO2 API Manager - { Unexpected character '{' (code 123) in prolog; expected '<'}

Issue

When Invoking a API the following error was Observed.


 ERROR
{org.apache.synapse.transport.passthru.util.RelayUtils} - Error while building Passthrough stream {org.apache.synapse.transport.passthru.util.RelayUtils}
org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '{' (code 123) in prolog; expected '<'
at [row,col
{unknown-source}]: [1,1]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
at org.apache.axiom.om.impl.llom.OMDocumentImpl.getOMDocumentElement(OMDocumentImpl.java:109)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:570)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.getDocumentElement(StAXOMBuilder.java:566)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:129)
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.mediators.base.SequenceMediator.mediate(SequenceMediator.java:196)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
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:297)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:83)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:51)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:220)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:492)
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:228)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
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:722)
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '{' (code 123) in prolog; expected '<'
at [row,col {unknown-source}
]: [1,1]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:639)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2052)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1134)
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.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)


What to Note.

This issue can only occur under following circumstances.

1. If you have enabled response caching this error can be seen.
2. If you have defined a custom mediation flow to the API. (In the IN or OUT sequence) this can occur.

The reason for this issue.

If you have enabled response caching or if you have any content aware mediators with  the API invocation flow the message will get built when it reaches the GW. So as per the stacktrace the GW fails to build the message successfully. Since the GW is unable to build the message it throws this error.

One of the reason for this is mismatching Content-type header with an mismatching content body. For e.g. Consider the following DEBUG log fragment.

[2015-05-15 16:56:04,827] DEBUG {org.apache.synapse.transport.http.wire} -  >> "Content-Type: text/html[\r][\n]" {org.apache.synapse.transport.http.wire}
[AM] [2015-05-15 16:56:04,830] DEBUG {org.apache.synapse.transport.http.wire} -  >> "{"Name":"sourish"}[\r][\n]" {org.apache.synapse.transport.http.wire}

As you can see above the Content-type header is sent as text/html, but the actual content is a Json {"Name":"sourish"}. So in this case when the GW is trying to build this message this error is thrown

So in order to avoid this issue you can follow one of the options.

1. You can change the back-end service so it sends the correct Content-Type with the response.
2. You can disable response caching and test the scenario.
3. You can add the following message builder and formatter, so the message will be built as plain text. You need to add these into axis2.xml under relevant Builder and Formatter sections. axis2.xml can be found at <AM_HOME>/repository/conf/axis2 directory.
<messageBuilder contentType="text/html" class="org.apache.axis2.format.PlainTextBuilder"/>

<messageFormatter contentType="text/html" class="org.apache.axis2.format.PlainTextFormatter"/>



Error when starting WSO2 servers after changing default ports

Error

The followign error might occur when starting WSO2 servers after changin there default ports.

ERROR
{org.apache.coyote.AbstractProtocol} - Failed to start end point associated with ProtocolHandler ["http-nio-80"] {org.apache.coyote.AbstractProtocol}
java.net.SocketException: Permission denied
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:444)
at sun.nio.ch.Net.bind(Net.java:436)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:470)
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:617)
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:444)
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1010)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.wso2.carbon.tomcat.internal.CarbonTomcat.startConnectors(CarbonTomcat.java:379)
at org.wso2.carbon.tomcat.ext.transport.ServletTransportManager.startTransports(ServletTransportManager.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)


Possible Reason and Solution

You are getting this permission denied exception because the user you are running the instance does not have sufficient privileges (root permissions). All the ports below 1024 are called Privileged Ports and in Linux. Hence they are not allowed to be opened by any non-root user. It is a unix system security feature which prevents malicious users from setting up a malicious service on a well-known service port. To fix this you need to run the wso2carbon server as a root user. But before proceeding  make sure that you have setup the java environment ( setup PATH and JAVA_HOME environmental variables correctly) for the root user.