Nashorn抛出java.lang.runtimeexception:java.lang.classnotfoundException:jdk.nashorn.internal.runtime.context.getContext

技术标签: java.  Nashorn.

我正在尝试在OpenJDK版本“1.8.0_91”中使用Nashorn。我的代码如下。

ScriptEngineManager manager = new ScriptEngineManager(null);
ScriptEngine engine = manager.getEngineByName("nashorn");
engine.eval(getJSReaderFromResorces("env.nashorn.1.2.js"));

它在下面的最后一行中抛出异常。

Caused by: java.lang.ClassNotFoundException: jdk.nashorn.internal.runtime.Context.getContext
    at jdk.nashorn.internal.runtime.NativeJavaPackage.classNotFound(NativeJavaPackage.java:162)
    at jdk.nashorn.internal.scripts.Script$\^eval\_.:program(<eval>:1249)
    at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:623)
    at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
    at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)

看答案

engine.eval(getJSReaderFromResorces("env.nashorn.1.2.js"));

看来这个脚本使用Nashorn内部类名为“jdk.nashorn.internal.runtime.context”。这是一个名为“jdk.nashorn.internal.runtime”的包。使用Security Manager设置时运行时,此软件包就会受到保护,脚本不可见。

在任何情况下,访问Nashorn内部/实现类都是一个好主意 - 因为那些没有兼容性保证。

使用Java 9,无论安全管理器打开/关闭,都不会从Nashorn Module导出,因此无法访问这些包。


智能推荐

hive报java.lang.RuntimeException

报错如下: Exception in thread “main” java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient 报错原因: Metastore...

Java.lang.RuntimeException: stop failed

版权声明:本文为【欧阳鹏】原创文章,欢迎转载,转载请注明出处! 【http://blog.csdn.net/ouyang_peng】 今天在调用MediaRecorder.stop(),报错了,Java.lang.RuntimeException: stop failed.   [html] view plain copy E/AndroidRuntime(7698)...

java.lang.ClassNotFoundException: org.springframework.web.context.

情境再现: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702) at org.apache.catal...

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener 如果看到ma...

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoader

1.在eclipse中查看是否有spring-web.jar包,如果没有,在maven中导入此jar包,如果有,进行第二步。 2.检测tomcat的下的部署项目中是否有lib文件夹,如果没有,进行以下步骤: 右击项目->properties->找到Deployment Assembly,右边便是编译打包的配置,看是不是缺少了lib库的依赖,我的就是,点击Add,选择"Java...

猜你喜欢

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

1.问题描述 Maven web项目启动时,控制台报如下异常:   2.解决方案 首先,需要确定maven项目中确实引入了spring web的jar包依赖   其次,查看maven web项目部署到tomcat服务器,是否将相关的jar包放到了服务器相关位置。   此时,已经找到了问题所在。选中项目-右键-属性-Deployment Assembly,查看如下图 &...

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

ellipse下利用Spring framework初始化项目时,在POM.xml依赖文件、web.xml配置文件等都准备好,且参数配置无误的情况下出现下面报错 再次检查依赖文件没问题后,前往tomcat部署路径webapps下相应项目的lib文件夹,发现eclipse没有将maven依赖的jar包复制到该路径下 于是问题原因找到了,就是缺少jar包,接下来要做的就是让eclipse在编译时将相关...

java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener。

Tomcat启动的时候报错   java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener。 jar都有,上网查错的时候发现么没有把maven依赖放到lib下,设置后程序正常运行 添加步骤如下    点击右侧ADD 点击OK即可...

redis中的hash扩容渐进式rehash过程

背景: redis字典(hash表)当数据越来越多的时候,就会发生扩容,也就是rehash 对比:java中的hashmap,当数据数量达到阈值的时候(0.75),就会发生rehash,hash表长度变为原来的二倍,将原hash表数据全部重新计算hash地址,重新分配位置,达到rehash目的 redis中的hash表采用的是渐进式hash的方式: 1、redis字典(hash表)底层有...

不同系统下的回车\r和换行\n,及其历史

2019独角兽企业重金招聘Python工程师标准>>>      我们平时按下键盘上的‘回车键’,就能实现回车换行【我们在屏幕上所看到的就是光标移到了下一行的开头位置!!ps:不讨论软件实现的特殊功能,如word里的回车智能缩进】。因此对这个按键更准确说应该叫做‘回车换行键’ 就且将这种将光标移到下行开...

问答精选

How to get the sum of rows using a vector and the make the result in a column

I have a dataframe and i want to calculate the sum of variables present in a vector in every row and make the sum in other variable after i want the name of new variable created to be from the name of...

Call a custom class in zend framework

I have a very rough project that done partially in zend framework (not ZF2). The 'application', 'library' and 'public' folders are on the same root. Now i need to create a library 'Anil' in the 'libra...

Hide Some Of The Categories In Magento?

I want to hide some of the categories from magento home page. I have created some categories like New Arrivals, Special Offer Which I would like to show in some different way may be in left panel or r...

Reading an internal file in Android Studio

I am writing to an internal file in Android Studio The code lets me write lines of data split with commas. I am able to then go to another activity and read it all out at once. However I want to be ab...

Rails Acts_as_votable Gem Like/Unlike Buttons with Ajax

I'm new to Ruby On Rails, I used the acts_as_votable gem to create Like and Unlike Buttons to make Users like and unlike Posts but I can't make them change from Like to Unlike (and viceversa) and upda...

相关问题

相关文章

热门文章

推荐文章

相关标签

推荐问答