Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » BundleInstall.begin throws exception
BundleInstall.begin throws exception [message #519216] Mon, 08 March 2010 06:15 Go to next message
Suraj  is currently offline Suraj Friend
Messages: 16
Registered: November 2009
Location: Bangalore
Junior Member
I have two questions both related:


    What exactly is BundleInstall.begin() trying to accomplish? I have read the code a little bit, and I see that its trying to "create a generation directory" and copy my bundle directory in to it. What exactly is a generation directory and why is it trying to copy my bundle directory in to it. Is it trying to cache or something?


    The other question is an issue actually. My bundle is not installing simply because it contains a file with chinese file name. The following exception will tell it all:
    Caused by: java.io.FileNotFoundException: /opt/server/ds/bundles/com.x.y.ds/���� eam-ds.jar.bak (No such file or directory)
    	at java.io.FileInputStream.open(Native Method)
    	at java.io.FileInputStream.<init>(FileInputStream.java:106)
    	at org.eclipse.osgi.internal.baseadaptor.AdaptorUtil.copyDir(AdaptorUtil.java:54)
    	at org.eclipse.osgi.internal.baseadaptor.BundleInstall.begin(BundleInstall.java:75)


The reason its giving FileNotFound is that the filename is chinese and it cant recognize it. Does anyone know how I can avoid this?

OS: Solaris 10 (Chinese)

[Updated on: Mon, 08 March 2010 06:17]

Report message to a moderator

Re: BundleInstall.begin throws exception [message #519338 is a reply to message #519216] Mon, 08 March 2010 14:43 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
BundleInstall.begin is trying to copy the bundle's content into the framework's local storage area. This is the default behavior of the framework when installing bundles from a URL (e.g. file: URL). I am not sure I understand why the standard File operations are not working just because there are some Chinese characters in the file names.

There are a few ways to avoid this:

1) use reference: URLs instead of file: URLs to install your bundle. For example reference:file:/opt/server/ds/bundles/com.x.y.ds/

2) Make your bundle a jar'ed bundle so the framework does not need to do a recursive directory copy of the bundle content.

But I wonder if you try this if it will still work. Since the pretty standard File operations did not work to copy the content of the bundle I have doubts that the framework will be able to load the content correctly at runtime if you use reference installs or if you jar the Chinese character file names into a bundle jar.
Re: BundleInstall.begin throws exception [message #519521 is a reply to message #519338] Tue, 09 March 2010 08:22 Go to previous messageGo to next message
Suraj  is currently offline Suraj Friend
Messages: 16
Registered: November 2009
Location: Bangalore
Junior Member
Why does it try to copy it to the framework local storage area? What does it achieve from it? Is it some kind of caching?
Re: BundleInstall.begin throws exception [message #519622 is a reply to message #519521] Tue, 09 March 2010 14:10 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
That is the behavior specified by the OSGi specification. The BundleContext.installBundle methods take an opaque location string and optionally an inputstream. Internally the framework will convert the opaque location string into a URL connection if possible to obtain an input stream to the content of the bundle. Since the URL may point to any protocol specific content frameworks are required to copy the content down to a local cache. Even for file: URLs. This is to ensure the content is under complete control by the framework. For example, you cannot expect a bundle's content to be updated simply by replacing the original location with a new jar. You must do an explicit update operation to get the new content installed into the framework.

In Equinox we added the reference: URL to avoid the need to copy the content of the bundle into the local framework storage cache. But this had different semantics than a normal installation where the content is copied into the frameworks storage.
Re: BundleInstall.begin throws exception [message #520099 is a reply to message #519622] Thu, 11 March 2010 07:51 Go to previous messageGo to next message
Suraj  is currently offline Suraj Friend
Messages: 16
Registered: November 2009
Location: Bangalore
Junior Member
Does copying the contents into the framework storage area, make things work faster the next time, the system is started?

Or is it that every single time osgi starts, the content will be copied?
Re: BundleInstall.begin throws exception [message #520190 is a reply to message #520099] Thu, 11 March 2010 14:09 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
This has nothing to do with performance. According to the specification the framework must copy a "snapshot" of the bundle content when it is installed. This is to avoid having to worry about the content changing in the bundle without the use of proper OSGi bundle update methods.

The copy is only made once at install time. But as I stated before you can avoid this behavior by using a reference:file: URL instead.

HTH

Tom.
Re: BundleInstall.begin throws exception [message #520343 is a reply to message #520190] Fri, 12 March 2010 01:39 Go to previous messageGo to next message
Suraj  is currently offline Suraj Friend
Messages: 16
Registered: November 2009
Location: Bangalore
Junior Member
Now I am completely done. Shocked . What we do is that we hava a launcher that will set the parent classloader type to "fwk" and start equinox invoking EclipseStarter via reflection. We read a list of bundles from a property file and for each of them in the list we do something like:

Bundle bundle = context.installBundle(bundleLoc);
bundle.start();


From your previous reply it seems that I dont need to do installBundle() every time. Am I doing something worng here?
Re: BundleInstall.begin throws exception [message #520345 is a reply to message #520343] Fri, 12 March 2010 03:19 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
It should not be necessary to install the bundles each startup. But it is also not necessarily wrong to do what you are doing. Trying to install a bundle with the same location string for a bundle which is already installed is a no-op to the framework. It should not even cause the URL to be constructed from the string. Instead the originally installed Bundle object is returned according to the javadoc.

Tom.
Re: BundleInstall.begin throws exception [message #520360 is a reply to message #520345] Fri, 12 March 2010 05:37 Go to previous messageGo to next message
Suraj  is currently offline Suraj Friend
Messages: 16
Registered: November 2009
Location: Bangalore
Junior Member
I do an installBundle() for a bundle every time my application starts. Does the framework remeber the bundles even after the jvm exits(note that I am not using SimpleConfigurator or any other custom launcher). I do now understand that it does copy all bundles in to the framework storage, but somehow the next time it starts up the Framework.getBundleByLocation() returns null each time, so it doesent seem to remeber my previous bundles. Do you mean that, in a general scenario, installBundle needs to be done once and once only during the first run for the entire lifetime.

I tried "reference:",, in which case, the bundles are not copied to storage area. So what exactly is "reference:" protocol. Is it part of standard OSGI spec. Is there any document for it?

[Updated on: Fri, 12 March 2010 07:58]

Report message to a moderator

Re: BundleInstall.begin throws exception [message #520466 is a reply to message #520360] Fri, 12 March 2010 13:58 Go to previous messageGo to next message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
How are you launching the framework? Are you using -clean? This option will clear the framework cache each startup. How are you shutting down the framework. The persistent meta-data cache for Equinox is not saved until the framework is properly shutdown (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=298416 for improvments in 3.6). You should be stopping the system bundle (bundle with id==0) to shutdown the framework.

Tom.
Re: BundleInstall.begin throws exception [message #520598 is a reply to message #520466] Sat, 13 March 2010 01:51 Go to previous message
Suraj  is currently offline Suraj Friend
Messages: 16
Registered: November 2009
Location: Bangalore
Junior Member
I knew about the clean property, but never thought the problem could be so trivial. The property was burried in deep in some god-forsaken configuration file. After removing thid property it does remeber installed bundles.


The original problem remains though. But I think it won't be a equinox problem, but an encoding related issue.

Thanks Tom.
Previous Topic:OSGi services within Ant task
Next Topic:Enforcing arbitrary bundle requirements
Goto Forum:
  


Current Time: Fri Apr 26 17:27:41 GMT 2024

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

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

Back to the top