Google日历mule连接器无法正常工作

时间:2015-07-23 18:50:11

标签: mule google-calendar-api

我正在使用Mule和Google Connectors。 我尝试过以下代码:

<mule xmlns:objectstore="http://www.mulesoft.org/schema/mule/objectstore" xmlns:json="http://www.mulesoft.org/schema/mule/json"
        xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:google-calendars="http://www.mulesoft.org/schema/mule/google-calendars" 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="EE-3.5.2"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="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/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
    http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.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/google-calendars http://www.mulesoft.org/schema/mule/google-calendars/current/mule-google-calendars.xsd">

        <google-calendars:config-with-oauth name="Google_Calendars"
            consumerKey="CUNSUMER_KEY" consumerSecret="CONSUMER_SECRET" doc:name="Google Calendars"
            applicationName="My Project">
            <google-calendars:oauth-callback-config domain="localhost" localPort="8082" path="oauth2callback"
                remotePort="8082" />
            <google-calendars:oauth-store-config objectStore-ref="ObjectStoreBean" />

        </google-calendars:config-with-oauth>

        <spring:beans>
            <spring:bean id="ObjectStoreBean" name="ObjectStoreBean" class="org.mule.util.store.SimpleMemoryObjectStore" />
        </spring:beans>
        <objectstore:config name="ObjectStore" doc:name="ObjectStore" objectStore-ref="ObjectStoreBean" />

        <flow name="authorizationAndAuthenticationFlow">
            <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="oauth-authorize"
                doc:name="HTTP" />
            <google-calendars:authorize config-ref="Google_Calendars" doc:name="Google Calendars" />
            <objectstore:store config-ref="ObjectStore" doc:name="ObjectStore" key="accessTokenId" overwrite="true"
                value-ref="#[flowVars['OAuthAccessTokenId']]" />
            <set-payload value="You have successfully authorized the connector" doc:name="Set Payload" />
            <catch-exception-strategy doc:name="Catch Exception Strategy">
                <set-payload value="An error has occurred authorizing the connector" doc:name="Set Payload" />
            </catch-exception-strategy>
        </flow>
        <flow name="getAcl">
            <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="get" doc:name="HTTP" />
            <logger level="INFO" doc:name="Logger" />
            <enricher target="#[flowVars['accessTokenId']]" doc:name="Message Enricher">
                <objectstore:retrieve config-ref="ObjectStore" key="accessTokenId" defaultValue-ref="#['']" doc:name="Get AccessToken" />
            </enricher>
            <expression-filter expression="#[flowVars['accessTokenId'] != '']" doc:name="Is Access Token Set" />
            <google-calendars:get-calendar-by-id id="CALENDAR_ID" config-ref="Google_Calendars" doc:name="Google Calendars" accessTokenId="#[flowVars['accessTokenId']]" />
            <json:object-to-json-transformer doc:name="Object to JSON" />
        </flow>

    </mule>

我可以很好地获得OAuth2授权,但是当我尝试获取日历时,我得到了:

Exception stack is:
1. com.google.common.primitives.UnsignedInteger.asUnsigned(I)Lcom/google/common/primitives/UnsignedInteger; (java.lang.NoSuchMethodError)
  com.google.api.client.util.Data:81 (null)
2. com.google.common.primitives.UnsignedInteger.asUnsigned(I)Lcom/google/common/primitives/UnsignedInteger; (java.lang.NoSuchMethodError). Message payload is of type: NullPayload (org.mule.api.MessagingException)
  org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
********************************************************************************
Root Exception stack trace:
java.lang.NoSuchMethodError: com.google.common.primitives.UnsignedInteger.asUnsigned(I)Lcom/google/common/primitives/UnsignedInteger;
    at com.google.api.client.util.Data.<clinit>(Data.java:81)
    at com.google.api.client.util.FieldInfo.<init>(FieldInfo.java:131)
    at com.google.api.client.util.FieldInfo.of(FieldInfo.java:104)
    at com.google.api.client.util.ClassInfo.<init>(ClassInfo.java:181)
    at com.google.api.client.util.ClassInfo.of(ClassInfo.java:92)
    at com.google.api.client.util.ClassInfo.<init>(ClassInfo.java:175)
    at com.google.api.client.util.ClassInfo.of(ClassInfo.java:92)
    at com.google.api.client.util.GenericData.<init>(GenericData.java:79)
    at com.google.api.client.util.GenericData.<init>(GenericData.java:61)
    at com.google.api.client.http.json.JsonHttpRequest.<init>(JsonHttpRequest.java:69)
    at com.google.api.services.calendar.CalendarRequest.<init>(CalendarRequest.java:44)
    at com.google.api.services.calendar.Calendar$Calendars$Get.<init>(Calendar.java:1372)
    at com.google.api.services.calendar.Calendar$Calendars.get(Calendar.java:1358)
    at org.mule.module.google.calendar.GoogleCalendarConnector.getCalendarById(GoogleCalendarConnector.java:273)
    at org.mule.module.google.calendar.processors.GetCalendarByIdMessageProcessor$1.process(GetCalendarByIdMessageProcessor.java:119)
    at org.mule.security.oauth.process.ProcessCallbackProcessInterceptor.execute(ProcessCallbackProcessInterceptor.java:24)
    at org.mule.security.oauth.process.RefreshTokenProcessInterceptor.execute(RefreshTokenProcessInterceptor.java:55)
    at org.mule.security.oauth.process.RefreshTokenProcessInterceptor.execute(RefreshTokenProcessInterceptor.java:24)
    at org.mule.security.oauth.process.ManagedAccessTokenProcessInterceptor.execute(ManagedAccessTokenProcessInterceptor.java:75)
    at org.mule.security.oauth.process.ManagedAccessTokenProcessInterceptor.execute(ManagedAccessTokenProcessInterceptor.java:24)
    at org.mule.security.oauth.process.ManagedAccessTokenProcessTemplate.execute(ManagedAccessTokenProcessTemplate.java:42)
    at org.mule.module.google.calendar.processors.GetCalendarByIdMessageProcessor.doProcess(GetCalendarByIdMessageProcessor.java:105)
    at org.mule.devkit.processor.DevkitBasedMessageProcessor.process(DevkitBasedMessageProcessor.java:88)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:40)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.processor.AsyncInterceptingMessageProcessor.process(AsyncInterceptingMessageProcessor.java:102)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.construct.DynamicPipelineMessageProcessor.process(DynamicPipelineMessageProcessor.java:54)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelope...
*******************************************************************************`

我尝试使用Mule 3.5.2和Google Calendar Connector v.1.1.1以及v.1.2.4,但仍无法正常工作

修改

实际上我发现Google Connectors指的是guava-12.0.jar,但是Mule Server Library是指guava-16.0.1.jar,所以我想当我在运行应用程序时,实际使用的是jar是guava-16.0.1.jar,该方法不再存在。

1 个答案:

答案 0 :(得分:1)

某处的某些代码(请参阅我的问题下方的评论)取决于15.0之前的Guava,其中已弃用的asUnsigned已从UnsignedInteger中移除。

您可以尝试将番石榴强加到14.0.1,方法是将其添加到您的项目中pom.xml

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>14.0.1</version>
</dependency>

这种降级当然可能会破坏其他地方的其他东西,但它值得一试(直到我们弄清楚需要这种删除方法的代码在哪里并提出相关项目的问题)。

编辑:事实证明,Mule将更新版本的Guava带到了类路径中。因此,您需要配置应用程序类加载器以使用嵌入在app zip中的Guava版本。在mule-deploy.properties中添加以下内容:

loader.override=-com.google.common.primitives.UnsignedInteger

参考:https://developer.mulesoft.com/docs/display/35X/Classloader+Control+in+Mule