Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 313181 - Java EE import fails if zip entries contain leading slashes
Summary: Java EE import fails if zip entries contain leading slashes
Status: RESOLVED FIXED
Alias: None
Product: WTP Java EE Tools
Classification: WebTools
Component: jst.j2ee (show other bugs)
Version: 3.0.5   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.0.5 P   Edit
Assignee: Jason Sholl CLA
QA Contact: Chuck Bridgham CLA
URL:
Whiteboard:
Keywords:
Depends on: 312728
Blocks:
  Show dependency tree
 
Reported: 2010-05-17 12:26 EDT by Jason Sholl CLA
Modified: 2010-05-21 08:33 EDT (History)
2 users (show)

See Also:
cbridgha: review+


Attachments
patch (976 bytes, patch)
2010-05-17 12:43 EDT, Jason Sholl CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Sholl CLA 2010-05-17 12:26:53 EDT
+++ This bug was initially created as a clone of Bug #312728 +++

Importing any EE artifact will fail if any of the zip entries contain leading slashes, e.g "/foo.txt" instead of "foo.txt".  It's not clear to me how the exmple ear archive was created, but it fails with an exception like the following:

java.lang.RuntimeException: /com/ibm/websphere/csi/ must be relative.
	at org.eclipse.jst.jee.archive.AbstractArchiveLoadAdapter.verifyRelative(Unknown Source)
	at org.eclipse.jst.jee.archive.AbstractArchiveLoadAdapter.createDirectory(Unknown Source)
	at org.eclipse.jst.jee.archive.internal.ZipFileArchiveLoadAdapterImpl.createFile(Unknown Source)
	at org.eclipse.jst.jee.archive.internal.ZipFileArchiveLoadAdapterImpl.getArchiveResources(Unknown Source)
	at org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities$JavaEEWrappingLoadAdapter.getArchiveResources(Unknown Source)
	at org.eclipse.jst.jee.archive.internal.ArchiveImpl.getArchiveResources(Unknown Source)
	at org.eclipse.jst.j2ee.internal.archive.ArchiveWrapper.getSize(Unknown Source)
	at org.eclipse.jst.j2ee.internal.archive.operations.EARComponentImportOperation.computeTotalWork(Unknown Source)
	at org.eclipse.jst.j2ee.internal.archive.operations.J2EEArtifactImportOperation.execute(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl$1.run(Unknown Source)
	at org.eclipse.core.internal.resources.Workspace.run(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.runOperation(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.doExecute(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.executeImpl(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.cacheThreadAndContinue(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelPausibleOperationImpl.execute(Unknown Source)
	at org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelWizard$1CatchThrowableRunnableWithProgress.run(Unknown Source)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(Unknown Source)


The fix is very simple and safe which is to ensure the paths are relative by calling Path.makeRelative().  This method will return itself if it is already relative so will not have performance implications.
Comment 1 Jason Sholl CLA 2010-05-17 12:27:51 EDT
The fix is already in 3.2; this is a backport.
Comment 2 Jason Sholl CLA 2010-05-17 12:43:20 EDT
Created attachment 168762 [details]
patch
Comment 3 Chuck Bridgham CLA 2010-05-18 10:54:27 EDT
approve
Comment 4 Carl Anderson CLA 2010-05-21 08:33:25 EDT
Committed to R3_0_5_patches