当我尝试将包含一些JavaScript的项目导入到工作区中时(使用Eclipse的Neon.M6版本),出现以下错误:
eclipse.buildId=4.6.0.I20160317-0200
java.version=1.8.0_05
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
org.eclipse.core.jobs
Error
Wed Mar 30 18:38:50 CEST 2016
An internal error occurred during: "Validating ****".
java.lang.NoClassDefFoundError: jdk/nashorn/internal/runtime/ECMAException
at org.eclipse.wst.jsdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:860)
at org.eclipse.wst.jsdt.core.dom.ASTParser.createAST(ASTParser.java:651)
at org.eclipse.wst.jsdt.internal.core.validation.JavaScriptValidator.validate(JavaScriptValidator.java:62)
at org.eclipse.wst.validation.Validator$V2.validate(Validator.java:1159)
at org.eclipse.wst.validation.internal.ValManager.validate(ValManager.java:704)
at org.eclipse.wst.validation.internal.ValManager$1.visit(ValManager.java:665)
at org.eclipse.wst.validation.internal.ValManager.accept(ValManager.java:810)
at org.eclipse.wst.validation.internal.ValManager.validate(ValManager.java:669)
at org.eclipse.wst.validation.internal.ValBuilderJob$Visitor.visit(ValBuilderJob.java:299)
at org.eclipse.core.internal.resources.Resource$2.visit(Resource.java:120)
at org.eclipse.core.internal.resources.Resource$1.visitElement(Resource.java:84)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:82)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:129)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:94)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:52)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:117)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:105)
at org.eclipse.wst.validation.internal.ValBuilderJob.fullBuild(ValBuilderJob.java:219)
at org.eclipse.wst.validation.internal.ValBuilderJob.run(ValBuilderJob.java:178)
at org.eclipse.wst.validation.internal.ValBuilderJob.runInWorkspace(ValBuilderJob.java:126)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:39)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.ClassNotFoundException: jdk.nashorn.internal.runtime.ECMAException cannot be found by org.eclipse.wst.jsdt.core_2.0.0.v201603171403
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:444)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:357)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:349)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 27 more
我正在使用默认情况下应包含JSDT的“ Eclipse for Scout Developers”(由于the changes in the Scout Framework for Neon,这是Neon的新功能)。
这里是我当前安装的Eclipse Installation Details(仅JSDT插件):
知道这可能是什么吗?
最佳答案
通过与G.Erkan的聊天,我了解了Nashorn如何迷上JSDT。在这里,我写下了该机制。我认为这足以理解和解决问题。
Nashorn是Javascript运行时库,可从Java 8+在<java-home>/lib/ext
文件夹中获得。
默认情况下,OSGi捆绑包使用引导类加载器,其中不包括lib / ext
当JSDT.core使用Nashorn时,JSDT团队制定了一种加载此外部库的方法。
技巧包括两个部分:
在运行时:org.eclipse.wst.jsdt.nashorn.extension捆绑包片段具有扩展ClassLoaderHook的类,该类通过添加lib / ext文件夹来扩展捆绑包类路径。
要激活ClassLoaderHook,您需要添加以下参数以启动配置以使挂钩有效:
-Dosgi.framework.extensions=org.eclipse.wst.jsdt.nashorn.extension
实际上:您需要将参数添加到正在运行的配置或产品配置中,以使其在运行时正常工作。
为了在开发时以及在本地Tycho构建中进行测试:您将需要指定一个参数来告诉Equinox类加载器加载普通的Java扩展类加载器。
为此,您将需要使用以下参数:
-Dorg.osgi.framework.bundle.parent=ext
实际上,您需要将参数添加到测试配置和tycho配置中。例如,检查
webtools.jsdt\tests\pom.xml
,您可以在其中看到Tycho surefire参数:<argLine>-Dorg.osgi.framework.bundle.parent=ext</argLine>
也可以看看
OSGi and Equinox: Creating Highly Modular Java Systems, Chap 23.9
关于javascript - Eclipse JSDT:内部错误NoClassDefFoundError:jdk/nashorn/internal/runtime/ECMAException,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36317684/