Bug 224148 - Web service scenarios broke in latest builds with Equinox p2
Summary: Web service scenarios broke in latest builds with Equinox p2
Status: CLOSED FIXED
Alias: None
Product: WTP Webservices
Classification: WebTools
Component: jst.ws (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 blocker (vote)
Target Milestone: 3.0 M6   Edit
Assignee: Andrew Mak CLA
QA Contact: Kathy Chan CLA
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-03-26 13:14 EDT by Andrew Mak CLA
Modified: 2008-05-08 14:39 EDT (History)
3 users (show)

See Also:


Attachments
patch (4.26 KB, patch)
2008-03-26 16:05 EDT, Andrew Mak CLA
no flags Details | Diff
updated patch (4.78 KB, patch)
2008-03-26 17:19 EDT, Andrew Mak CLA
bjorn.freeman-benson: iplog+
Details | Diff
patched org.eclipse.jst.ws.axis.consumption.ui plugin (77.65 KB, application/x-zip-compressed)
2008-03-26 18:10 EDT, Andrew Mak CLA
no flags Details
patched org.eclipse.wst.ws plugin (209.36 KB, application/x-zip-compressed)
2008-03-26 18:11 EDT, Andrew Mak CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Mak CLA 2008-03-26 13:14:57 EDT
WTP 3.0 build I20080326051939

In the new WTP that uses Equinox p2, Web service scenarios are broken at places where we need to copy files from the plugin to the workspace.  An error such as the one below is issued:

IWAB0506E Error when copying Axis jar files to web project
    java.io.FileNotFoundException: D:\WTP\3.0\20080326051939\eclipse\ce:file:dropins\eclipse\plugins\javax.wsdl_1.5.1.v200803061910.jar (The filename, directory name, or volume label syntax is incorrect)

Notice that the path segment "ce:file:dropins" is wrong and should be just "dropins".
Comment 1 Andrew Mak CLA 2008-03-26 13:18:38 EDT
A quick look through the Web service code shows that it just getting the plugin install directory using platform bundle APIs, i.e.:

<snip>
Bundle      bundle     = Platform.getBundle( bundleId );
URL         installURL = bundle.getEntry("/");
URL         fileURL    = new URL(installURL, path );

return fileURL;
</snip>

Comment 2 Kathy Chan CLA 2008-03-26 13:37:38 EDT
This needs to be fixed in this week's I-build for WTP 3.0 M6.
Comment 3 David Williams CLA 2008-03-26 14:03:20 EDT
where is that "path" segment coming from? 
Comment 4 Andrew Mak CLA 2008-03-26 14:12:00 EDT
A correction about my previous comment, I was looking at the wrong method. 
This is actually what we are using:

static public IPath getJarredPluginPath(String bundleId) {
    IPath result = null;
    Bundle bundle = Platform.getBundle(bundleId);
    if (bundle != null) {
        Path runtimeLibFullPath = null;
        String jarPluginLocation = bundle.getLocation().substring(7);
        Path jarPluginPath = new Path(jarPluginLocation);
        // handle case where jars are installed outside of eclipse installation
        if (jarPluginPath.isAbsolute())
            runtimeLibFullPath = jarPluginPath;
        // handle normal case where all plugins under eclipse install
        else {
            String installPath =
Platform.getInstallLocation().getURL().getPath();
            runtimeLibFullPath = new Path(installPath + "/" +
jarPluginLocation); //$NON-NLS-1$
        }
        result = runtimeLibFullPath;
    }
    return result;
}


The substring(7) looks a bit suspicious to me, but at the moment I'm having
trouble getting self-hosting working with a P2'd WTP build so I can't trace
thru the code to see what's happening there.
Comment 5 David Williams CLA 2008-03-26 15:33:33 EDT
(In reply to comment #4)
> 
> The substring(7) looks a bit suspicious to me, but at the moment I'm having
> trouble getting self-hosting working with a P2'd WTP build so I can't trace
> thru the code to see what's happening there.
> 

I'm sure that's it. 

Looks like what you want is some way to go from a Bundle's URL location to an IPath? I'm not sure that's (always) possible ... any chance you can not use an IPath? 

Comment 6 John Arthorne CLA 2008-03-26 16:02:50 EDT
Yes, that code looks like it's making some bad assumptions. This also looks wrong:

String installPath =
Platform.getInstallLocation().getURL().getPath();
            runtimeLibFullPath = new Path(installPath + "/" +
jarPluginLocation); //$NON-NLS-1$

I suspect there are other scenarios where this would have failed in the past (using extension locations for example). You are likely getting a reference: URL back from Bundle.getLocation(), hence the "ce:file:" path.

Tom, can you recommend the right thing to do here? FileLocator#resolve I assume.
Comment 7 Andrew Mak CLA 2008-03-26 16:05:59 EDT
Created attachment 93679 [details]
patch

Actually, we ultimately want to get a File object for the plugin jar file, and I found that we can do that much more easily using FileLocator.getBundleFile() API call.

This patch bypasses using BundleUtils.getJarredPluginPath() completely and I tested that it works in both pre/post P2 environments.  I also propose to deprecate the getJarredPluginPath() method.
Comment 8 Andrew Mak CLA 2008-03-26 16:21:23 EDT
Yes exactly, in P2 Bundle.getLocation() was returning "reference:file:dropins\eclipse\plugins\xyz.jar"

Is it safe to assume FileLocator.getBundleFile() will work for extension location case?
Comment 9 Thomas Watson CLA 2008-03-26 16:44:21 EDT
(In reply to comment #7)
> Created an attachment (id=93679) [details]
> patch
> 
> Actually, we ultimately want to get a File object for the plugin jar file, and
> I found that we can do that much more easily using FileLocator.getBundleFile()
> API call.

Yes this is the recommended way to get the path to the bundle content.  Note that this may be a jar or a directory depending on how the bundle was installed.

(In reply to comment #8)
> Yes exactly, in P2 Bundle.getLocation() was returning
> "reference:file:dropins\eclipse\plugins\xyz.jar"
> 
> Is it safe to assume FileLocator.getBundleFile() will work for extension
> location case?
> 
Yes this should work no matter where the bundle is installed on disk.

Comment 10 Andrew Mak CLA 2008-03-26 17:19:54 EDT
Created attachment 93694 [details]
updated patch

After discussing with Kathy, we will fix the getJarredPluginPath() method also, since there are some other code using it.

Thanks for everyone's input!
Comment 11 Kathy Chan CLA 2008-03-26 17:27:00 EDT
Patch committed and released to HEAD as v200803262125.

Thanks Andrew for the speedy resolution!
Comment 12 Andrew Mak CLA 2008-03-26 18:10:32 EDT
Created attachment 93706 [details]
patched org.eclipse.jst.ws.axis.consumption.ui plugin
Comment 13 Andrew Mak CLA 2008-03-26 18:11:42 EDT
Created attachment 93708 [details]
patched org.eclipse.wst.ws plugin
Comment 14 David Williams CLA 2008-03-27 10:56:35 EDT
For reference, I've opened bugs on other places where we've copied this method ... I think we all know who started it :) [and it wasn't Kathy or her team :) ] 

bug 224382
bug 224384 

Comment 15 David Williams CLA 2008-04-24 00:44:47 EDT
mass change to add 'contributed' keyword based on bugzilla query, please correct if that's not accurate (by marking patches as obsolete and removing the 'contributed' keyword. 
Comment 16 Kathy Chan CLA 2008-05-08 14:39:22 EDT
This problem has been long fixed and released.  Verified and closing.