Tom Rutchik created FELIX-5946:
----------------------------------
Summary: Felix Version Number is 0.0.0
Key: FELIX-5946
URL: https://issues.apache.org/jira/browse/FELIX-5946
Project: Felix
Issue Type: Bug
Components: Framework
Reporter: Tom Rutchik
The framework reports Felix Version as 0.0.0
I've track the issue down and here's the problem:
File Felix.java - original code
{color:#000080}private static {color}String getFrameworkVersion()
{
{color:#808080}// The framework version property.
{color} Properties props = {color:#000080}new {color}Properties();
InputStream in =
Felix.{color:#000080}class{color}.getResourceAsStream({color:#008000}"Felix.properties"{color});
------------------
Here's the change needed to make it work
{color:#000080}private static {color}{color:#333333}String
getFrameworkVersion(){color}
{color:#333333}{{color}
{color:#808080}// The framework version property.
{color}{color:#333333} Properties props = {color}{color:#000080}new
{color}{color:#333333}Properties();{color}
{color:#333333} InputStream in =
Felix.{color}{color:#000080}class{color}{color:#333333}.getClassLoader().getResourceAsStream({color}{color:#008000}"Felix.properties"{color}{color:#333333});{color}
{color:#333333}alternative:{color}
{color:#333333}InputStream in =
Felix.{color:#000080}class{color}.getResourceAsStream({color:#008000}"/Felix.properties"{color});{color}
{color:#333333}----------------------------{color}
Then add the Felix.properties resource to the root of the framework jar. Its
content should contain:
{color:#000080}felix.version {color}= {color:#008000}6.0.1{color}
where 6.0.1 is replaced with the actual felix version.
{color:#333333}The problem is that getResourceAsStream(resource) is relative
the location of the class if the resource does not start with a leading "/" .
You could also resolve the problem by putting the "Felix.properties" file in
the same directory as the Felix, but that seems like a strange place to locate
it.{color}
{color:#333333}I looked for solution where the version number was obtained from
the Bundle-Version in the "MANIFEST.MF", but this information is not available
when Felix is embedded in the application. In an android environment, you
can't add the "Felix.properties" file at runtime due to file access
permissions. You also can't solve the problem by adding a "felix.version"
property to the config used to initialize the framework, it get's overwritten
with a 0.0.0 version if the "Felix.properties" file does not exist.{color}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)