我正在尝试使用 Twilio Java API 拨打电话。下面是代码。
public static Result call() {
Logger.debug("calling the requested number");
Form<User> form = userForm.bindFromRequest();
User user = form.get();
Logger.debug("Information submitted " + user.toString());
/* Instantiate a new Twilio Rest Client */
TwilioRestClient client = new TwilioRestClient(ACCOUNTSID, AUTHTOKEN);
// Get the account and call factory class
Account acct = client.getAccount();
CallFactory callFactory = acct.getCallFactory();
//build map of post parameters
Map<String,String> params = new HashMap<String,String>();
url = url + user.getCalleeNumber();
Logger.debug("url is " + url);
params.put("From", "+18054094292");
params.put("To", user.getCallerNumber());
params.put("Url", url);
try {
// Make a phone call ( This makes a POST request to the Calls resource)
callFactory.create(params);
} catch (TwilioRestException e) {
e.printStackTrace();
}
return ok("");
}
因此,如果我使用 play "run 8081" 或 play "start 8081" 运行它的 dev 或 prod 模式,代码就可以工作。但是当我暂存应用程序并通过 nohup 运行它时,我收到以下错误。任何猜测为什么会发生这种情况。堆栈跟踪如下。
play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.NoSuchMethodError: org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager: method <init>()V not found]]
at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10.jar:2.1.0]
at play.api.DefaultApplication.handleError(Application.scala:383) [play_2.10.jar:2.1.0]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anon$2$$anonfun$handle$1.apply(PlayDefaultUpstreamHandler.scala:132) [play_2.10.jar:2.1.0]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anon$2$$anonfun$handle$1.apply(PlayDefaultUpstreamHandler.scala:128) [play_2.10.jar:2.1.0]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.0]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.0]
java.lang.RuntimeException: java.lang.NoSuchMethodError: org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager: method <init>()V not found
at play.libs.F$Promise$6.apply(F.java:401) ~[play_2.10.jar:2.1.0]
at scala.concurrent.Future$$anonfun$map$1.liftedTree2$1(Future.scala:253) ~[scala-library.jar:na]
at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:249) ~[scala-library.jar:na]
at scala.concurrent.Future$$anonfun$map$1.apply(Future.scala:249) ~[scala-library.jar:na]
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:29) ~[scala-library.jar:na]
at akka.dispatch.BatchingExecutor$Batch$$anonfun$run$1.liftedTree1$1(BatchingExecutor.scala:67) ~[akka-actor_2.10.jar:na]
Caused by: java.lang.NoSuchMethodError: org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager: method <init>()V not found
at com.twilio.sdk.TwilioRestClient.<init>(TwilioRestClient.java:139) ~[twilio-java-sdk-3.3.14-jar-with-dependencies.jar:na]
at com.twilio.sdk.TwilioRestClient.<init>(TwilioRestClient.java:110) ~[twilio-java-sdk-3.3.14-jar-with-dependencies.jar:na]
at controllers.Application.call(Application.java:42) ~[twilio-test-1_2.10-1.0-SNAPSHOT.jar:1.0-SNAPSHOT]
at Routes$$anonfun$routes$1$$anonfun$applyOrElse$2$$anonfun$apply$2.apply(routes_routing.scala:69) ~[twilio-test-1_2.10-1.0-SNAPSHOT.jar:na]
at Routes$$anonfun$routes$1$$anonfun$applyOrElse$2$$anonfun$apply$2.apply(routes_routing.scala:69) ~[twilio-test-1_2.10-1.0-SNAPSHOT.jar:na]
at play.core.Router$HandlerInvoker$$anon$6$$anon$2.invocation(Router.scala:141) ~[play_2.10.jar:2.1.0]