2016-06-07 134 views
0

我使用使用PHP-SDK运行时错误

引擎prediction.iohttps://templates.prediction.io/PredictionIO/template-scala-parallel-complementarypurchase模板和插入团购活动成功部署,但在查询给错误

curl -k -H "Content-Type: application/json" -d '{ "items": ["<item_id>"], "num": "3" }' https://localhost:8000/queries.json 

误差小于

Stack Trace: 
java.lang.RuntimeException: Unable to invoke no-args constructor for scala.collection.immutable.Set<java.lang.String>. Register an InstanceCreator with Gson for this type may fix this problem. 
    at com.google.gson.internal.ConstructorConstructor$12.construct(ConstructorConstructor.java:210) 
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:162) 
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93) 
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172) 
    at com.google.gson.Gson.fromJson(Gson.java:803) 
    at com.google.gson.Gson.fromJson(Gson.java:768) 
    at com.google.gson.Gson.fromJson(Gson.java:717) 
    at com.google.gson.Gson.fromJson(Gson.java:689) 
    at io.prediction.workflow.JsonExtractor$.extractWithGson(JsonExtractor.scala:152) 
    at io.prediction.workflow.JsonExtractor$.extract(JsonExtractor.scala:70) 
    at io.prediction.workflow.ServerActor$$anonfun$24.apply(CreateServer.scala:519) 
    at io.prediction.workflow.ServerActor$$anonfun$24.apply(CreateServer.scala:513) 
    at spray.routing.ApplyConverterInstances$$anon$22$$anonfun$apply$1.apply(ApplyConverterInstances.scala:25) 
    at spray.routing.ApplyConverterInstances$$anon$22$$anonfun$apply$1.apply(ApplyConverterInstances.scala:24) 
    at spray.routing.ConjunctionMagnet$$anon$1$$anon$2$$anonfun$happly$1$$anonfun$apply$1.apply(Directive.scala:38) 
    at spray.routing.ConjunctionMagnet$$anon$1$$anon$2$$anonfun$happly$1$$anonfun$apply$1.apply(Directive.scala:37) 
    at spray.routing.directives.BasicDirectives$$anon$1.happly(BasicDirectives.scala:26) 
    at spray.routing.ConjunctionMagnet$$anon$1$$anon$2$$anonfun$happly$1.apply(Directive.scala:37) 
    at spray.routing.ConjunctionMagnet$$anon$1$$anon$2$$anonfun$happly$1.apply(Directive.scala:36) 
    at spray.routing.directives.BasicDirectives$$anon$2.happly(BasicDirectives.scala:79) 
    at spray.routing.Directive$$anon$7$$anonfun$happly$4.apply(Directive.scala:86) 
    at spray.routing.Directive$$anon$7$$anonfun$happly$4.apply(Directive.scala:86) 
    at spray.routing.directives.BasicDirectives$$anon$3$$anonfun$happly$1.apply(BasicDirectives.scala:92) 
    at spray.routing.directives.BasicDirectives$$anon$3$$anonfun$happly$1.apply(BasicDirectives.scala:92) 
    at spray.routing.directives.ExecutionDirectives$$anonfun$detach$1$$anonfun$apply$7$$anonfun$apply$3.apply$mcV$sp(ExecutionDirectives.scala:89) 
    at spray.routing.directives.ExecutionDirectives$$anonfun$detach$1$$anonfun$apply$7$$anonfun$apply$3.apply(ExecutionDirectives.scala:89) 
    at spray.routing.directives.ExecutionDirectives$$anonfun$detach$1$$anonfun$apply$7$$anonfun$apply$3.apply(ExecutionDirectives.scala:89) 
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) 
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) 
    at scala.concurrent.impl.ExecutionContextImpl$$anon$3.exec(ExecutionContextImpl.scala:107) 
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) 
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) 
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) 
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) 
Caused by: java.lang.reflect.InvocationTargetException 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at com.google.gson.internal.UnsafeAllocator$1.newInstance(UnsafeAllocator.java:48) 
    at com.google.gson.internal.ConstructorConstructor$12.construct(ConstructorConstructor.java:207) 
    ... 33 more 
Caused by: java.lang.InstantiationException: scala.collection.immutable.Set 
    at sun.misc.Unsafe.allocateInstance(Native Method) 
    ... 39 more 

这是我的engine.json

{ 
    "id": "default", 
    "description": "Default settings", 
    "engineFactory": "com.my.ComplementaryPurchaseEngine", 
    "datasource": { 
    "params" : { 
     "appName": "store", 
     "eventNames": ["buy"] 
    } 
    }, 
    "algorithms": [ 
    { 
     "name": "algo", 
     "params": { 
     "basketWindow" : 120, 
     "maxRuleLength" : 2, 
     "minSupport": 0.001, 
     "minConfidence": 0.1, 
     "minLift" : 1.0, 
     "minBasketSize" : 2, 
     "maxNumRulesPerCond": 5, 
     "eventNames": ["buy"] 
     } 
    } 
    ] 
} 
+0

报价你尝试过没有你的curl命令的-k?或者在你的curl json中没有引用数字? curl -H“Content-Type:application/json”-d'{“items”:[“”],“num”:3}'https:// localhost:8000/queries.json – alex9311

+0

实际上有一些通过预测硬编码,即服务器始终以https运行,即使在本地主机上运行,​​因此-k用于绕过https(ssl)。我已经试过没有数字字段太 – Dau

+1

我不是说没有数字字段,但有“数字”:3而不是“数字”:“3” – alex9311

回答

1

在你卷曲的要求,NUM场并不需要围绕它

curl -k -H "Content-Type: application/json" -d '{ "items": ["<item_id>"], "num": 3 }' https://localhost:8000/queries.json