Details
Description
Problem :
By default, the DirectoryWatcher of Felix scans for new files very early in the start process. If a new application bundle is added to the "deploy" directory, it might be detected and started while the framework start level is still at 30, although the application bundle start should be postponed until level 60 is reached.
If not, a typical problem will be that Camel-core is deployed after the application bundle, thereby not using the OSGi-aware CamelContext, causing some Camel components not to be found, with errors such as the following :
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: sql://SELECT 1 from DUAL?dataSourceRef=myDS due to: No component found with scheme: sql
A hint to the root cause of the problem can be found in the logs :
CamelNamespaceHandler | OSGi environment not detected.
By default, the property "felix.fileinstall.start.level" in file "org.apache.felix.fileinstall-deploy.cfg" is unconfigured, resulting in the default "0" level being used. Although this means that the new bundle's start level will be configured at level 60 (as configured in the "karaf.startlevel.bundle" property), another unwanted side effect is also observed : there is no wait in method "DirectoryWatcher:run()".
Solutions :
To avoid such race conditions between the starting of Camel-core bundle and an application bundle, it would be safer to explicitly configure the property "felix.fileinstall.start.level" to 60 in Felix 3.1.x, or property "felix.fileinstall.active.level" to 60 in Felix 3.2.x, or change the code of DirectoryWatcher to retrieve the default start level, in case it is unspecified in the properties.