Eclipse - Tomcat 7 - 发布时出现 java.lang.IndexOutOfBoundsException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20145399/
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
Eclipse - Tomcat 7 - java.lang.IndexOutOfBoundsException on publish
提问by 4_y
I have a Webproject using maven and when I try to deploy it to Tomcat 7, I get the following message:
我有一个使用 maven 的 Web 项目,当我尝试将它部署到 Tomcat 7 时,我收到以下消息:
Publishing failed
Could not publish to the server.
java.lang.IndexOutOfBoundsException
Could not publish server configuration: myworkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\server.xml (The system cannot find the path specified.).
myworkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\server.xml (The system cannot find the path specified.)
When I look at the log file of tomcat in 'myworkpace.metadata.logs' I see the following:
当我在“myworkpace.metadata.logs”中查看 tomcat 的日志文件时,我看到以下内容:
!ENTRY org.eclipse.wst.server.core 4 0 2013-11-22 13:36:40.128
!MESSAGE Publishing failed
!SUBENTRY 1 org.eclipse.wst.server.core 4 0 2013-11-22 13:36:40.128
!MESSAGE Could not publish to the server.
!STACK 0
java.lang.IndexOutOfBoundsException
at java.io.BufferedInputStream.read(BufferedInputStream.java:338)
at org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsByteArray(Util.java:498)
at org.eclipse.jdt.core.ToolFactory.createDefaultClassFileReader(ToolFactory.java:269)
at org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities.isEJBArchive(JavaEEArchiveUtilities.java:900)
at org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities.refineForJavaEE(JavaEEArchiveUtilities.java:606)
at org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities.openArchive(JavaEEArchiveUtilities.java:370)
at org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities.openBinaryArchive(JavaEEArchiveUtilities.java:290)
at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper$ArchiveCache.openArchive(JavaEEBinaryComponentHelper.java:612)
at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.openArchive(JavaEEBinaryComponentHelper.java:470)
at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.getUniqueArchive(JavaEEBinaryComponentHelper.java:422)
at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.getArchive(JavaEEBinaryComponentHelper.java:415)
at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.getJavaEEQuickPeek(JavaEEBinaryComponentHelper.java:98)
at org.eclipse.jst.j2ee.project.JavaEEProjectUtilities.getJ2EEComponentType(JavaEEProjectUtilities.java:273)
at org.eclipse.jst.j2ee.internal.common.exportmodel.JEEHeirarchyExportParticipant.isChildModule(JEEHeirarchyExportParticipant.java:42)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.isChildModule(FlatVirtualComponent.java:367)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.addUsedReferences(FlatVirtualComponent.java:305)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.treeWalk(FlatVirtualComponent.java:235)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.cacheResources(FlatVirtualComponent.java:188)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.fetchResources(FlatVirtualComponent.java:118)
at org.eclipse.wst.web.internal.deployables.FlatComponentDeployable.members(FlatComponentDeployable.java:227)
at org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable.members(J2EEFlexProjDeployable.java:267)
at org.eclipse.wst.server.core.internal.ModulePublishInfo.getDelta(ModulePublishInfo.java:407)
at org.eclipse.wst.server.core.internal.ServerPublishInfo.getDelta(ServerPublishInfo.java:366)
at org.eclipse.wst.server.core.internal.Server.getPublishedResourceDelta(Server.java:1574)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.getPublishedResourceDelta(ServerBehaviourDelegate.java:698)
at org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour.getPublishedResourceDelta(TomcatServerBehaviour.java:958)
at org.eclipse.jst.server.tomcat.core.internal.PublishOperation2.publishDir(PublishOperation2.java:137)
at org.eclipse.jst.server.tomcat.core.internal.PublishOperation2.execute(PublishOperation2.java:82)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.performTasks(ServerBehaviourDelegate.java:1335)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:954)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:774)
at org.eclipse.wst.server.core.internal.Server.publishImpl(Server.java:3153)
at org.eclipse.wst.server.core.internal.Server$PublishJob.run(Server.java:345)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
!SUBENTRY 1 org.eclipse.jst.server.tomcat.core 4 0 2013-11-22 13:36:40.128
!MESSAGE Could not publish server configuration: C:\IBM\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\server.xml (The system cannot find the path specified.).
!STACK 0
java.io.FileNotFoundException: myworkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\server.xml (The system cannot find the path specified.)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:149)
at org.eclipse.jst.server.tomcat.core.internal.TomcatVersionHelper.publishCatalinaContextConfig(TomcatVersionHelper.java:499)
at org.eclipse.jst.server.tomcat.core.internal.Tomcat70Configuration.publishContextConfig(Tomcat70Configuration.java:674)
at org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour.publishFinish(TomcatServerBehaviour.java:462)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:1011)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:774)
at org.eclipse.wst.server.core.internal.Server.publishImpl(Server.java:3153)
at org.eclipse.wst.server.core.internal.Server$PublishJob.run(Server.java:345)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
If I try to publish again, I only get the first error:
如果我再次尝试发布,我只会收到第一个错误:
Could not publish to the server.
java.lang.IndexOutOfBoundsException
and in the logs:
并在日志中:
!ENTRY org.eclipse.wst.server.core 4 0 2013-11-22 13:41:18.645
!MESSAGE Could not publish to the server.
!STACK 0
java.lang.IndexOutOfBoundsException
at java.io.BufferedInputStream.read(BufferedInputStream.java:338)
at org.eclipse.jdt.internal.compiler.util.Util.getInputStreamAsByteArray(Util.java:498)
at org.eclipse.jdt.core.ToolFactory.createDefaultClassFileReader(ToolFactory.java:269)
at org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities.isEJBArchive(JavaEEArchiveUtilities.java:900)
at org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities.refineForJavaEE(JavaEEArchiveUtilities.java:606)
at org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities.openArchive(JavaEEArchiveUtilities.java:370)
at org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities.openBinaryArchive(JavaEEArchiveUtilities.java:290)
at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper$ArchiveCache.openArchive(JavaEEBinaryComponentHelper.java:612)
at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.openArchive(JavaEEBinaryComponentHelper.java:470)
at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.getUniqueArchive(JavaEEBinaryComponentHelper.java:422)
at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.getArchive(JavaEEBinaryComponentHelper.java:415)
at org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper.getJavaEEQuickPeek(JavaEEBinaryComponentHelper.java:98)
at org.eclipse.jst.j2ee.project.JavaEEProjectUtilities.getJ2EEComponentType(JavaEEProjectUtilities.java:273)
at org.eclipse.jst.j2ee.internal.common.exportmodel.JEEHeirarchyExportParticipant.isChildModule(JEEHeirarchyExportParticipant.java:42)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.isChildModule(FlatVirtualComponent.java:367)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.addUsedReferences(FlatVirtualComponent.java:305)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.treeWalk(FlatVirtualComponent.java:235)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.cacheResources(FlatVirtualComponent.java:188)
at org.eclipse.wst.common.componentcore.internal.flat.FlatVirtualComponent.fetchResources(FlatVirtualComponent.java:118)
at org.eclipse.wst.web.internal.deployables.FlatComponentDeployable.members(FlatComponentDeployable.java:227)
at org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable.members(J2EEFlexProjDeployable.java:267)
at org.eclipse.wst.server.core.internal.ModulePublishInfo.fillCache(ModulePublishInfo.java:314)
at org.eclipse.wst.server.core.internal.ModulePublishInfo.getDelta(ModulePublishInfo.java:396)
at org.eclipse.wst.server.core.internal.ServerPublishInfo.getDelta(ServerPublishInfo.java:366)
at org.eclipse.wst.server.core.internal.Server.getPublishedResourceDelta(Server.java:1574)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.getPublishedResourceDelta(ServerBehaviourDelegate.java:698)
at org.eclipse.jst.server.tomcat.core.internal.TomcatServerBehaviour.getPublishedResourceDelta(TomcatServerBehaviour.java:958)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.computeDelta(ServerBehaviourDelegate.java:874)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:909)
at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:774)
at org.eclipse.wst.server.core.internal.Server.publishImpl(Server.java:3153)
at org.eclipse.wst.server.core.internal.Server$PublishJob.run(Server.java:345)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
I tried starting from a clean installation (clean eclipse, clean tomcat and clean workspace), imported the code from CVS, but still the same problem
我尝试从干净的安装(干净的 Eclipse、干净的 tomcat 和干净的工作区)开始,从 CVS 导入代码,但仍然是同样的问题
Anyone got any ideas as to what may be incorrect (or how I could locate the problem)?
任何人对什么可能不正确(或我如何找到问题)有任何想法?
EDIT
编辑
When I build the project into a WAR-file on another computer and deploy this war file directly to tomcat via the management console, it works.
当我将项目构建到另一台计算机上的 WAR 文件中并通过管理控制台将这个 WAR 文件直接部署到 tomcat 时,它可以工作。
My guess is that the build must be different somehow...
我的猜测是构建必须以某种方式不同......
EDIT2
编辑2
I removed the complete maven repository. Afer this, I was able to build the project correctly and run it on Tomcat using the exported war-file.
我删除了完整的 Maven 存储库。在此之后,我能够正确构建项目并使用导出的War文件在 Tomcat 上运行它。
However, I still get the IndexOutOfBoundsException when I try to publish directly from eclipse
但是,当我尝试直接从 eclipse 发布时,我仍然收到 IndexOutOfBoundsException
EDIT3
编辑3
After removing the Maven repository a few times, I was able to build and run the project. It seems Maven sometimes gets corrupted.
多次删除 Maven 存储库后,我能够构建和运行该项目。看来 Maven 有时会损坏。
If others should have this problem, delete the complete Maven directory and run a maven update on each of the projects in the workspace.
如果其他人遇到此问题,请删除完整的 Maven 目录并在工作区中的每个项目上运行 Maven 更新。
回答by 4_y
The maven repository can be corrupt. It is best to remove the complete repository and update all projects in the workspace.
Maven 存储库可能已损坏。最好删除完整的存储库并更新工作区中的所有项目。
回答by jtsnr
Although this question has been answered - it was a problem with a corrupt repository, it is possible to determine which jar in your repository is corrupt by deploying the war to Tomcat outside of eclipse.
尽管这个问题已经得到回答——这是一个损坏的存储库的问题,但可以通过将 war 部署到 Eclipse 之外的 Tomcat 来确定存储库中的哪个 jar 损坏。
In my situation Tomcat then reported in its log where the problem lay (guava-13.0.1.jar):
在我的情况下,Tomcat 然后在其日志中报告了问题所在(guava-13.0.1.jar):
SEVERE: Unable to process Jar entry [com/google/common/collect/package-info.class] from Jar [jar:file:/C:/Java/tomcat/apache-tomcat-7.0.42/webapps/myapp/WEB-INF/lib/guava-13.0.1.jar!/] for annotations java.util.zip.ZipException: invalid LOC header (bad signature)
回答by Matteo Pelucco
Most probably some jar of your local maven repo that are included in your .war as dependency are corrupted. As jtsnr suggested, you can deploy your .war outside Eclipse to discover which jar is corrupted. But there is a quicker solution. Just locate the /target dir of your maven project (or just unzip the .war) and locate inside the *.jar files (should be under WEB-INF/lib). Now, with a simple zip tool (e.g.: 7-Zip) select all and extract. You will receive a prompt for each corrupted file you have: after this, locate the file in your Maven repo and delete the entire version for that file. In this way, if you have a big repo, you gain a lot of time avoiding to re-download the entire jar ecosystem :) HTH..
很可能是您的 .war 中包含的本地 Maven 存储库的一些 jar,因为依赖项已损坏。正如 jtsnr 所建议的,您可以在 Eclipse 之外部署您的 .war 以发现哪个 jar 已损坏。但是有一个更快的解决方案。只需找到您的 maven 项目的 /target 目录(或者只是解压缩 .war)并找到 *.jar 文件(应该在 WEB-INF/lib 下)。现在,使用一个简单的 zip 工具(例如:7-Zip)全选并解压缩。您将收到有关您拥有的每个损坏文件的提示:在此之后,在您的 Maven 存储库中找到该文件并删除该文件的整个版本。这样,如果你有一个很大的 repo,你就可以避免重新下载整个 jar 生态系统 :) HTH ..
回答by Varun
Lets try once the way it is mentioned below. so please delete the previous installation. Step 1 Create a new Server run time (Window -> Preferences -> Server -> Runtime Environments). Step 2 Add Server to Eclipse (Window -> Show View -> Servers) add a new server configuration (right-click and select New -> Server) but DO NOT ADD ANY PROJECTS TO IT. Step 3 Open Server Overview page Double click the new server configuration to bring up the Server Overview page where we set port and time out for the Server. Step 4
让我们尝试一下下面提到的方式。所以请删除之前的安装。步骤 1 创建一个新的服务器运行时(Window -> Preferences -> Server -> Runtime Environments)。第 2 步将服务器添加到 Eclipse(窗口 -> 显示视图 -> 服务器)添加新的服务器配置(右键单击并选择新建 -> 服务器),但不要向其添加任何项目。第 3 步打开服务器概览页面双击新的服务器配置以打开服务器概览页面,我们在其中设置服务器的端口和超时。第四步
Under Server Locations select Use Tomcat installation. Save.
在服务器位置下选择使用 Tomcat 安装。节省。
You should be able to start your server now. Now add your project to the server and you're ready to go.
您现在应该可以启动服务器了。现在将您的项目添加到服务器,您就可以开始了。