You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by thully <tm...@eng.ucsd.edu> on 2015/04/02 04:43:24 UTC

Capturing bundle load errors...

Hi,

Our project (Cytoscape) utilizes Karaf 3 as its framework for OSGi bundle
management. In our application, end users are able to install bundles -
either from our App Store or from disk. These bundles are stored in a
subdirectory of the user's home that is managed by Felix FileInstall.

Anyway, I was wondering if there is any way to capture bundle load errors
programmatically so that our application can respond to them (i.e. by
displaying an error message, offering the user the choice to uninstall the
bundle, etc etc). It seems that since FileInstall starts the bundles, there
is no way to capture these aside from scraping the log. 

Would it be a better approach to simply not use FileInstall at all and
manage our own local bundles? If that might be a good approach, how can we
change its settings such that it won't scan for JAR files?



--
View this message in context: http://karaf.922171.n3.nabble.com/Capturing-bundle-load-errors-tp4039419.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Capturing bundle load errors...

Posted by thully <tm...@eng.ucsd.edu>.
Simply installing the bundle directly and catching errors is what I was
thinking of doing. If I did that, what would be the best way to disable
FileInstall from scanning for JARs entirely? 

As for implementing a feature - what would that entail? Making each JAR a
feature isn't an option - we don't control all the JARs built for Cytoscape
ourselves. The ArtifactTransformer sounds like it may be promising (and
perhaps simpler than loading everything ourselves) - does someone have an
example of this? FileInstall doesn't provide much in the way of
documentation...



--
View this message in context: http://karaf.922171.n3.nabble.com/Capturing-bundle-load-errors-tp4039419p4039434.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Capturing bundle load errors...

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

why not providing a feature and implementing a FeatureListener to catch 
the error ?

You can also implement a FileInstall Artifact Transformer to deal with 
bundle installation and so catch the errors.

Regards
JB

On 04/02/2015 04:43 AM, thully wrote:
> Hi,
>
> Our project (Cytoscape) utilizes Karaf 3 as its framework for OSGi bundle
> management. In our application, end users are able to install bundles -
> either from our App Store or from disk. These bundles are stored in a
> subdirectory of the user's home that is managed by Felix FileInstall.
>
> Anyway, I was wondering if there is any way to capture bundle load errors
> programmatically so that our application can respond to them (i.e. by
> displaying an error message, offering the user the choice to uninstall the
> bundle, etc etc). It seems that since FileInstall starts the bundles, there
> is no way to capture these aside from scraping the log.
>
> Would it be a better approach to simply not use FileInstall at all and
> manage our own local bundles? If that might be a good approach, how can we
> change its settings such that it won't scan for JAR files?
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Capturing-bundle-load-errors-tp4039419.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Capturing bundle load errors...

Posted by Łukasz Dywicki <lu...@code-house.org>.
Hey Tmhull,
There are two stages of installation which are covered by fileinstall - first one is bringing bundle to system, second starting it up. You can manage to do such thing via BundleContext instance. Code is not hard since all necessary functionalities are delivered by OSGi framework out of the box.

String url = "file:/opt/repository/bundle-1.0.jar";
try {
    Bundle bundle = bundleContext.install(url);

    try {
    	bundle.start();
    } catch (BundleException e) {
    	// bundle could not be started due to:
	 	// {@link BundleException#NATIVECODE_ERROR},
	 	// {@link BundleException#RESOLVE_ERROR},
	 	// {@link BundleException#STATECHANGE_ERROR}, and
		// {@link BundleException#ACTIVATOR_ERROR}.
	} catch (IllegalStateException e) {
		// bundle is uninstalled OR bundle tries to update itself
	} catch (SecurityException e)
		// no privileges to run
    }
} catch (BundleException e) {
	// unable to install bundle due one of these reasons:
	// {@link BundleException#READ_ERROR}
	// {@link BundleException#DUPLICATE_BUNDLE_ERROR},
	// {@link BundleException#MANIFEST_ERROR}, and
	// {@link BundleException#REJECTED_BY_HOOK}
} catch (IllegalStateException e) {
	// called bundle context is invalid
} catch (SecurityException e) {
	// no privileges to install 
}

I don’t know details of your system, however most of cases are
a) bundle installation location is invalid
b) resolving bundle dependencies fails

Kind regards,
Lukasz,
—
luke@code-house.org
Twitter: ldywicki
Blog: http://dywicki.pl
Code-House - http://code-house.org

> Wiadomość napisana przez thully <tm...@eng.ucsd.edu> w dniu 2 kwi 2015, o godz. 04:43:
> 
> Hi,
> 
> Our project (Cytoscape) utilizes Karaf 3 as its framework for OSGi bundle
> management. In our application, end users are able to install bundles -
> either from our App Store or from disk. These bundles are stored in a
> subdirectory of the user's home that is managed by Felix FileInstall.
> 
> Anyway, I was wondering if there is any way to capture bundle load errors
> programmatically so that our application can respond to them (i.e. by
> displaying an error message, offering the user the choice to uninstall the
> bundle, etc etc). It seems that since FileInstall starts the bundles, there
> is no way to capture these aside from scraping the log. 
> 
> Would it be a better approach to simply not use FileInstall at all and
> manage our own local bundles? If that might be a good approach, how can we
> change its settings such that it won't scan for JAR files?
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Capturing-bundle-load-errors-tp4039419.html
> Sent from the Karaf - User mailing list archive at Nabble.com.