{"id":2061,"date":"2015-04-10T17:51:05","date_gmt":"2015-04-10T15:51:05","guid":{"rendered":"http:\/\/hasselba.ch\/blog\/?p=2061"},"modified":"2015-04-10T17:51:05","modified_gmt":"2015-04-10T15:51:05","slug":"xpages-running-googles-chrome-v8-javascript-engine-2","status":"publish","type":"post","link":"https:\/\/hasselba.ch\/blog\/?p=2061","title":{"rendered":"XPages: Running Google\u2019s Chrome V8 Javascript Engine (2)"},"content":{"rendered":"<p>A while ago <a title=\"XPages: Running Google\u2019s Chrome V8 Javascript Engine\" href=\"https:\/\/hasselba.ch\/blog\/?p=1746\">I tried to run Google&#8217;s V8 Javascript engine<\/a> on top of XPages, and today I found the reason why my server crashed after the first click: I have tried to load the engine only once (statically), and that killed Domino completly.<\/p>\n<p>Today I moved the code back into the <em>processAction<\/em> method, and now it works without problems.<\/p>\n<pre><code>package ch.hasselba.xpages.jav8;\r\n\r\nimport javax.faces.event.AbortProcessingException;\r\nimport javax.faces.event.ActionEvent;\r\nimport javax.script.ScriptEngine;\r\nimport javax.script.ScriptEngineManager;\r\nimport javax.script.ScriptException;\r\n\r\npublic class JAV8Test implements javax.faces.event.ActionListener {\r\n\r\n\u00a0\u00a0 \u00a0public void processAction(ActionEvent actionEvent)\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0throws AbortProcessingException {\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0ScriptEngineManager factory = new ScriptEngineManager();\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0ScriptEngine engine = factory.getEngineByName(\"jav8\");\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0try {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0System.out.println(engine.getClass().getCanonicalName());\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0engine.eval(\"var i=1+1;\");\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0System.out.println(\"i = \" + engine.get(\"i\"));\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0} catch (ScriptException ex) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0ex.printStackTrace();\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0}\r\n\u00a0\u00a0 \u00a0}\r\n}\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A while ago I tried to run Google&#8217;s V8 Javascript engine on top of XPages, and today I found the reason why my server crashed after the first click: I have tried to load the engine only once (statically), and &hellip; <a href=\"https:\/\/hasselba.ch\/blog\/?p=2061\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[76,74],"tags":[47,7,11,31,5,3],"class_list":["post-2061","post","type-post","status-publish","format-standard","hentry","category-ssjs","category-xpages","tag-9-0","tag-domino","tag-http","tag-java","tag-ssjs","tag-xpages"],"_links":{"self":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2061","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2061"}],"version-history":[{"count":1,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2061\/revisions"}],"predecessor-version":[{"id":2062,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2061\/revisions\/2062"}],"wp:attachment":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2061"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2061"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2061"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}