-
Notifications
You must be signed in to change notification settings - Fork 869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"No such function" error occurred while creating & executing Javascript Functions dynamically. #4785
Comments
@lvca , Can you please comment on this or delegate to someone? |
Ok, seems the function library caches it. |
By reading your log, the error is on "testFunction3" that doesn't exist in the database. In your description you speak about testFunction1 and testFunction2, but not testFunction3 that is the function not found. |
@lvca This is a valid issue and you might not followed the steps to reproduce the issue. Here is another code snippet to reproduce the same issue. Once you run the below code, it'll execute only first function, then it'll fail while executing the second function. public static void main(String[] args) {
ODatabaseDocumentTx db = new ODatabaseDocumentTx("remote:localhost/GratefulDeadConcerts");
db.open("admin", "admin");
int count = 1;
while (true) {
db.reload();
String name = "testFunction" + count;
OFunction sum = db.getMetadata().getFunctionLibrary().createFunction(name);
sum.setLanguage("javascript");
sum.setCode("return " + name + ";");
sum.save();
System.out.println(sum.getId());
Object obj = (Object) sum.execute();
System.out.println("Function: " + name + ", Result: " + obj.toString());
try {
Thread.currentThread().sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
count++;
}
} Therefore I can't create functions dynamically and execute those with this issue. |
@lvca I have observed the same. Here's our practical use case. We have a web application running on tomcat which uses orientdb java API. And using this API we are invoking some server functions (javascript). Now when we go to orientdb studio and update the function logic, the changes are not effective until I restart tomcat. However, this problem doesn't occur when we invoke it through your Rest API (not sure if that's the correct term) or from studio itself. So I assume this has something to do with the Java API where it might be caching these functions. Any solution? |
I have encountered with below error while creating Javascript functions and executing it from a web application. The newly created function is not getting executed and below error has been occurred.
This issue can recreate using below code snippet and using below mentioned steps. Here I used this code to simulate the function execution happen in my web application. Web application initialize the DB connection at startup.
testFunction1
and with a simplereturn "F1";
script & save.testFunction2
with the script ofreturn "F2";
The function
testFunction1
will execute but the second functiontestFunction2
will not execute and will throw the above error.The text was updated successfully, but these errors were encountered: