查询免费购买项目的运行时错误
Runtime error on query complimentary purchase items
我正在使用https://templates.prediction.io/PredictionIO/template-scala-parallel-complementarypurchase template of prediction.io
and inserted buy events using PHP-SDK
引擎部署成功但查询出错
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.construct(ConstructorConstructor.java:210)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:162)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.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.apply(CreateServer.scala:519)
at io.prediction.workflow.ServerActor$$anonfun.apply(CreateServer.scala:513)
at spray.routing.ApplyConverterInstances$$anon$$anonfun$apply.apply(ApplyConverterInstances.scala:25)
at spray.routing.ApplyConverterInstances$$anon$$anonfun$apply.apply(ApplyConverterInstances.scala:24)
at spray.routing.ConjunctionMagnet$$anon$$anon$$anonfun$happly$$anonfun$apply.apply(Directive.scala:38)
at spray.routing.ConjunctionMagnet$$anon$$anon$$anonfun$happly$$anonfun$apply.apply(Directive.scala:37)
at spray.routing.directives.BasicDirectives$$anon.happly(BasicDirectives.scala:26)
at spray.routing.ConjunctionMagnet$$anon$$anon$$anonfun$happly.apply(Directive.scala:37)
at spray.routing.ConjunctionMagnet$$anon$$anon$$anonfun$happly.apply(Directive.scala:36)
at spray.routing.directives.BasicDirectives$$anon.happly(BasicDirectives.scala:79)
at spray.routing.Directive$$anon$$anonfun$happly.apply(Directive.scala:86)
at spray.routing.Directive$$anon$$anonfun$happly.apply(Directive.scala:86)
at spray.routing.directives.BasicDirectives$$anon$$anonfun$happly.apply(BasicDirectives.scala:92)
at spray.routing.directives.BasicDirectives$$anon$$anonfun$happly.apply(BasicDirectives.scala:92)
at spray.routing.directives.ExecutionDirectives$$anonfun$detach$$anonfun$apply$$anonfun$apply.apply$mcV$sp(ExecutionDirectives.scala:89)
at spray.routing.directives.ExecutionDirectives$$anonfun$detach$$anonfun$apply$$anonfun$apply.apply(ExecutionDirectives.scala:89)
at spray.routing.directives.ExecutionDirectives$$anonfun$detach$$anonfun$apply$$anonfun$apply.apply(ExecutionDirectives.scala:89)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1(Future.scala:24)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
at scala.concurrent.impl.ExecutionContextImpl$$anon.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.newInstance(UnsafeAllocator.java:48)
at com.google.gson.internal.ConstructorConstructor.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"]
}
}
]
}
在您的 curl 请求中,num 字段不需要引号
curl -k -H "Content-Type: application/json" -d '{ "items": ["<item_id>"], "num": 3 }' https://localhost:8000/queries.json
我正在使用https://templates.prediction.io/PredictionIO/template-scala-parallel-complementarypurchase template of prediction.io
and inserted buy events using PHP-SDK
引擎部署成功但查询出错
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.construct(ConstructorConstructor.java:210)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:162)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.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.apply(CreateServer.scala:519)
at io.prediction.workflow.ServerActor$$anonfun.apply(CreateServer.scala:513)
at spray.routing.ApplyConverterInstances$$anon$$anonfun$apply.apply(ApplyConverterInstances.scala:25)
at spray.routing.ApplyConverterInstances$$anon$$anonfun$apply.apply(ApplyConverterInstances.scala:24)
at spray.routing.ConjunctionMagnet$$anon$$anon$$anonfun$happly$$anonfun$apply.apply(Directive.scala:38)
at spray.routing.ConjunctionMagnet$$anon$$anon$$anonfun$happly$$anonfun$apply.apply(Directive.scala:37)
at spray.routing.directives.BasicDirectives$$anon.happly(BasicDirectives.scala:26)
at spray.routing.ConjunctionMagnet$$anon$$anon$$anonfun$happly.apply(Directive.scala:37)
at spray.routing.ConjunctionMagnet$$anon$$anon$$anonfun$happly.apply(Directive.scala:36)
at spray.routing.directives.BasicDirectives$$anon.happly(BasicDirectives.scala:79)
at spray.routing.Directive$$anon$$anonfun$happly.apply(Directive.scala:86)
at spray.routing.Directive$$anon$$anonfun$happly.apply(Directive.scala:86)
at spray.routing.directives.BasicDirectives$$anon$$anonfun$happly.apply(BasicDirectives.scala:92)
at spray.routing.directives.BasicDirectives$$anon$$anonfun$happly.apply(BasicDirectives.scala:92)
at spray.routing.directives.ExecutionDirectives$$anonfun$detach$$anonfun$apply$$anonfun$apply.apply$mcV$sp(ExecutionDirectives.scala:89)
at spray.routing.directives.ExecutionDirectives$$anonfun$detach$$anonfun$apply$$anonfun$apply.apply(ExecutionDirectives.scala:89)
at spray.routing.directives.ExecutionDirectives$$anonfun$detach$$anonfun$apply$$anonfun$apply.apply(ExecutionDirectives.scala:89)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1(Future.scala:24)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
at scala.concurrent.impl.ExecutionContextImpl$$anon.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.newInstance(UnsafeAllocator.java:48)
at com.google.gson.internal.ConstructorConstructor.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"]
}
}
]
}
在您的 curl 请求中,num 字段不需要引号
curl -k -H "Content-Type: application/json" -d '{ "items": ["<item_id>"], "num": 3 }' https://localhost:8000/queries.json