ClassCastException NativeRegExpExecResult cannot be cast to NativeArray

Stijn de Witt stijndewitt at hotmail.com
Tue Dec 15 15:53:37 UTC 2015


Dear fellow developers,
First of all thank you for your work on Nashorn. I am pretty excited at the possibilities of being able to integrate my two favorite languages, Java and Javascript.
I have two concrete questions and a problem (which caused the questions):
1. Can a Nashorn engine be used across threads (using ScriptContext or Bindings for isolation)?2. Is there a good example of using Nashorn from a Servlet Filter?
My problem:
I am struggling with server-side rendering of React components using Nashorn. I am deploying to OpenShift and whenever I try to make my app listen to the rout route, I run into a weird ClassCastException somewhere inside the Nashorn code. I now think this is due to a heartbeat request OpenShift's haproxy is doing on my app that is causing (relatively) high load and triggering a concurrency problem... This leads me to believe I am doing something wrong in the way I create the script engine and using script contexts in a ThreadLocal to isolate the different threads.
I have formulated my question, including logs and relevant code, on StackOverflow.com.http://stackoverflow.com/questions/34276136/classcastexception-nativeregexpexecresult-cannot-be-cast-to-nativearray
 
Could one of you maybe have a look at my situation, specifically my servlet filter code and tell me if I am doing it wrong and if so, what I should change?(I tried instantiating a different engine per thread and saving them in a ThreadLocal, but this leads to OutOfMemory errors quickly)
Thank you for any tips, pointers to docs etc that you could spare.
With kind regards,
-Stijn
Stijn de Witthttp://stijndewitt.wordpress.com

 		 	   		  


More information about the nashorn-dev mailing list