You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I really don't have any idea why am I getting that issue at all. What could be the issue? I've created a schema validator for Android with this library but even everything seems fine, I still get that issue.
the exception was; javax.json.JsonException: JSON validation provider was not found. at com.kobil.ui.validator.spi.JsonValidationProvider.provider(JsonValidationProvider.java:51) at com.kobil.ui.validator.api.JsonValidationService$-CC.newInstance(JsonValidationService.java:84)
the class:
`
class JsonSchemaHelper {
private var context: Context
private var jsonString: String? = null
private var schemaString: String? = null
constructor(context: Context) {
this.context = context
}
constructor(context: Context, jsonString: String? = null) {
this.context = context
this.jsonString = jsonString
}
constructor(context: Context, jsonString: String? = null, schema: String? = null) {
this.context = context
this.jsonString = jsonString
this.schemaString = schema
}
fun isJsonValid(callback: ValidationListener? = null): Boolean {
var result = false
if (schemaString != null && schemaString!!.isNotEmpty()) {
result = validate(schemaString!!, callback)
} else {
context.resources.openRawResource(R.raw.service_provider_v1_combined)
.bufferedReader(Charsets.UTF_8).use {
result = validate(it.readText(), callback)
}
}
return result
}
fun isJsonValid(): Boolean {
return isJsonValid(null)
}
private fun validate(
schemaText: String? = null,
callback: ValidationListener? = null
): Boolean {
var result = true
val service: JsonValidationService = JsonValidationService.newInstance()
if (schemaText != null && schemaText.isNotEmpty()) {
val jsonSchema =
service.readSchema(ByteArrayInputStream(schemaText.toByteArray(Charsets.UTF_8)))
var jsonStringIs: InputStream? = null
if (jsonString != null) {
if (jsonString!!.isNotEmpty()) {
jsonStringIs =
ByteArrayInputStream(jsonString!!.toByteArray(Charsets.UTF_8))
} else {
callback?.onError("Json is null, did you forget to pass it?")
result = false
}
}
if (jsonSchema == null) {
callback?.onError("Json schema object is null")
result = false
}
if (jsonStringIs == null) {
callback?.onError("Json input source is null")
result = false
} else {
service.createParser(
jsonStringIs,
jsonSchema,
service.createProblemPrinter {
callback?.onError(it)
result = false
Log.e("handler", it)
println("handler $it")
System.out.println("handler $it")
}).use { parser ->
try {
while (parser.hasNext()) {
val event =
parser.next() // this part needed for catching issues too even that field is useless!
}
} else {
result = false
callback?.onError("Json schema text was null")
}
if (result) callback?.onSuccess()
return result
}
interface ValidationListener {
fun onError(errorDescription: String? = null)
fun onSuccess()
}
}
`
The text was updated successfully, but these errors were encountered:
Hello @Swisyn
Thank you for trying this library.
For achieving loose coupling between the API and the implementation, this library uses Java Service Provider Interface which looks up the proper implementation via META-INF/services/ or module-info.java. Judging from the exception log, the package of JsonValidationProvider seems to be renamed from my original. If my guess is correct, you must modify the configuration of the provider which resides where as described above.
I am facing same problem when running Spring boot application jar from command prompt. But It is working fine from eclipse and same application jar in other machine. I am using java11 and no module structure.
Hello,
I really don't have any idea why am I getting that issue at all. What could be the issue? I've created a schema validator for Android with this library but even everything seems fine, I still get that issue.
the exception was;
javax.json.JsonException: JSON validation provider was not found. at com.kobil.ui.validator.spi.JsonValidationProvider.provider(JsonValidationProvider.java:51) at com.kobil.ui.validator.api.JsonValidationService$-CC.newInstance(JsonValidationService.java:84)
the class:
`
class JsonSchemaHelper {
private var context: Context
private var jsonString: String? = null
private var schemaString: String? = null
// Log.e("event", event.name)
// println(event.toString())
// System.out.println(event.toString())
}
} catch (e: JsonParsingException) {
result = false
e.message?.let { callback?.onError(it) }
}
}
}
`
The text was updated successfully, but these errors were encountered: