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

Mule 4.6.7流程启动报错:Cannot invoke "Object.getClass()" because "c" is null

问题描述

在Anypoint Studio IDE中运行基于Mule Runtime 4.6.7的应用时,流程imp_get:\rest\v1\service-orders(serviceOrderId)启动失败,抛出空指针错误:Cannot invoke "Object.getClass()" because "c" is null。

错误信息

Caused by: org.mule.runtime.core.api.config.ConfigurationException: Error creating bean with name 'imp_get:\rest\v1\service-orders\(serviceOrderId)': Cannot create inner bean '(inner bean)#6f0369bd' of type [org.mule.runtime.config.internal.factories.ErrorHandlerFactoryBean_ByteBuddy_org_mule_runtime_core_internal_exception_ErrorHandler] while setting bean property 'exceptionListener'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#6f0369bd': FactoryBean threw exception on object creation; nested exception is java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "c" is null
    at org.mule.runtime.module.deployment.impl.internal.artifact.ArtifactContextBuilder.lambda$build$1(ArtifactContextBuilder.java:531) ~[mule-module-deployment-model-impl-4.6.7.jar:?]
    at org.mule.runtime.core.api.util.ExceptionUtils.tryExpecting(ExceptionUtils.java:224) ~[mule-core-4.6.7.jar:?]
    at org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader(ClassUtils.java:1102) ~[mule-core-4.6.7.jar:?]
    at org.mule.runtime.core.api.util.ClassUtils.withContextClassLoader(ClassUtils.java:1020) ~[mule-core-4.6.7.jar:?]

流程配置

<flow name="imp_get:\rest\v1\service-orders\(serviceOrderId)" doc:id="025691fe-eb05-4cc5-be58-c5d31b028c62" >
            <ee:transform doc:name="init vars" doc:id="6979887a-1fae-4af8-b102-9e3d78e2dd80">
                <ee:message />
                <ee:variables>
                    <ee:set-variable variableName="operationType"><![CDATA[%dw 2.0
    output application/java
    ---
    "api-rest"]]></ee:set-variable>
                    <ee:set-variable variableName="operationStatus"><![CDATA["success"]]></ee:set-variable>
                    <ee:set-variable variableName="businessEntityDetails"><![CDATA[%dw 2.0
    output application/json
    ---
    {
        serviceOrderId: attributes.uriParams.serviceOrderId
    }]]></ee:set-variable>
                    <ee:set-variable variableName="originalAttributes"><![CDATA[attributes]]></ee:set-variable>
                    <ee:set-variable variableName="noDataFound"><![CDATA[%dw 2.0
    output application/java
    ---
    false]]></ee:set-variable>
                    <ee:set-variable variableName="businessEntityId" ><![CDATA[%dw 2.0
    output application/java
    ---
    attributes.uriParams.serviceOrderId]]></ee:set-variable>
                </ee:variables>
            </ee:transform>
            <ee:transform doc:name="request serice order" doc:id="9f14f0b2-21ee-43c4-b902-69e286c27e3a" >
                <ee:message >
                </ee:message>
                <ee:variables >
                    <ee:set-variable variableName="serviceOrderId" ><![CDATA[%dw 2.0
    import * from dw::core::URL
    output application/json
    ---
    encodeURI(attributes.uriParams.serviceOrderId)]]></ee:set-variable>
                    <ee:set-variable variableName="queryParam" ><![CDATA[%dw 2.0
    var expandSpecificData = (attributes.queryParams.expandSpecificData default "false") == "true"
    var expandTextData = (attributes.queryParams.expandTextData default "false") == "true"
    var expandPartnerData = (attributes.queryParams.expandPartnerData default "false") == "true"
    ---
    {
        expandSpecificData: expandSpecificData,
        expandTextData: expandTextData,
        expandPartnerData: expandPartnerData
    }]]></ee:set-variable>
                    <ee:set-variable variableName="requestHeader" ><![CDATA[output application/java
    ---
    {
        x_conversation_id: attributes.headers.'X-Conversation-Id'
    }]]></ee:set-variable>
                </ee:variables>
            </ee:transform>
            <try doc:name="Try" doc:id="4d92f031-cc98-4a38-9349-4a3ae98372f7" >
                <http:request method="GET" doc:name="Request" doc:id="e0b3e101-97ae-45f9-980d-2bba12a19ef3" config-ref="HTTP_get_codex-closing-sys" path="${codex-closing-sys.path-serviceOrderId}" />
                <error-handler >
                    <on-error-continue enableNotifications="true" logException="true" doc:name="On Error Continue" doc:id="5718ba83-be9f-4f0c-9716-7dd552ca2ebd" >
                        <ee:transform doc:name="Transform Message" doc:id="a61dae32-5918-4efc-b175-0bc79def06a3" >
                            <ee:message >
                                <ee:set-payload ><![CDATA[%dw 2.0
    output application/java
    ---
    error
    //error.muleMessage.typedValue]]></ee:set-payload>
                            </ee:message>
                            <ee:variables >
                                <ee:set-variable variableName="operationStatus" ><![CDATA["error"]]></ee:set-variable>
                                <ee:set-variable variableName="httpStatus" ><![CDATA[404]]></ee:set-variable>
                                <ee:set-variable variableName="responseError" ><![CDATA[%dw 2.0
    output application/json
    ---
    {
        "type": "CLOSING-EXP:NOT_FOUND",
        "message": "The serviceOrder is not found"
    }]]></ee:set-variable>
                            </ee:variables>
                        </ee:transform>
                    </on-error-continue>
                </error-handler>
            </try>
            <choice doc:name="Choice" doc:id="0e92c648-0251-462e-9f4b-fc1a6ccf422d" >
                <when expression="#[!isEmpty(payload.data)]">
                    <ee:transform doc:name="responseCodex" doc:id="d2044aea-b1fd-4a75-874c-4ed8c925d3d1" >
                        <ee:message >
                            <ee:set-payload ><![CDATA[%dw 2.0
    output application/json
    ---
    if(!isEmpty(payload.data.serviceOrderHeader)) 
        (payload.data)
    else 
        ({})
    ]]></ee:set-payload>
                        </ee:message>
                    </ee:transform>
                    <ee:transform doc:name="init companyCode" doc:id="8399099b-c8fd-43b0-a96a-19636de7be74">
                    <ee:message>
                    </ee:message>
                <ee:variables>
                    <ee:set-variable variableName="companyCode"><![CDATA[%dw 2.0
    output application/java
    ---
    payload.data.serviceOrderHeader.companyCode]]></ee:set-variable>
                </ee:variables>
                </ee:transform>
                    <flow-ref doc:name="getAuthorization" doc:id="2fa53737-4811-4470-b30f-edf7f1e5df8e" name="getAuthorization"/>
                </when>
                <otherwise >
                    <ee:transform doc:name="noDataFound" doc:id="1904f051-8456-4756-a63e-4b0df1d6eae9" >
                        <ee:message />
                        <ee:variables >
                            <ee:set-variable variableName="noDataFound" ><![CDATA[%dw 2.0
    output application/java
    ---
    true]]></ee:set-variable>
                        </ee:variables>
                    </ee:transform>
                </otherwise>
            </choice>
            <ee:transform doc:name="responseData" doc:id="ec3eb206-0634-4951-b8bf-1d3f1672ab1c" >
                <ee:message />
                <ee:variables >
                    <ee:set-variable variableName="responseError" ><![CDATA[%dw 2.0
    output application/json
    ---
    if(vars.noDataFound)
    {
        "type": "ANALYTICS-EXP:NOT_FOUND",
        "message": "The service order you are looking for does not exist."
    }
    else if (!vars.isAuthorized)
    {
        "type": "ANALYTICS-EXP:NOT_AUTHORIZED",
        "message": "Unauthorized" 
    }
    else if(!isEmpty(payload.error))
     {
        "type": "ANALYTICS-EXP:BAD_REQUEST",
        "message":  if(typeOf(payload.error) ~='Object')   payload.error.message else  payload.error  
    }
    
    else 
    {}]]></ee:set-variable>
                    <ee:set-variable variableName="opretaionDetails" ><![CDATA[%dw 2.0
    output application/json
    ---
    if(!vars.noDataFound  and vars.isAuthorized )
      vars.operationDetails ++ { "httpStatus":200}
    else 
     vars.operationDetails ++ { "httpStatus":400}
     ]]></ee:set-variable>
                    <ee:set-variable variableName="operationStatus" ><![CDATA[%dw 2.0
    output application/json
    ---
    if(!vars.noDataFound and vars.isAuthorized )
       "success"
    else 
     "error"]]></ee:set-variable>
                    <ee:set-variable variableName="responseData" ><![CDATA[%dw 2.0
    output application/json
    ---
    if(!vars.noDataFound  and vars.isAuthorized )
       vars.responseCodex
    else 
    {}
    ]]></ee:set-variable>
                    <ee:set-variable variableName="httpStatus" ><![CDATA[%dw 2.0
    output application/java
    ---
    if(!vars.noDataFound  and vars.isAuthorized )
    200
    else if (vars.httpStatus == 404)
    404
    else 
    400]]></ee:set-variable>
                </ee:variables>
            </ee:transform>
            <error-handler />
        </flow>

调试提示与建议

  • 移除空的全局错误处理器:流程末尾的<error-handler />是空标签,Mule初始化空错误处理器时会触发NPE。直接删除该标签,或配置具体的错误处理逻辑(如on-error-continue、on-error-propagate)。
  • 补全变量初始化:responseData转换中使用了vars.operationDetails和vars.responseCodex,但流程未初始化这两个变量。建议在init vars转换中添加默认值初始化,避免启动或运行时异常。
  • 验证HTTP配置有效性:检查HTTP_get_codex-closing-sys配置是否存在,确认${codex-closing-sys.path-serviceOrderId}属性已在项目配置文件中定义。
  • 清理重建项目:在Anypoint Studio中执行Run As → Mule Application (clean)清理部署,再通过Maven → Clean → Package重建项目,重启IDE后重新部署。
  • 检查连接器兼容性:确认项目中所有连接器版本与Mule Runtime 4.6.7兼容,尤其是HTTP连接器,可通过Maven依赖列表核对版本匹配度。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 23:25:55