You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WSO2 Microintegrator报错:File连接器read中介未被识别求解决方案

WSO2 Microintegrator File连接器部署报错:Unknown mediator referenced by configuration element : {http://ws.apache.org/ns/synapse}file

操作背景

为在WSO2 Microintegrator项目中读取JSON文件,实践File连接器(Read mediator)的使用,执行了以下操作:

  • 创建带Connector Exporter功能的简易测试集成项目
  • 在工作区下载File连接器,Studio提示已加载

项目代码

<api context="/read" name="init" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET" uri-template="/json">
        <inSequence>
            <file.read configKey="FILE_CONNECTION_1">
                <path>test.json</path>
                <readMode>Complete File</readMode>
                <includeResultTo>Message Body</includeResultTo>
                <enableStreaming>false</enableStreaming>
                <enableLock>false</enableLock>
            </file.read>
            <respond/>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>

报错信息

导出构件并在Integration Studio集成服务器运行时,出现以下错误,应用被撤销部署:
Unknown mediator referenced by configuration element : {http://ws.apache.org/ns/synapse}file

版本信息

  • Studio版本:8.2.0
  • 服务器版本:4.2.0(外部4.3.0服务器测试结果一致)
  • File连接器版本:4.0.32

已执行的排查步骤

  • 确认项目包含Connector Exporter
  • 通过Add/Remove Connector菜单查看,File连接器已加载
  • 在内部Studio服务器和外部服务器部署均出现相同错误

解决方案及替代方案

1. 修正Connector Exporter配置

检查项目中的connector-exporter.xml文件,确保File连接器被正确声明导出。若文件不存在,手动创建并添加以下内容(注意版本与使用的连接器一致):

<connectorExporters xmlns="http://wso2.org/projects/integration/carbon/connector">
    <connectorExporter>
        <connectorName>file</connectorName>
        <version>4.0.32</version>
    </connectorExporter>
</connectorExporters>

2. 验证服务器端连接器jar包

确认Microintegrator服务器的repository/components/dropins目录下存在org.wso2.carbon.connector.file-4.0.32.jar文件。若缺失,从Integration Studio工作区的{workspace}/.metadata/.plugins/org.wso2.integrationstudio.distribution.core/components/dropins路径复制对应jar包到服务器目录,重启服务器。

3. 核对连接配置名称

确保API中引用的configKey="FILE_CONNECTION_1"与已创建的File连接配置名称完全一致,无拼写错误。

4. 替代方案:使用内置File Mediator

若连接器问题无法快速解决,可使用WSO2 MI内置的File Mediator实现文件读取,示例代码如下:

<api context="/read" name="init" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET" uri-template="/json">
        <inSequence>
            <!-- 替换为实际文件路径 -->
            <property name="transport.vfs.FileURI" value="file:///your/actual/path/test.json" scope="default" type="STRING"/>
            <property name="vfs.action" value="GET" scope="default" type="STRING"/>
            <send>
                <endpoint>
                    <address uri="vfs:file:///dummy"/>
                </endpoint>
            </send>
            <respond/>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>

内容的提问来源于stack exchange,提问作者Fidel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 11:52:38