如何在mule上获取twitter屏幕名称

时间:2015-03-31 16:10:17

标签: twitter mule

我想用mule发送一条推文,但我在#[payload.user.screenName]上得到一个NullPointerException,如何获取screenName ??并且所有其他方式都不起作用

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

<mule xmlns:twitter="http://www.mulesoft.org/schema/mule/twitter" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:http="http://www.mulesoft.org/schema/mule/http" 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.6.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="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/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/twitter http://www.mulesoft.org/schema/mule/twitter/current/mule-twitter.xsd">
    <http:request-config name="HTTP_Request_Configuration" host="api.openweathermap.org" port="80" basePath="data/2.5/weather?q=Cadiz,es&amp;APPID=mykey" doc:name="HTTP Request Configuration"/>
    <twitter:config name="Twitter" accessKey="${twitter.accessKey}" accessSecret="${twitter.accessSecret}" consumerKey="${twitter.consumerKey}" consumerSecret="${twitter.consumerSecret}" doc:name="Twitter"/>
    <flow name="pruebaFlow">
        <poll doc:name="Poll">
            <fixed-frequency-scheduler frequency="10000"/>
            <http:request config-ref="HTTP_Request_Configuration" path="/" method="GET" doc:name="HTTP"/>
        </poll>
        <byte-array-to-string-transformer doc:name="Byte Array to String"/>
        <echo-component doc:name="Echo"/>
        <twitter:show-user config-ref="Twitter" doc:name="Twitter"/>
        <twitter:send-direct-message-by-screen-name config-ref="Twitter" message="#[header.INBOUND:message]" screenName="#[payload.user.screenName]" doc:name="Twitter"/>
    </flow>
</mule>

这就是stracktrace

Exception stack is:
1. null (java.lang.NullPointerException)
  org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer:363 (null)
2. [Error: null pointer: payload.user.screenName]
[Near : {... payload.user.screenName ....}]
             ^
[Line: 1, Column: 1] (org.mule.mvel2.PropertyAccessException)
  org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer:434 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/mvel2/PropertyAccessException.html)
3. Execution of the expression "payload.user.screenName" failed. (org.mule.api.expression.ExpressionRuntimeException)
  org.mule.el.mvel.MVELExpressionLanguage:202 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/ExpressionRuntimeException.html)
4. Failed to invoke sendDirectMessageByScreenName. Message payload is of type: UserJSONImpl (org.mule.api.MessagingException)
  org.mule.devkit.processor.DevkitBasedMessageProcessor:128 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
    at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:363)
    at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:140)
    at org.mule.mvel2.ast.ASTNode.optimize(ASTNode.java:159)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)

现在我有一个新错误

RROR 2015-03-31 22:36:55,067 [[prueba].HTTP_Listener_Configuration.worker.01] org.mule.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: Work Descriptor. Root Exception was: 401 response received, but no WWW-Authenticate header was present. Type: class java.lang.IllegalStateException
ERROR 2015-03-31 22:36:55,075 [[prueba].HTTP_Listener_Configuration.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : Error sending HTTP request. Message payload is of type: MuleHttpClient$1
Code                  : MULE_ERROR-29999
--------------------------------------------------------------------------------
Exception stack is:
1. 401 response received, but no WWW-Authenticate header was present (java.lang.IllegalStateException)
  com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider$AsyncHttpClientEventFilter$AuthorizationHandler:1623 (null)
2. java.lang.IllegalStateException: 401 response received, but no WWW-Authenticate header was present (java.util.concurrent.ExecutionException)
  org.glassfish.grizzly.impl.SafeFutureImpl$Sync:363 (null)
3. java.util.concurrent.ExecutionException: java.lang.IllegalStateException: 401 response received, but no WWW-Authenticate header was present (java.io.IOException)
  org.mule.module.http.internal.request.grizzly.GrizzlyHttpClient:282 (null)
4. Error sending HTTP request. Message payload is of type: MuleHttpClient$1 (org.mule.api.MessagingException)
  org.mule.module.http.internal.request.DefaultHttpRequester:190 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.IllegalStateException: 401 response received, but no WWW-Authenticate header was present
    at com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider$AsyncHttpClientEventFilter$AuthorizationHandler.handleStatus(GrizzlyAsyncHttpProvider.java:1623)
    at com.ning.http.client.providers.grizzly.GrizzlyAsyncHttpProvider$AsyncHttpClientEventFilter.onHttpHeadersParsed(GrizzlyAsyncHttpProvider.java:1422)
    at org.glassfish.grizzly.http.HttpCodecFilter.decodeHttpPacketFromBytes(HttpCodecFilter.java:664)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

0 个答案:

没有答案
相关问题