VS Code karate config js error while running scenario with java 1.8 and karate version 1.2.0.RC5 - visual-studio-code

I am getting following error while running a scenario file from VS Code with Java 1.8 and karate version 1.2.0.RC5:
ERROR com.intuit.karate - src/test/java/feature/FOC.feature:5
* url baseUrl
js failed:
01: baseUrl
org.graalvm.polyglot.PolyglotException: ReferenceError: "baseUrl" is not defined
- <js>.:program(Unnamed:1)
karate-config.js file:
function fn() {
var env = karate.env; // get system property 'karate.env'
karate.log('karate.env system property was:', env);
if (!env) {
env = 'qa';
}
var config = {
secretKey: 'ssshhhhhhhhhhh!!!!',
// myVarName: 'someValue'
}
if (env == 'dev') {
config.baseUrl = 'https://services-dev.com/'
} else if (env == 'qa') {
config.baseUrl = 'https://services-qa.com/'
}
var result = karate.callSingle('classpath:tlrservice/feature/tripIdGenaration.feature');
config.tripIdGenaration = result;
return config;
}
feature file:
Feature: Test
Background:
* url baseUrl

Related

How to configure the DAP debugger under neovim for typescript?

I'm trying to configure the DAP debugger in Neovim for a typescript application.
I added the DAP plugin:
use "mfussenegger/nvim-dap"
I also have a config.lua file containing the adapter and configuration:
local status_ok, dap = pcall(require, "dap")
if not status_ok then
return
end
dap.adapters.chrome = {
type = "executable",
command = "node",
args = {os.getenv("HOME") .. "/dev/dap-debugger/vscode-js-debug/out/src/debugServerMain.js", "45635"}
}
dap.configurations.typescript = {
{
type = "chrome",
request = "attach",
program = "${file}",
debugServer = 45635,
cwd = vim.fn.getcwd(),
sourceMaps = true,
protocol = "inspector",
port = 9222,
webRoot = "${workspaceFolder}"
}
}
When, under nvim in my typescript application project, I try to start the debugger with the :lua require'dap'.continue() command, I get the error:
Debug adapter didn't respond. Either the adapter is slow (then wait and ignore this) or there is a problem with your adapter or `chrome` configuration. Check
the logs for errors (:help dap.set_log_level)
But the ~/.cache/nvim/dap.log DAP log shows no error:
[ DEBUG ] 2022-04-12T08:49:37Z+0200 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:776 ] "Spawning debug adapter" {
args = { "/home/stephane/dev/dap-debugger/vscode-js-debug/out/src/debugServerMain.js", "45635" },
command = "node",
type = "executable"
}
[ DEBUG ] 2022-04-12T08:49:37Z+0200 ] ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:965 ] "request" {
arguments = {
adapterID = "nvim-dap",
clientId = "neovim",
clientname = "neovim",
columnsStartAt1 = true,
linesStartAt1 = true,
locale = "en_US.UTF-8",
pathFormat = "path",
supportsRunInTerminalRequest = true,
supportsVariableType = true
},
command = "initialize",
seq = 0,
type = "request"
}
I can set breakpoints with the command:
lua require'dap'.toggle_breakpoint()
I also installed the VSCode Js debugger with the following commands:
git clone https://github.com/microsoft/vscode-js-debug
cd vscode-js-debug/
npm i
gulp
I can see that my Chrome browser is listening on the 9222 port:
chrome 208069 stephane 118u IPv4 1193769 0t0 TCP 127.0.0.1:9222 (LISTEN)
If I run the debugger manually, I can see it starts on the given port number:
09:16 $ node ~/dev/dap-debugger/vscode-js-debug/out/src/debugServerMain.js 45635
Debug server listening at 45635
I'm on NVIM v0.7.0-dev
My Angular application is started and responds all right.
UPDATE: The debugger I was trying to use is not on DAP standard. I guess I need to find an alternative.
The VSCode Chrome debugger is deprecated and has been replaced by the VSCode JS debugger. The VSCode JS debugger is compatible with all browsers. But the VSCode JS debugger is not DAP compliant. So the VSCode Chrome debugger is still being used for now.
Installing the debugger:
git clone git#github.com:microsoft/vscode-chrome-debug.git
cd vscode-chrome-debug
npm install
npm run build
Configuring the debugger:
local function configureDebuggerAngular(dap)
dap.adapters.chrome = {
-- executable: launch the remote debug adapter - server: connect to an already running debug adapter
type = "executable",
-- command to launch the debug adapter - used only on executable type
command = "node",
args = { os.getenv("HOME") .. "/.local/share/nvim/lsp-debuggers/vscode-chrome-debug/out/src/chromeDebug.js" }
}
-- The configuration must be named: typescript
dap.configurations.typescript = {
{
name = "Debug (Attach) - Remote",
type = "chrome",
request = "attach",
-- program = "${file}",
-- cwd = vim.fn.getcwd(),
sourceMaps = true,
-- reAttach = true,
trace = true,
-- protocol = "inspector",
-- hostName = "127.0.0.1",
port = 9222,
webRoot = "${workspaceFolder}"
}
}
end
local function configureDap()
local status_ok, dap = pcall(require, "dap")
if not status_ok then
print("The dap extension could not be loaded")
return
end
dap.set_log_level("DEBUG")
vim.highlight.create('DapBreakpoint', { ctermbg = 0, guifg = '#993939', guibg = '#31353f' }, false)
vim.highlight.create('DapLogPoint', { ctermbg = 0, guifg = '#61afef', guibg = '#31353f' }, false)
vim.highlight.create('DapStopped', { ctermbg = 0, guifg = '#98c379', guibg = '#31353f' }, false)
vim.fn.sign_define('DapBreakpoint', { text = '', texthl = 'DapBreakpoint', linehl = 'DapBreakpoint',
numhl = 'DapBreakpoint' })
vim.fn.sign_define('DapBreakpointCondition',
{ text = 'ﳁ', texthl = 'DapBreakpoint', linehl = 'DapBreakpoint', numhl = 'DapBreakpoint' })
vim.fn.sign_define('DapBreakpointRejected',
{ text = '', texthl = 'DapBreakpoint', linehl = 'DapBreakpoint', numhl = 'DapBreakpoint' })
vim.fn.sign_define('DapLogPoint', { text = '', texthl = 'DapLogPoint', linehl = 'DapLogPoint', numhl = 'DapLogPoint' })
vim.fn.sign_define('DapStopped', { text = '', texthl = 'DapStopped', linehl = 'DapStopped', numhl = 'DapStopped' })
return dap
end
local function configure()
local dap = configureDap()
if nil == dap then
print("The DAP core debugger could not be set")
end
configureDebuggerAngular(dap)
end

Problems with database connection Ktor!!! I just don't understand why the ktor not to see the path of application.conf jbdc

I'm having a problem with my web project. It is my first time when i try connecting database. I want to connect database to see that working. I use Postgres and have set up a database. I want to connect by using the following code :
Data base settings
package com.testreftul
import com.testreftul.model.Orders
import com.testreftul.model.Products
import com.testreftul.model.User
import com.typesafe.config.ConfigFactory
import io.ktor.server.config.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.SchemaUtils
import org.jetbrains.exposed.sql.transactions.transaction
object DbSettings {
private val appConfig = HoconApplicationConfig(ConfigFactory.load())
private var dbUrl = appConfig.property("jbdc.url").getString()
private var dbUser = appConfig.property("jbdc.username").getString()
private var dbPassword = appConfig.property("jbdc.password").getString()
fun init(dbUrl: String, dbUser: String, dbPassword: String) {
this.dbUrl = dbUrl
this.dbUser = dbUser
this.dbPassword = dbPassword
pgConnection()
transaction {
SchemaUtils.create(User, Products, Orders)
}
}
private fun pgConnection() = Database.connect(
url = dbUrl,
driver = "org.postgresql.Driver",
user = dbUser,
password = dbPassword
)
suspend fun <T> dbQuery(block:()->T): T =
withContext(Dispatchers.IO){
transaction {
block()
}
}
}
Database plugin
package com.testreftul.plugins
import com.testreftul.DbSettings
import io.ktor.server.application.*
fun Application.connectDatabase(){
val url = environment.config.property("jdbc.url").getString()
val username = environment.config.property("jdbc.username").getString()
val password = environment.config.property("jdbc.password").getString()
DbSettings.init(url,username,password)
}
Application.conf
ktor {
deployment {
port = 8080
port = ${?PORT}
}
application {
modules = [ com.testreftul.ApplicationKt.module ]
}
}
jdbc{
url = "jdbc:postgresql://localhost:5432/restest"
username = "postgres"
password = "admin"
}
build.gradle.kts
val ktor_version: String by project
val kotlin_version: String by project
val logback_version: String by project
val exposed_version:String by project
val postgresql_jdbc:String by project
plugins {
application
kotlin("jvm") version "1.6.20"
id("org.jetbrains.kotlin.plugin.serialization") version "1.6.20"
}
group = "com.testreftul"
version = "0.0.1"
application {
mainClass.set("io.ktor.server.netty.EngineMain")
val isDevelopment: Boolean = project.ext.has("development")
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment")
}
repositories {
mavenCentral()
maven { url = uri("https://maven.pkg.jetbrains.space/public/p/ktor/eap") }
}
dependencies {
implementation("io.ktor:ktor-server-core-jvm:$ktor_version")
implementation("io.ktor:ktor-server-content-negotiation-jvm:$ktor_version")
implementation("io.ktor:ktor-serialization-kotlinx-json-jvm:$ktor_version")
implementation("io.ktor:ktor-server-netty-jvm:$ktor_version")
implementation("ch.qos.logback:logback-classic:$logback_version")
implementation ("org.jetbrains.exposed:exposed-core:$exposed_version")
implementation ("org.jetbrains.exposed:exposed-dao:$exposed_version")
implementation ("org.jetbrains.exposed:exposed-jdbc:$exposed_version")
implementation ("org.jetbrains.exposed:exposed-java-time:$exposed_version")
implementation ("org.postgresql:postgresql:$postgresql_jdbc")
testImplementation("io.ktor:ktor-server-tests-jvm:$ktor_version")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
}
gradle.properties
ktor_version=2.0.0-beta-1
kotlin_version=1.6.20
logback_version=1.2.3
kotlin.code.style=official
exposed_version=0.37.3
postgresql_jdbc=42.3.3
Application.kt
package com.testreftul
import io.ktor.server.application.*
import com.testreftul.plugins.*
fun main(args: Array<String>): Unit =
io.ktor.server.netty.EngineMain.main(args)
#Suppress("unused") // application.conf references the main function. This annotation prevents the IDE from marking it as unused.
fun Application.module() {
connectDatabase()
configureRouting()
configureSerialization()
}
I installed all the plugins that were needed and created a database,and also i configure my ide and connect to database with dialect postgres.When i run the console return Caused by: io.ktor.server.config.ApplicationConfigurationException: Property jbdc.url not found.
> Task :run FAILED
2022-04-06 01:55:22.805 [main] TRACE Application - {
# application.conf # file:/C:/Users/eljan/IdeaProjects/ktor-restful1/build/resources/main/application.conf: 6
"application" : {
# application.conf # file:/C:/Users/eljan/IdeaProjects/ktor-restful1/build/resources/main/application.conf: 7
"modules" : [
# application.conf # file:/C:/Users/eljan/IdeaProjects/ktor-restful1/build/resources/main/application.conf: 7
"com.testreftul.ApplicationKt.module"
]
},
# application.conf # file:/C:/Users/eljan/IdeaProjects/ktor-restful1/build/resources/main/application.conf: 2
"deployment" : {
# application.conf # file:/C:/Users/eljan/IdeaProjects/ktor-restful1/build/resources/main/application.conf: 3
"port" : 8080
},
# Content hidden
"security" : "***"
}
2022-04-06 01:55:22.976 [main] INFO Application - Autoreload is disabled because the development mode is off.
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.testreftul.plugins.DatabaseKt.connectDatabase(Database.kt:11)
at com.testreftul.ApplicationKt.module(Application.kt:11)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at kotlin.reflect.jvm.internal.calls.CallerImpl$Method.callMethod(CallerImpl.kt:97)
at kotlin.reflect.jvm.internal.calls.CallerImpl$Method$Static.call(CallerImpl.kt:106)
at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:108)
at kotlin.reflect.jvm.internal.KCallableImpl.callDefaultMethod$kotlin_reflection(KCallableImpl.kt:159)
at kotlin.reflect.jvm.internal.KCallableImpl.callBy(KCallableImpl.kt:112)
at io.ktor.server.engine.internal.CallableUtilsKt.callFunctionWithInjection(CallableUtils.kt:119)
at io.ktor.server.engine.internal.CallableUtilsKt.executeModuleFunction(CallableUtils.kt:36)
at io.ktor.server.engine.ApplicationEngineEnvironmentReloading$launchModuleByName$1.invoke(ApplicationEngineEnvironmentReloading.kt:333)
at io.ktor.server.engine.ApplicationEngineEnvironmentReloading$launchModuleByName$1.invoke(ApplicationEngineEnvironmentReloading.kt:332)
at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.avoidingDoubleStartupFor(ApplicationEngineEnvironmentReloading.kt:357)
at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.launchModuleByName(ApplicationEngineEnvironmentReloading.kt:332)
at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.access$launchModuleByName(ApplicationEngineEnvironmentReloading.kt:32)
at io.ktor.server.engine.ApplicationEngineEnvironmentReloading$instantiateAndConfigureApplication$1.invoke(ApplicationEngineEnvironmentReloading.kt:313)
at io.ktor.server.engine.ApplicationEngineEnvironmentReloading$instantiateAndConfigureApplication$1.invoke(ApplicationEngineEnvironmentReloading.kt:311)
at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.avoidingDoubleStartup(ApplicationEngineEnvironmentReloading.kt:339)
at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.instantiateAndConfigureApplication(ApplicationEngineEnvironmentReloading.kt:311)
at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.createApplication(ApplicationEngineEnvironmentReloading.kt:144)
at io.ktor.server.engine.ApplicationEngineEnvironmentReloading.start(ApplicationEngineEnvironmentReloading.kt:278)
at io.ktor.server.netty.NettyApplicationEngine.start(NettyApplicationEngine.kt:183)
at io.ktor.server.netty.EngineMain.main(EngineMain.kt:26)
Caused by: io.ktor.server.config.ApplicationConfigurationException: Property jbdc.url not found.
at io.ktor.server.config.HoconApplicationConfig.property(HoconApplicationConfig.kt:15)
at com.testreftul.DbSettings.<clinit>(DbSettings.kt:16)
... 26 more
Caused by: io.ktor.server.config.ApplicationConfigurationException: Property jbdc.url not found.
Execution failed for task ':run'.
> Process 'command 'C:\Users\eljan\.jdks\corretto-16.0.2\bin\java.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
You have a typo in config's property names in the definition of default values for private variables. It should be jdbc instead of jbdc:
private var dbUrl = appConfig.property("jbdc.url").getString()
private var dbUser = appConfig.property("jbdc.username").getString()
private var dbPassword = appConfig.property("jbdc.password").getString()

How to specify HTTP authentication (user, password) when using an URL for libvirt_volume.source

I am trying to Provision VMs with Terraform.
i give the source image for the vm
here:
source = "http://10.1.1.160/Builds/14.7.1.10_0.39637/output/KVM/14.7.1.10_0.39637-disk1.qcow2"
but this site require a user name and a password.
where and how can i specify the credentials of this site in my tf file?
this is my main.tf file:
terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
}
}
}
provider "libvirt" {
uri = "qemu:///system"
}
resource "libvirt_volume" "centos7-qcow2" {
name = "centos7.qcow2"
pool = "default"
source = "http://10.1.1.160/Builds/14.7.1.10_0.39637/output/KVM/14.7.1.10_0.39637-disk1.qcow2"
format = "qcow2"
}
# Define KVM domain to create
resource "libvirt_domain" "gw" {
name = "gw"
memory = "8192"
vcpu = 4
network_interface {
network_name = "default"
}
disk {
volume_id = "${libvirt_volume.centos7-qcow2.id}"
}
console {
type = "pty"
target_type = "serial"
target_port = "0"
}
graphics {
type = "spice"
listen_type = "address"
autoport = true
}
}
when i run terraform apply i got this error:
*Error while determining image type for http://10.1.1.160/Builds/14.7.1.10_0.39637/output/KVM/14.7.1.10_0.39637-disk1.qcow2: Can't retrieve partial header of resource to determine file type: http://10.1.1.160/Builds/14.7.1.10_0.39637/output/KVM/14.7.1.10_0.39637-disk1.qcow2 - 401 Authorization Required
with libvirt_volume.centos7-qcow2,
on main.tf line 13, in resource "libvirt_volume" "centos7-qcow2":
13: resource "libvirt_volume" "centos7-qcow2" {*
thanks for helping!
I just added the password and the user to the URL, like this:
http://user:password#host/path
:)

Ionic runtime error cannot read property "toLowerCase" of null

I am trying to view an app via "ionic serve" but I get this error. I have looked at other subjects but have never seen a runtime error. I tried all of their solutions but I would still have the same error page. Here is what I see:
And to be honest, I am not the coder of this app, but I have bought it from a store. But, I know some here and there. If there is a simple solution to fix this, that would be amazing!
The first error link is pointing to here:
_this.initialData();
var operating_system = '';
var admob = {};
if (_this.device.platform.toLowerCase() == 'android') {
operating_system = 'android';
admob = {
banner: settings['admob_android_banner'],
interstitial: settings['admob_android_interstitial']
};
}
The second error link is pointing me to here:
SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
try {
fn.call(this._context, value);
}
catch (err) {
this.unsubscribe();
throw err;
}
};
The third error is pointing to here:
SafeSubscriber.prototype.next = function (value) {
if (!this.isStopped && this._next) {
var _parentSubscriber = this._parentSubscriber;
if (!_parentSubscriber.syncErrorThrowable) {
this.__tryOrUnsub(this._next, value);
}
else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
this.unsubscribe();
}
}
The fourth error is pointing to here:
Subscriber.prototype._next = function (value) {
this.destination.next(value);
};
The fifth error is pointing to here:
var /** #type {?} */ response = new Response(responseOptions);
response.ok = isSuccess(status);
if (response.ok) {
responseObserver.next(response);
// TODO(gdi2290): defer complete if array buffer until done
responseObserver.complete();
return;
}
Here is the code I get in cmd:
C:\Users\xx-nj\Desktop\DukhanApp\DukhanColor>ionic serve
Starting app-scripts server: --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703 --nobrowser -
Ctrl+C to cancel
[20:02:52] watch started ...
[20:02:52] build dev started ...
[20:02:53] clean started ...
[20:02:53] clean finished in 3 ms
[20:02:53] copy started ...
[20:02:53] deeplinks started ...
[20:02:53] deeplinks finished in 573 ms
[20:02:53] transpile started ...
[20:03:01] transpile finished in 7.70 s
[20:03:01] preprocess started ...
[20:03:01] preprocess finished in 1 ms
[20:03:01] webpack started ...
[20:03:01] copy finished in 8.80 s
[20:03:09] webpack finished in 8.01 s
[20:03:09] sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[20:03:13] sass finished in 3.39 s
[20:03:13] postprocess started ...
[20:03:13] postprocess finished in 14 ms
[20:03:13] lint started ...
[20:03:13] build dev finished in 20.14 s
[20:03:13] watch ready in 20.44 s
[20:03:13] dev server running: http://localhost:8100/
[OK] Development server running!
Local: http://localhost:8100
External: http://192.168.8.111:8100
DevApp: celltore_ionic3#8100 on NajmLaptop
[20:03:23] tslint: C:/Users/xx-nj/Desktop/DukhanApp/DukhanColor/src/pages/contactus/contactus.ts, line: 124
'marker' is declared but never used.
L123: let map = new google.maps.Map(element, mapOptions);
L124: let marker = new google.maps.Marker({
L125: title: this.textStatic['cellstore_contact_us_title'],
[20:03:23] tslint: ...s/xx-nj/Desktop/DukhanApp/DukhanColor/src/pages/detailcategory/detailcategory.ts, line: 138
Duplicate variable: 'filter'
L138: for (var filter in this.filter['valueCustom']) {
L139: let attr = this.filter['value'][filter];
[20:03:23] tslint: ...s/xx-nj/Desktop/DukhanApp/DukhanColor/src/pages/detailcategory/detailcategory.ts, line: 140
Duplicate variable: 'option'
L139: let attr = this.filter['value'][filter];
L140: if (attr && Object.keys(attr).length > 0) for (var option in attr) {
L141: if(option != 'select' && attr[option]) {
[20:03:23] tslint: C:/Users/xx-nj/Desktop/DukhanApp/DukhanColor/src/pages/brand/brand.ts, line: 121
Duplicate variable: 'filter'
L121: for (var filter in this.filter['valueCustom']) {
L122: let attr = this.filter['value'][filter];
[20:03:23] tslint: C:/Users/xx-nj/Desktop/DukhanApp/DukhanColor/src/pages/brand/brand.ts, line: 123
Duplicate variable: 'option'
L122: let attr = this.filter['value'][filter];
L123: if (attr && Object.keys(attr).length > 0) for (var option in attr) {
L124: if(option != 'select' && attr[option]) {
[20:03:23] tslint: C:/Users/xx-nj/Desktop/DukhanApp/DukhanColor/src/pages/home/home.ts, line: 300
Duplicate variable: 'diff'
L299: element[i]["due_date"] = false;
L300: var diff = (start.getTime() - today.getTime()) / 1000;
L301: element[i]['time_diff'] = Math.floor(diff);
[20:03:23] tslint: C:/Users/xx-nj/Desktop/DukhanApp/DukhanColor/src/pages/home/home.ts, line: 165
'remaining_time' is declared but never used.
L164: ngOnInit() {
L165: var remaining_time = setInterval(() => {
L166: if (this.navCtrl.getActive().component.name == "HomePage") {
[20:03:23] tslint: C:/Users/xx-nj/Desktop/DukhanApp/DukhanColor/src/pages/search/search.ts, line: 213
Duplicate variable: 'filter'
L213: for (var filter in this.filter['valueCustom']) {
L214: let attr = this.filter['value'][filter];
[20:03:23] tslint: C:/Users/xx-nj/Desktop/DukhanApp/DukhanColor/src/pages/search/search.ts, line: 215
Duplicate variable: 'option'
L214: let attr = this.filter['value'][filter];
L215: if (attr && Object.keys(attr).length > 0) for (var option in attr) {
L216: if(option != 'select' && attr[option]) {
[20:03:23] lint finished in 10.05 s
It seems that platform is not returned properly and that's why it's null.
You didn't include your constructor so i have no idea how your constructor looks like, but the following code snippet is returning platform name properly using the Device plugin you're using in your code.
import { Device } from '#ionic-native/device';
constructor(private device: Device) {}
......
if(this.device.platform.toLowerCase()=='android'){
// Your logic here
}
This happens because you're running ionic serve on web and the cordova platform isn't available there. Ionic Native returns {} when a property doesn't exist (when cordova isn't available), and it throws a console warning for developer assistance.
When one try to retrieve data from {} object then it will return null.
Please try adding below code:
import { Platform } from 'ionic-angular';
//add it in constructor as follows:
constructor( public platform: Platform){
}
//add platform check
if (this.platform.is('cordova')) {
//add your code here
}else{
console.log("Plugin not supported on web");
}

Guvnor execution server getting 401 when using AD-configured Guvnor as endpoint

We are using:
• Drools Execution Server that came with Drools 5.0.x
• Drools Guvnor 5.2 configured with active directory
The execution server and guvnor run on the same Tomcat and use the same port.
With the execution server you can have a listener for each package within the configuration file. I have two such files, from-file-system.properties that points to a local directory where a drools binary package is manually deployed. This works fine.
But I try to use with-guvnor.properties which points to a package binary on 5.3 Guvnor. Here is the file:
name=ndipiazza
newInstance=true
# Absolute path of the directory containing pc.drl: placeholder replaced by Ant.
url=http://localhost:9109/drools-guvnor/rest/packages/NDD_Test/binary
poll=10
I get the following error:
RuleAgent(ndipiazza) INFO (Mon Jun 18 18:11:32 EDT 2012): Configuring package provider : URLScanner monitoring URLs: http://localhost:9109/drools-guvnor/rest/packages/NDD_Test/binary
RuleAgent(ndipiazza) WARNING (Mon Jun 18 18:11:34 EDT 2012): Was an error contacting http://localhost:9109/drools-guvnor/rest/packages/NDD_Test/binary. Reponse header: {null=[HTTP/1.1 401 Unauthorized]
Some sort of authorization error very likely related to the active directory configuration within Guvnor 5.2.
This used to work for us just fine with an earlier version of Guvnor.
How can I fix this issue?
So we isolated the problem today. Drools Server 5.0.x cannot support a URL endpoint when it has authentication of any sort.
I reported a bug: https://issues.jboss.org/browse/JBRULES-3554
Without these changes, this will not work.
drools-core's org/drools/agent/HttpClientImpl.java
These two methods need to have authentication added in (marked by START and END NDD), and obviously switched with your username/password.
public LastUpdatedPing checkLastUpdated(URL url) throws IOException {
URLConnection con = url.openConnection();
HttpURLConnection httpCon = (HttpURLConnection) con;
try {
// **** START NDD *****
BASE64Encoder enc = new sun.misc.BASE64Encoder();
String userpassword = "ad-user" + ":" + "ad-password";
String encodedAuthorization = enc.encode( userpassword.getBytes() );
httpCon.setRequestProperty("Authorization", "Basic "+
encodedAuthorization);
// **** END NDD *****
httpCon.setRequestMethod( "HEAD" );
String lm = httpCon.getHeaderField( "lastModified" );
LastUpdatedPing ping = new LastUpdatedPing();
ping.responseMessage = httpCon.getHeaderFields().toString();
if ( lm != null ) {
ping.lastUpdated = Long.parseLong( lm );
} else {
long httpLM = httpCon.getLastModified();
if ( httpLM > 0 ) {
ping.lastUpdated = httpLM;
}
}
return ping;
} finally {
httpCon.disconnect();
}
}
public Package fetchPackage(URL url) throws IOException,
ClassNotFoundException {
URLConnection con = url.openConnection();
HttpURLConnection httpCon = (HttpURLConnection) con;
try {
// **** START NDD *****
BASE64Encoder enc = new sun.misc.BASE64Encoder();
String userpassword = "ad-user" + ":" + "ad-password";
String encodedAuthorization = enc.encode( userpassword.getBytes() );
httpCon.setRequestProperty("Authorization", "Basic "+
encodedAuthorization);
// **** END NDD *****
httpCon.setRequestMethod( "GET" );
Object o = DroolsStreamUtils.streamIn( httpCon.getInputStream() );
if ( o instanceof KnowledgePackageImp ) {
return ((KnowledgePackageImp) o).pkg;
} else {
return (Package) o;
}
} finally {
httpCon.disconnect();
}
}
Mystery solved.