Twitter + Scribe +无法从null对象获取String

时间:2014-02-03 14:15:26

标签: java twitter scribe

我正在尝试使用scribe授权twitter。当我尝试

requestToken = service.getRequestToken()

我收到以下错误

14:10:11,305 ERROR [ajp-bio-8009-exec-4][IncludeTag:154]   java.lang.IllegalArgumentException: Cannot get String from a null object
    at org.scribe.utils.Preconditions.check(Preconditions.java:80)
    at org.scribe.utils.Preconditions.checkNotNull(Preconditions.java:27)
    at org.scribe.utils.StreamUtils.getStreamContents(StreamUtils.java:20)
    at org.scribe.model.Response.parseBodyContents(Response.java:40)
    at org.scribe.model.Response.getBody(Response.java:66)
    at org.scribe.oauth.OAuth10aServiceImpl.getRequestToken(OAuth10aServiceImpl.java:59)
    at org.apache.jsp.html.portlet.login.login_jsp._jspService(login_jsp.java:2432)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

我尝试了以下帖子中提到的答案,但没有任何效果

scribe + twitter > Cannot get String from a null object

每当我尝试包含TwitterApi.SSL.class或TwitterApi.Authenticate.class时,它都会给我“无法解析为类型”错误。

有没有人遇到过这个问题?

2 个答案:

答案 0 :(得分:1)

使用.provider(TwitterApi.SSL.class)代替.provider(TwitterApi.class)。 它应该工作。

答案 1 :(得分:1)

请检查您使用的Scribe版本。根据他们的ChangeLog页面,SSL支持仅在版本1.2期间添加,因此如果它来自旧版本,您的jar将不包含SSL类。 https://github.com/fernandezpablo85/scribe-java/blob/master/changelog.txt

下载最新的jar将解决您的问题:)