Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse - Tomcat 7 - java.lang.IndexOutOfBoundsException on publish

Tags:

I have a Webproject using maven and when I try to deploy it to Tomcat 7, I get the following message:

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:

!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

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.

My guess is that the build must be different somehow...

EDIT2

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.

However, I still get the IndexOutOfBoundsException when I try to publish directly from eclipse

EDIT3

After removing the Maven repository a few times, I was able to build and run the project. It seems Maven sometimes gets corrupted.

If others should have this problem, delete the complete Maven directory and run a maven update on each of the projects in the workspace.

like image 751
4_y Avatar asked Nov 22 '13 12:11

4_y


3 Answers

The maven repository can be corrupt. It is best to remove the complete repository and update all projects in the workspace.

like image 200
4_y Avatar answered Oct 20 '22 00:10

4_y


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.

In my situation Tomcat then reported in its log where the problem lay (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)
like image 34
jtsnr Avatar answered Oct 19 '22 23:10

jtsnr


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

like image 29
Matteo Pelucco Avatar answered Oct 19 '22 23:10

Matteo Pelucco