scalaj-http で get リクエストを実行できません:
Http("https://someUrl.com")
.option(HttpOptions.connTimeout(6000))
.option(HttpOptions.readTimeout(15000))
.asString
Exception in thread "main" java.lang.NoSuchMethodError: scala.collection.mutable.StringBuilder.append([CII)Lscala/collection/mutable/StringBuilder;
at scalaj.http.Http$.readOnce$1(Http.scala:163)
at scalaj.http.Http$.readString(Http.scala:167)
at scalaj.http.Http$Request$$anonfun$asString$1.apply(Http.scala:128)
at scalaj.http.Http$Request$$anonfun$asString$1.apply(Http.scala:128)
at scalaj.http.Http$.tryParse(Http.scala:148)
at scalaj.http.Http$Request$$anonfun$apply$1.apply(Http.scala:85)
at scalaj.http.Http$Request$$anonfun$apply$1.apply(Http.scala:85)
at scalaj.http.Http$Request.process(Http.scala:99)
at scalaj.http.Http$Request.apply(Http.scala:85)
at scalaj.http.Http$Request.asString(Http.scala:128)
at com.me.method1(API.scala:21)
at com.me.Application$delayedInit$body.apply(Application.scala:5)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
at scala.App$class.main(App.scala:71)
at com.me.Application$.main(Application.scala:3)
at com.me.Application.main(Application.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
このオプションを追加すると
Http("https://someUrl.com")
.option(HttpOptions.connTimeout(6000))
.option(HttpOptions.readTimeout(15000))
.option(HttpOptions.allowUnsafeSSL)
.asString
エラーは次のようになります。
Exception in thread "main" java.lang.NoClassDefFoundError: scala/reflect/ClassManifest$
at scalaj.http.HttpOptions$$anonfun$allowUnsafeSSL$1.apply(Http.scala:30)
at scalaj.http.HttpOptions$$anonfun$allowUnsafeSSL$1.apply(Http.scala:23)
at scalaj.http.Http$Request$$anonfun$process$2.apply(Http.scala:95)
at scalaj.http.Http$Request$$anonfun$process$2.apply(Http.scala:95)
at scala.collection.immutable.List.foreach(List.scala:318)
at scalaj.http.Http$Request.process(Http.scala:95)
at scalaj.http.Http$Request.apply(Http.scala:85)
at scalaj.http.Http$Request.asString(Http.scala:128)
at com.me.API.getJsessionId(API.scala:21)
at com.me.Application$delayedInit$body.apply(Application.scala:5)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
at scala.App$class.main(App.scala:71)
at com.me.Application$.main(Application.scala:3)
at com.me.Application.main(Application.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.lang.ClassNotFoundException: scala.reflect.ClassManifest$
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 24 more
URLは確かに利用可能です。実際、どの URL を使用しても (https でなくても)、エラーが発生します。
Exception in thread "main" java.lang.NoSuchMethodError: scala.collection.mutable.StringBuilder.append([CII)Lscala/collection/mutable/StringBuilder;
at scalaj.http.Http$.readOnce$1(Http.scala:163)
at scalaj.http.Http$.readString(Http.scala:167)
at scalaj.http.Http$Request$$anonfun$asString$1.apply(Http.scala:128)
at scalaj.http.Http$Request$$anonfun$asString$1.apply(Http.scala:128)
at scalaj.http.Http$.tryParse(Http.scala:148)
at scalaj.http.Http$Request$$anonfun$apply$1.apply(Http.scala:85)
at scalaj.http.Http$Request$$anonfun$apply$1.apply(Http.scala:85)
at scalaj.http.Http$Request.process(Http.scala:99)
at scalaj.http.Http$Request.apply(Http.scala:85)
at scalaj.http.Http$Request.asString(Http.scala:128)
at com.me.method(API.scala:22)
at com.me.Application$delayedInit$body.apply(Application.scala:5)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
at scala.App$class.main(App.scala:71)
build.sbt
scalaVersion := "2.10.2"
libraryDependencies += "org.scalaj" % "scalaj-http_2.8.1" % "0.3.2"
PS Scala 用のより良い http ライブラリがある場合は、それを提案してください。