Caused by: java.lang.IllegalArgumentException: Could not locate call adapter for rx.Observable錯誤
public class TRService { public static final String BASE_TRC_URL = "http://www.tuling123.com/openapi/"; private static Retrofit retrofit = new Retrofit.Builder() .baseUrl(BASE_TRC_URL) .addConverterFactory(GsonConverterFactory.create()) .build(); private TRService() { } public static TRApi createTRService() { return retrofit.create(TRApi.class); } }
public interface TRApi { /** * 可以看到這裡應該是post傳遞的引數。 * @param key * @param info * @param userid * @return */ @FormUrlEncoded @POST("api") Observable<TREntity> getTRResponse(@Field("key") String key, @Field("info") String info, @Field("userid") String userid); }
呼叫的地方:
private void gainChat(String str) { service.getTRResponse(Contant.TRC_KEY, str, Contant.TRC_USER_ID) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Action1<TREntity>() { @Override public void call(TREntity trEntity) { if (trEntity != null) { String str; if (trEntity.getCode() == 40004) { str = Contant.TRC_ROBOT_REST; } else { str = trEntity.getText(); } addData(new ChatBean(TRClientAdapter.TYPE_ROBOT, str)); } } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { addData(new ChatBean(TRClientAdapter.TYPE_ROBOT, Contant.TRC_ROBOT_FAILED)); } }); }
出現如下錯誤:
Caused by: java.lang.IllegalArgumentException: Could not locate call adapter for rx.Observable<>
要在構建Retrofit時指定介面卡模式為RxJavaCallAdapterFactory,修改如下:
public class TRService {
public static final String BASE_TRC_URL = "http://www.tuling123.com/openapi/";
private static Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_TRC_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build();
private TRService() {
}
public static TRApi createTRService() {
return retrofit.create(TRApi.class);
}
}
如果沒有使用RxJavaCallAdapterFractory,那麼使用Retrofit的回撥,如下:
public interface TRApi {
/**
* 可以看到這裡應該是post傳遞的引數。
* @param key
* @param info
* @param userid
* @return
*/
@FormUrlEncoded
@POST("api")
Call<TREntity> getTRResponse(@Field("key") String key, @Field("info") String info, @Field("userid") String userid);
}
相關推薦
Caused by: java.lang.IllegalArgumentException: Could not locate call adapter for rx.Observable錯誤
public class TRService { public static final String BASE_TRC_URL = "http://www.tuling123.com/openapi/"; private static Retrofit
Caused by: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
在驗證碼的顯示問題出現如下錯誤: Caused by: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment 修改
Caused by java lang ClassNotFoundException Could not load
1、錯誤描述WARN:2015-05-01 13:26:10[localhost-startStop-1] - HHH000402: Using Hibernate built-in connection pool (not for production use!)WARN:2
Caused by: java.lang.RuntimeException: Could not generate DH keypair異常處理
一、換新版本JDK7。 二、下載下面兩個jar,並放在你的jdk路徑ext下(我的是C:\Program Files\Java\jdk1.6.0_45\jre\lib\ext),並修改C:\Program Files\Java\jdk1.6.0_45\jre\lib\sec
Caused by: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value
整合spring+mybatis 報錯以下錯誤: 我完全是IDEA的問題!!!找了半天啊!!! org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.wechat.mo
spring aop定義增強時候報錯 Caused by: java.lang.IllegalArgumentException: Pointcut is not well-formed: expec
Caused by: java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting ')' at character position 11 Caused by: java.lang.IllegalArg
tomcat啟動報錯Caused by: java.lang.IllegalArgumentException: The main resource set specifiedis not valid
原因:筆者電腦中不存在“G:\Tomcatdata\data\sourcecode\chapter03\helloapp]”此路徑、檔案,所以刪除tomcat檔案目錄下的conf\server.xml檔案中的對應資訊(Context)後,tomcat能正常啟動。 錯誤資訊如下:
Caused by: java.lang.IllegalArgumentException: @EnableAsync annotation metadata was not injected
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.annotat
spring aop Caused by: java.lang.IllegalArgumentException: Pointcut is not well-formed: 報錯
最近這幾天在公司研究spring aop(面向切面程式設計),在使用spring 註解實現時,遇到了一個bug,由此記錄一下,方便日後讀閱;報錯如下圖所示: 由於是第一次接觸spring aop 當時就懵逼了,在網上搜索相關的錯誤,最後找到了自己的問題出
Caused by: java.lang.IllegalArgumentException: At least one JPA metamodel must be present!
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nes
springboot Caused by: java.lang.IllegalArgumentException: Property 'sessionFactory' is required
異常資訊:springboot Caused by: java.lang.IllegalArgumentException: Property 'sessionFactory' is required 一般出現該類問題就是配置的問題,無論是xml配置。還是springboot的yml配置。
Caused by: java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required
前言:最近在寫一個oa專案,用的是ssh框架,使用註解開發啟動tomcat的時候報了下面錯誤 問題: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'depa
Caused by: java.lang.IllegalArgumentException: argument type mismatch
essage Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.
[異常]Caused by: java.lang.IllegalArgumentException: Result Maps collection already contains value for
Caused by: java.lang.IllegalArgumentException: Result Maps collection already contains value for at org.apache.ibatis.session.Configuration$St
Caused by: java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
切入點引數定義錯誤 錯誤詳細資訊如下,紅色標註是錯誤的關鍵點 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'IStudentMgr'
Java異常 - java.lang.IllegalArgumentException: Could not resolve placeholder 'xxxx' in string value xx
異常描述 org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'xxx' defined in URL[file:/xxxx/xxx.xml
Spring整合mybatis:Caused by: java.lang.IllegalArgumentException錯誤
java.lang.IllegalArgumentException at org.springframework.asm.ClassReader.<init>(Unknown Source) at org.springframew
解決Caused by: java.lang.IllegalArgumentException: Property sqlSessionFactory or sqlSessionTemplate ar
啟動tomcat之後日誌裡面報:Caused by: java.lang.IllegalArgumentException: Property sqlSessionFactory or sqlSessionTemplate are required, 網上看了一些文章,基本上是少了:
java.lang.IllegalArgumentException: Could not get next sequenced ID for sequence name: Visitor解決方案
HTTP Status 500 - Could not get next sequenced ID for sequence name: Visitortype Exception reportmessage Could not get next sequenced ID f
Caused by: java.lang.IllegalArgumentException: argument type mismatch錯誤
2014-06-24 08:51:42,984 ERROR [main] (DefSchedulerEngine.java:157) - 排程引擎啟動異常 org.springframework.orm.hibernate3.HibernateSystemException