Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Load custom function will result: Rserve error: Object reference not set to an instance of an object. #47

Open
sirpod opened this issue Oct 24, 2018 · 3 comments

Comments

@sirpod
Copy link

sirpod commented Oct 24, 2018

Hello,

when I trying to load/add a custom function in the plugin the plugin return on every call:
"WARN|SSEtoRserve.RServeEvaluator|Rserve error: Object reference not set to an instance of an object."

I setup function definition file
<setting name="functionDefinitionsFile" serializeAs="String"> <value>.\FuncDefs.json</value> <!-- Set to i.e. .\FuncDefs.json to add your own defined SSE functions. The file contains the description of the functions. --> </setting>

This works with default functions as well with new ones created by me in the JSON-file.

But I have a complex script what I do not want do define in a JSON-file.
Therefore I saved the script in a R-file and saved it to the machine.
When I now trying to load this on start up of the plugin:

<setting name="rserveInitScript" serializeAs="String"> <value>source("FUNCTION.R")</value> </setting>

Any request (R.ScriptAggrExStr | R.ConcatStringsTensor | or others) I send to the plugin returns the same error.

First I though I had an error in my function but even when I setup a simple function the same error occurs.
e.g.
myFunction <- function(inputData) { return('done') }

Operating system where the SSE plugin is deployed
[x] Windows
[ ] Linux
Qlik Sense
[ ] Desktop
[x] Server

Versions

  • sse-r-plugin: v1.2.1
  • Qlik Sense: QlikSense June 2018
  • Operating system: Windows Server 2012 R2

Thanks & regards
Tobias

@sirpod
Copy link
Author

sirpod commented Oct 30, 2018

I tested further and found out that in the JSON-file it works if you add semicolon after each command:
myFunction <- function(inputData) { return('done'); };

But in the "rserveInitScript" it dosen't work at all
Seams like a BUG to me.

Please confirm.

Thanks & regards

@tobiaslindulf
Copy link
Contributor

The rserveInitScript is a bit picky and it requires the last statement to actually return something. the function source() does not actually return something so that is the reason why it fails.
So try to add getwd(); after source, like: source("sum.R"); getwd();
or to be even more explicit also set the wd to something like: setwd('C:/Users/myUser/Documents/R/Myscripts'); source("sum.R"); getwd();

This should work for you.

@sirpod
Copy link
Author

sirpod commented Nov 2, 2018

Thanks for the help!
Now it works.

But I still have a problem with encoding.
The plugin interprets the UTF-8 characters as native.
The option
options(encoding = 'UTF-8');
returns an error in the plugin when executed on startup or gets ignored when setup in my function.

Any idea what this could be about?

Thanks & regards
Tobias

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants