Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Cannot find a file in my bundle
Cannot find a file in my bundle [message #856509] Wed, 25 April 2012 18:38 Go to next message
loic Missing name is currently offline loic Missing nameFriend
Messages: 6
Registered: December 2011
Junior Member
Hi,

I have a plugin that creates template files in a workspace project. The template file is stored in the bundle, my build.properties looks like:

source.. = src/
output.. = bin/
bin.includes = META-INF/,\
               .,\
               templates/


where the directory "templates/" hosts my template file.

In my plugin I have some code doing:

		// Step 1: Find the template description file in the bundle
		URL url = FileLocator.find(Platform.getBundle(Activator.PLUGIN_ID),
				new Path(PROJECT_TEMPLATES_PATH + File.separator + projectType
						+ File.separator + templateName), null);
		if (url == null) ...{


where PROJECT_TEMPLATES_PATH is "templates"


When I test my plugin in my development Eclipse (Run As "Eclipse Application") it works fine, it can find the template "templates/foo/bar".

When I install the feature (that includes my plugin) in a fresh new Eclipse, it fails to find the "templates/foo/bar" template file. The file is in my plugin jar file, my plugin jar file is correctly installed in the <eclipse>/plugins directory. Actually the plugin works all fine except that it cannot find the template.

I checked the state of the bundle, it is in state ACTIVE.

I put some traces, and the code can find the bundle (i.e. "Platform.getBundle(Activator.PLUGIN_ID)" works fine) but it cannot find the entry...

Any reasons why ?
How can I find out the reason ? (any way to debug this?)

Thanks!
Re: Cannot find a file in my bundle [message #859880 is a reply to message #856509] Fri, 27 April 2012 21:22 Go to previous message
loic Missing name is currently offline loic Missing nameFriend
Messages: 6
Registered: December 2011
Junior Member
I found a way to workaround this issue. I am not sure if it is bug or just my ignorance.

It turns out that :

		URL url = FileLocator.find(
				Platform.getBundle(Activator.PLUGIN_ID),
				new Path(Consts.TEMPLATES_PATH + File.separator +
					PROJECT_DIRECTORY + File.sperator +
					projectType.toLowerCase() + File.separator +
					templateName + Consts.EXTENSION_DESCRIPTION),
				null);


works fine testing from the dev Eclipse (using Run as... Application) but does not work (url == null) when I install my feature/plugin in a brand new Eclipse.

The workaround is to use Path.append(String str):

		URL url = FileLocator.find(
				Platform.getBundle(Activator.PLUGIN_ID),
				new Path(Consts.TEMPLATES_PATH).append(PROJECT_DIRECTORY)
						.append(projectType.toLowerCase())
						.append(templateName + Consts.EXTENSION_DESCRIPTION),
				null);


That would work on both my dev Eclipse test (Run as... Eclipse Application) and also when I deploy my feature/plugin in a brand new Eclipse.

Feel free to comment to explain the behavior difference. I am running all my dev/tests on Windows so the path separator should not be an issue.
Previous Topic:Administrator rights and Software update
Next Topic:OSGI bundle start fail,erro:java.lang.ClassNotFoundException: org.xml.sax.EntityResolver
Goto Forum:
  


Current Time: Sat Oct 23 17:58:22 GMT 2021

Powered by FUDForum. Page generated in 0.02222 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top