2013-11-22 83 views
17

我有一個Webproject使用maven,當我嘗試將它部署到Tomcat 7,我得到以下信息:日食 - Tomcat的7 - java.lang.IndexOutOfBoundsException上發佈

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.) 

當我看tomcat的日誌文件中的「myworkpace.metadata.logs」我看到以下內容:

!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) 

如果我再次嘗試發佈,我只得到了第一個錯誤:

Could not publish to the server. 
java.lang.IndexOutOfBoundsException 

,並在日誌中:

!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) 

我試圖從一個全新安裝(乾淨日食,乾淨Tomcat和乾淨的工作空間)開始,進口從CVS的代碼,但還是同樣的問題

任何人有任何關於什麼可能不正確的想法(或者我如何找到問題)?

編輯

當我生成該項目到另一臺計算機上WAR文件,並直接部署該war文件通過管理控制檯的tomcat,它的工作原理。

我的猜測是,構建必須以某種方式不同......

EDIT2

我刪除了完整的Maven倉庫。爲此,我能夠正確地構建項目並使用導出的war文件在Tomcat上運行它。

但是,我仍然得到IndexOutOfBoundsException異常,當我嘗試直接從日食

EDIT3

發佈移除Maven倉庫了幾次後,我是能夠建立和運行項目。看來Maven有時會被損壞。

如果其他人應該有這個問題,請刪除完整的Maven目錄並對工作區中的每個項目運行maven更新。

+0

EDIT3的解決方案爲我工作。謝謝! – Frecklefoot

回答

17

maven倉庫可能已損壞。最好刪除完整的存儲庫並更新工作區中的所有項目。

+0

我面臨同樣的問題,但刪除存儲庫和更新項目不起作用。任何替代品? – dshgna

+0

我的maven回購大小非常巨大,因此我不想刪除其中的所有文件。那麼我可以通過名稱「org」刪除目錄嗎?我認爲stacktrace中的每個類都以org開頭。 @dshgna – verystrongjoe

0

讓我們試試下面提到的方式。所以請刪除以前的安裝。 步驟1 創建新的服務器運行時間 (窗口 - >首選項 - >服務器 - >運行時環境)。 步驟2 添加服務器到Eclipse (窗口 - >顯示視圖 - >服務器)添加一個新的服務器配置(右鍵單擊並選擇新建 - >服務器),但不要添加任何項目。 步驟3 打開服務器概述頁面 雙擊新的服務器配置打開服務器概述頁面,我們在其中爲服務器設置端口和超時。 步驟4

在服務器位置下選擇使用Tomcat安裝。保存。

您應該可以立即啓動服務器。現在將您的項目添加到服務器,然後就可以開始了。

+0

當我這樣做時,我仍然得到第二個錯誤: 無法發佈到服務器。 java.lang.IndexOutOfBoundsException –

+0

您是否能夠在不使用Eclipse的情況下獨立啓動服務器 – Varun

+0

是的,如果我導入在另一臺機器上構建的相同代碼的war文件,並直接在tomcat中將其導入而不使用eclipse,則應用程序運行正常。我編輯了我的帖子,包括這個新發現。我相信在構建代碼時一定會出現錯誤,而不是實際運行它。 –

3

儘管已經回答了這個問題 - 這是一個腐敗的存儲庫的問題,可以通過在eclipse之外將戰爭部署到Tomcat來確定存儲庫中的哪個jar損壞。

在我的情況的Tomcat然後在其日誌中報告問題出在哪裏放置(番石榴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) 
+0

我在展示如何確定哪個Jar文件被破壞 - 在Eclipse中遇到問題時並不明顯。 – jtsnr

+1

如何在eclipse之外部署到Tomcat? – dshgna

1

最大的可能是你的本地Maven回購的一些罐子包含在你的.war因爲依賴項已損壞。 正如jtsnr建議的那樣,您可以在Eclipse之外部署您的.war,以發現哪個jar損壞了。但有一個更快的解決方案。只需找到你的Maven項目的目標目錄(或者只是解壓縮.war)並找到* .jar文件(應該在WEB-INF/lib下)。 現在,用一個簡單的zip工具(例如:7-Zip)選擇全部並提取。您將收到每個已損壞文件的提示:在此之後,在Maven repo中找到該文件並刪除該文件的整個版本。 這樣,如果你有一個大的回購,你會獲得很多時間,避免重新下載整個罐子生態系統:) HTH ..

+0

這真的是最好的答案。發生這種情況時刪除整個庫似乎不是一個好的解決方案。 –