2014-02-06 36 views
0

我正在嘗試編寫使用Box連接器的Mule流。我可以去http://localhost:8081/auth併成功授權。但只要我在我的帳戶中創建一個文件,我就會得到「無法調用getEvents,消息有效負載的類型爲:String。」而在根異常跟蹤我得到: 「無效的密鑰類型」Mule Box連接器 - 無效的密鑰類型/消息有效負載是字符串類型

騾子流量(基於:https://github.com/mulesoft/box-connector/blob/master/demo/src/main/app/box-connector-demo.xml

<?xml version="1.0" encoding="UTF-8"?> 

    <mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" 
     xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:objectstore="http://www.mulesoft.org/schema/mule/objectstore" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:box="http://www.mulesoft.org/schema/mule/box" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/scripting   http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd 
    http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-current.xsd 
    http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
    http://www.mulesoft.org/schema/mule/objectstore http://www.mulesoft.org/schema/mule/objectstore/1.0/mule-objectstore.xsd 
    http://www.mulesoft.org/schema/mule/box http://www.mulesoft.org/schema/mule/box/2.0/mule-box.xsd 
    http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
    http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd"> 
     <box:config name="Box" clientId="removed" clientSecret="removed" doc:name="Box"> 
      <box:oauth-callback-config domain="localhost" localPort="8081" path="callback" remotePort="8081"/> 
     </box:config> 
<objectstore:config name="ObjectStore" objectStore-ref="_defaultInMemoryObjectStore" doc:name="ObjectStore"/> 
     <flow name="Authorize" doc:name="Authorize"> 
      <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" path="auth"/> 
      <box:authorize config-ref="Box" doc:name="Authorize" /> 

</flow> 
    <flow name="longPolling" doc:name="longPolling"> 
      <box:listen-events config-ref="Box" doc:name="Box (Streaming)"/> 
      <set-variable variableName="defaultValue" value="0" doc:name="Variable"/> 
      <objectstore:retrieve config-ref="ObjectStore" key="streamPosition" defaultValue-ref="#[flowVars['defaultValue']]" doc:name="ObjectStore"/> 
      <box:get-events config-ref="Box" streamPosition="#[payload]" accessTokenId="#[message.inboundProperties['boxAccessTokenId']]" doc:name="Box" /> 
      <objectstore:store config-ref="ObjectStore" key="streamPosition" value-ref="#[payload.nextStreamPosition]" overwrite="true" doc:name="ObjectStore"/> 
      <scripting:transformer doc:name="Groovy"> 
     <scripting:script engine="Groovy"><![CDATA[return payload.entries.findAll{it.eventType =='ITEM_DOWNLOAD' || it.eventType == 'ITEM_PREVIEW'} 
      ]]></scripting:script> 
      </scripting:transformer> 

    <scripting:transformer doc:name="Groovy"> 
       <scripting:script engine="Groovy"><![CDATA[return payload.findAll{it.source?.type == "file" && it.source?.parent.id == "0"} 
      ]]></scripting:script> 
      </scripting:transformer> 

    <foreach doc:name="Foreach"> 
       <logger message="Box user #[payload.createdBy.login] has seen the file #[payload.source.name]" level="ERROR" doc:name="Logger"/> 
      </foreach> 


    </flow> 
    </mule> 

以下是完整的錯誤:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
    + Started app 'boxtest'         + 
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
    WARN 2014-02-06 10:00:35,607 [Box Long Polling thread for endpont http://2.realtime.services.box.net/subscribe?channel=removed&stream_type=all] org.mule.DefaultMuleMessage: setProperty(key, value) called with null value; removing key: boxAccessTokenId; please report the following stack trace to [email protected] 
    java.lang.Throwable 
     at org.mule.DefaultMuleMessage.setProperty(DefaultMuleMessage.java:457) 
     at org.mule.DefaultMuleMessage.addProperties(DefaultMuleMessage.java:1249) 
     at org.mule.DefaultMuleMessage.<init>(DefaultMuleMessage.java:174) 
     at org.mule.modules.box.processors.AbstractListeningMessageProcessor.process(AbstractListeningMessageProcessor.java:76) 
     at org.mule.modules.box.lp.LongPollingClient$1.run(LongPollingClient.java:63) 
     at java.lang.Thread.run(Unknown Source) 
    ERROR 2014-02-06 10:00:35,823 [[boxtest].longPolling.stage1.02] org.mule.exception.DefaultMessagingExceptionStrategy: 
    ******************************************************************************** 
    Message    : Failed to invoke getEvents. Message payload is of type: String 
    Code     : MULE_ERROR--2 
    -------------------------------------------------------------------------------- 
    Exception stack is: 
    1. Invalid key type (java.lang.RuntimeException) 
     org.mule.modules.box.oauth.BoxConnectorOAuthClientFactory:28 (null) 
    2. Failed to invoke getEvents. Message payload is of type: String (org.mule.api.MessagingException) 
     org.mule.modules.box.processors.GetEventsMessageProcessor:155 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html) 
    -------------------------------------------------------------------------------- 
    Root Exception stack trace: 
    java.lang.RuntimeException: Invalid key type 
     at org.mule.modules.box.oauth.BoxConnectorOAuthClientFactory.makeObject(BoxConnectorOAuthClientFactory.java:28) 
     at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1179) 
     at org.mule.modules.box.oauth.BoxConnectorOAuthManager.acquireAccessToken(BoxConnectorOAuthManager.java:339) 
     + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything) 
    ******************************************************************************** 

回答

1

這看起來像一個bug對我來說:box:get-events應該使用屬性boxAccessTokenId作爲身份驗證令牌,並且由於空值而導致該屬性未設置,並且當我查看BoxConnector類的源代碼時來自,有一個私有變量a的引用ccessTokenIdentifier從未設置。我把這個報告給Mule dev的地址。

+0

謝謝,我以爲是我。 –

相關問題