Friday, April 14, 2017

WSO2 ESB 4.8.1 support for FileConnector V2

WSO2 ESB File connector version2 introduces the atomic operation related to the file system and allows you to easily manipulate files based on your requirement. The file streaming functionality using Apache Commons I/O lets you copy large files and will reduce the file transfer time between the two file systems resulting in a significant improvement in performance that can be utilised in file operations.



File connector V2 only supports for ESB 5.0.0 ESB 4.9.0 as it is mentioned in the download page [1]. The older version of the file connector (version 1.0.0) supports ESB 4.8.1 but it is deprecated. [1].

You could follow below steps to build the connector.
  1. git clone https://github.com/wso2-extensions/esb-connector-file.git
  2. cd esb-connector-file
  3. git tag
  4. git checkout tags/org.wso2.carbon.connector.fileconnector-1.0.0
  5. mvn clean install -DskipTests
Once you build successfully, you can find the zip file inside the "PATH/esb-connector-file/target" directory. Here we have attached the fileconnector-connector-1.0.0.zip fileconnector-connector-1.0.0.zip which we got after building the code and it works fine without any error.

If you use file connector V2 in ESB 4.8.1 you will get below error.

[2017-04-14 19:33:07,660]  INFO - LibraryArtifactDeployer Synapse Library named '{org.wso2.carbon.connector}fileconnector' has been deployed from file : /home/rajjaz/Documents/support/TRIVADISAGDEV-6/wso2esb-4.8.1/repository/deployment/server/synapse-libs/fileconnector-connector-2.0.7.zip
[2017-04-14 19:33:15,881]  INFO - SynapseImportFactory Successfully created Synapse Import: fileconnector
[2017-04-14 19:33:15,900] ERROR - RPCInOnlyMessageReceiver org/apache/commons/net/ftp/FTPHTTPClient
java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPHTTPClient
 at java.lang.Class.getDeclaredConstructors0(Native Method)
 at java.lang.Class.privateGetDeclaredConstructors(Class.java:2585)
 at java.lang.Class.getConstructor0(Class.java:2885)
 at java.lang.Class.newInstance(Class.java:350)
 at org.apache.synapse.config.xml.ClassMediatorFactory.createSpecificMediator(ClassMediatorFactory.java:112)
 at org.apache.synapse.config.xml.AbstractMediatorFactory.createMediator(AbstractMediatorFactory.java:91)
 at org.apache.synapse.config.xml.MediatorFactoryFinder.getMediator(MediatorFactoryFinder.java:223)
 at org.apache.synapse.config.xml.AbstractListMediatorFactory.addChildren(AbstractListMediatorFactory.java:41)
 at org.apache.synapse.config.xml.TemplateMediatorFactory.createSpecificMediator(TemplateMediatorFactory.java:61)
 at org.apache.synapse.config.xml.AbstractMediatorFactory.createMediator(AbstractMediatorFactory.java:91)
 at org.apache.synapse.config.xml.MediatorFactoryFinder.getMediator(MediatorFactoryFinder.java:223)
 at org.apache.synapse.libraries.model.LibraryArtifact$TemplateArtifactFile.build(LibraryArtifact.java:190)
 at org.apache.synapse.libraries.model.LibraryArtifact.loadComponentsInto(LibraryArtifact.java:100)
 at org.apache.synapse.libraries.model.SynapseLibrary.loadLibrary(SynapseLibrary.java:144)
 at org.apache.synapse.libraries.model.SynapseLibrary.loadLibrary(SynapseLibrary.java:129)
 at org.apache.synapse.libraries.util.LibDeployerUtils.loadLibArtifacts(LibDeployerUtils.java:340)
 at org.wso2.carbon.mediation.library.service.MediationLibraryAdminService.addImport(MediationLibraryAdminService.java:81)
 at org.wso2.carbon.mediation.library.service.MediationLibraryAdminService.addImport(MediationLibraryAdminService.java:105)
 at org.wso2.carbon.mediation.library.service.MediationLibraryAdminService.updateStatus(MediationLibraryAdminService.java:412)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
 at org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver.invokeBusinessLogic(RPCInOnlyMessageReceiver.java:66)
 at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
 at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
 at org.apache.axis2.transport.local.LocalTransportReceiver.processMessage(LocalTransportReceiver.java:169)
 at org.apache.axis2.transport.local.LocalTransportReceiver.processMessage(LocalTransportReceiver.java:82)
 at org.wso2.carbon.core.transports.local.CarbonLocalTransportSender.finalizeSendWithToAddress(CarbonLocalTransportSender.java:45)
 at org.apache.axis2.transport.local.LocalTransportSender.invoke(LocalTransportSender.java:77)
 at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
 at org.apache.axis2.description.OutOnlyAxisOperationClient.executeImpl(OutOnlyAxisOperation.java:297)
 at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
 at org.wso2.carbon.mediation.library.stub.MediationLibraryAdminServiceStub.updateStatus(MediationLibraryAdminServiceStub.java:1476)
 at org.wso2.carbon.mediation.library.ui.LibraryAdminClient.updateStatus(LibraryAdminClient.java:114)
 at org.apache.jsp.mediation_005flibrary.import_005flib_jsp._jspService(org.apache.jsp.mediation_005flibrary.import_005flib_jsp:96)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.wso2.carbon.ui.JspServlet.service(JspServlet.java:155)
 at org.wso2.carbon.ui.TilesJspServlet.service(TilesJspServlet.java:80)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.eclipse.equinox.http.helper.ContextPathServletAdaptor.service(ContextPathServletAdaptor.java:37)
 at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
 at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
 at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:68)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.service(DelegationServlet.java:68)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
 at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:605)
 at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:544)
 at org.eclipse.equinox.http.servlet.internal.RequestDispatcherAdaptor.include(RequestDispatcherAdaptor.java:37)
 at org.eclipse.equinox.http.helper.ContextPathServletAdaptor$RequestDispatcherAdaptor.include(ContextPathServletAdaptor.java:369)
 at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:1015)
 at org.apache.jasper.runtime.PageContextImpl.include(PageContextImpl.java:700)
 at sun.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:606)
 at org.apache.tiles.jsp.context.JspUtil.doInclude(JspUtil.java:87)
 at org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:88)
 at org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:82)
 at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:465)
 at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:140)
 at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:117)
 at org.apache.tiles.jsp.taglib.RenderTagSupport.execute(RenderTagSupport.java:171)
 at org.apache.tiles.jsp.taglib.RoleSecurityTagSupport.doEndTag(RoleSecurityTagSupport.java:75)
 at org.apache.tiles.jsp.taglib.ContainerTagSupport.doEndTag(ContainerTagSupport.java:80)
 at org.apache.jsp.admin.layout.template_jsp._jspx_meth_tiles_insertAttribute_7(org.apache.jsp.admin.layout.template_jsp:603)
 at org.apache.jsp.admin.layout.template_jsp._jspService(org.apache.jsp.admin.layout.template_jsp:335)
 at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
 at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.wso2.carbon.ui.JspServlet.service(JspServlet.java:155)
 at org.wso2.carbon.ui.TilesJspServlet.service(TilesJspServlet.java:80)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.eclipse.equinox.http.helper.ContextPathServletAdaptor.service(ContextPathServletAdaptor.java:37)
 at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
 at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
 at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:68)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.service(DelegationServlet.java:68)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
 at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
 at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
 at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
 at org.eclipse.equinox.http.servlet.internal.RequestDispatcherAdaptor.forward(RequestDispatcherAdaptor.java:30)
 at org.eclipse.equinox.http.helper.ContextPathServletAdaptor$RequestDispatcherAdaptor.forward(ContextPathServletAdaptor.java:362)
 at org.apache.tiles.servlet.context.ServletTilesRequestContext.forward(ServletTilesRequestContext.java:198)
 at org.apache.tiles.servlet.context.ServletTilesRequestContext.dispatch(ServletTilesRequestContext.java:185)
 at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:419)
 at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:370)
 at org.wso2.carbon.ui.action.ActionHelper.render(ActionHelper.java:52)
 at org.wso2.carbon.ui.TilesJspServlet.service(TilesJspServlet.java:101)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.eclipse.equinox.http.helper.ContextPathServletAdaptor.service(ContextPathServletAdaptor.java:37)
 at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
 at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
 at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:68)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
 at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.service(DelegationServlet.java:68)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.wso2.carbon.tomcat.ext.filter.CharacterSetFilter.doFilter(CharacterSetFilter.java:61)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
 at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:178)
 at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:49)
 at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:141)
 at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:156)
 at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
 at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:52)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1653)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: Class Not found : org.apache.commons.net.ftp.FTPHTTPClient
 at org.apache.axis2.deployment.DeploymentClassLoader.findClass(DeploymentClassLoader.java:92)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
 at org.apache.axis2.deployment.DeploymentClassLoader.loadClass(DeploymentClassLoader.java:273)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
 ... 135 more

If you want to use file connector V2 in ESB 4.8.1 you have to follow the below steps.

We were able to deploy file connector V2 by adding the commons-net orbit bundle commons-net_3.3.0.wso2v1.jar in to a ESB 4.8.1 instance. We received this jar from ESB 4.9.0. (<ESB_HOME>/repository/components/plugins). Please find the steps we followed to test the commons-net_3.3.0.wso2v1.jar below:
  1. Placed the attached commons-net_3.3.0.wso2v1.jar r in <ESB_HOME>/repository/components/dropins
  2. Start the ESB 4.8.1
  3. Uploaded the file connector V2 and enabled it.
[2017-04-14 19:35:15,686] INFO - LibraryArtifactDeployer Synapse Library named '{org.wso2.carbon.connector}fileconnector' has been deployed from file : /home/rajjaz/Documents/support/TRIVADISAGDEV-6/wso2esb-4.8.1/repository/deployment/server/synapse-libs/fileconnector-connector-2.0.7.zip
[2017-04-14 19:35:26,721] INFO - SynapseImportFactory Successfully created Synapse Import: fileconnector

We also tested a VFS read/write scenario to check if the commons-net_3.3.0.wso2v1.jar effects the existing functionalities. Appreciate if you could test the commons-net_3.3.0.wso2v1.jar as per your requirement and let us know the feedback.