Eclipse 中关于从所需的 .class 文件间接引用的类型的错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7476092/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 20:33:18  来源:igfitidea点击:

Error in Eclipse about type indirectly referenced from required .class file

eclipse

提问by Fernando Moyano

I'm having this exception with some stubs generateds by Axis2:

我遇到了 Axis2 生成的一些存根的异常:

"The type org.apache.axiom.om.OMElement cannot be resolved. It is indirectly referenced from required .class files"

“无法解析 org.apache.axiom.om.OMElement 类型。它是从所需的 .class 文件间接引用的”

I've been reading many posts, and trying to find a solution. What I've found so far is to add the apache tomcat 5.5 library to the build path. It removed the error in the java file, but then, when I to execute any java program inside the project, I got this error:

我一直在阅读很多帖子,并试图找到解决方案。到目前为止我发现的是将 apache tomcat 5.5 库添加到构建路径中。它删除了java文件中的错误,但是,当我在项目中执行任何java程序时,我得到了这个错误:

'Launching myApp' has encountered a problem Exception occurred executing command line. Cannot run program "C:\Program Files\Java\jdk1.5.0_22\bin\javaw.exe" (in directory "D:\Digicel\workspace\Digicel\myClassSample"): CreateProcess error=87, The parameter is incorrect

“启动 myApp”遇到问题执行命令行时发生异常。无法运行程序“C:\Program Files\Java\jdk1.5.0_22\bin\javaw.exe”(在目录“D:\Digicel\workspace\Digicel\myClassSample”中):CreateProcess error=87,参数不正确

then if I remove the apache tomcat library from the build path, I can run the other java programs, but not the one mentioned initially.

然后如果我从构建路径中删除 apache tomcat 库,我可以运行其他 java 程序,但不能运行最初提到的那个。

Any thoughts about it?

有什么想法吗?

回答by Fernando Moyano

Okay, I've found the cause of the problem with the help of a friend :)

好的,我在朋友的帮助下找到了问题的原因:)

The thing is that Eclipse is aware that one of my dependencies, depends of another library, and Eclipse is checking for it when it tries to build the code.

问题是 Eclipse 知道我的一个依赖项依赖于另一个库,并且 Eclipse 在尝试构建代码时正在检查它。

So, what I've done is try to check which jar file contains this library: " org.apache.axiom.om.OMElement".

所以,我所做的是尝试检查哪个 jar 文件包含这个库:“org.apache.axiom.om.OMElement”。

I've googled it and found that it is "axiom-api-1.2.10.jar" and finally my file compiled with 0 errors.

我用谷歌搜索它,发现它是“axiom-api-1.2.10.jar”,最后我的文件编译为 0 个错误。

He also explained to me that my original solution of adding the apache tomcat server library is adding all the jars that cames with apache tomcat (which is a big list), and probably there may have been a version conflict with my current list of added jars.

他还跟我解释说,我原来的添加apache tomcat服务器库的方案是把apache tomcat自带的jar包都加进去(这是一个很大的列表),可能和我目前添加的jar列表有版本冲突.

So, the fix was to find the appropriate jar and add it to the project.

因此,解决方法是找到合适的 jar 并将其添加到项目中。

回答by Martin

This error can also occur when a indirect dependency has a corrupt jar file. This may be caused by problems at the public maven repository.

当间接依赖项具有损坏的 jar 文件时,也会发生此错误。这可能是由公共 maven 存储库中的问题引起的。

If this is the case removing the local maven repository to download fresh jar files will fix your problem:

如果是这种情况,删除本地 Maven 存储库以下载新的 jar 文件将解决您的问题:

rm -Rf ~/.m2/repository/{enter/path/to/broken/stuff}