FUSE ESB
  1. FUSE ESB
  2. ESB-1197

The "org.osgi.service.http.port" in "etc\system.properties" is ignored

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Critical Critical
    • Resolution: Done
    • Affects Version/s: 4.2.0-fuse-01-00
    • Component/s: None
    • Labels:
      None
    • Similar Issues:
      Show 10 results 

      Description

      The "org.osgi.service.http.port" in "etc\system.properties" is ignored. It does not have any effect at all. There is one way to change Pax Web HTTP port by creating a "etc\org.ops4j.pax.web.cfg" file and configure "org.osgi.service.http.port" in the new file like:

      org.osgi.service.http.port=8080
      

      However, It only works the second time when we start Fuse ESB. The Pax Web Http listening port is aways on default 8181 in the first time when I start Fuse ESB even with the new file "etc\org.ops4j.pax.web.cfg" created.

      Here is instruction to reproduce the behaviour:
      1. Extract the FUSE ESB 4.2 zip file into a new location;
      2. create a "etc\org.ops4j.pax.web.cfg" file and add following line:

      org.osgi.service.http.port=8080
      

      3. start the Fuse ESB by "bin\karaf".

      You will see that the http port is still on default 8181. If you restart the Fuse ESB, the http port will change to 8080 that is configured in "etc\org.ops4j.pax.web.cfg".

      Here is Felix Karaf features.xml file for "http" feature:

      <feature name="http" version="1.4.0-fuse-01-00">
      <config name="org.ops4j.pax.web">
      org.osgi.service.http.port=8181
      </config>
      <bundle>mvn:org.apache.geronimo.specs/geronimo-servlet_2.5_spec/1.1.2</bundle>
      <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jetty-bundle/6.1.22_1</bundle>
      <bundle>mvn:org.ops4j.pax.web/pax-web-api/0.7.2</bundle>
      <bundle>mvn:org.ops4j.pax.web/pax-web-spi/0.7.2</bundle>
      <bundle>mvn:org.ops4j.pax.web/pax-web-runtime/0.7.2</bundle>
      <bundle>mvn:org.ops4j.pax.web/pax-web-jetty/0.7.2</bundle>
      </feature>
      

      It looks like hard coded "org.osgi.service.http.port=8181" in Felix Karaf somehow overwrite configuration from "etc\xxx" when it is deployed. Only restart of Fuse ESB will make the configuration from "etc\xxx" works.

      Here is a suggested fix:
      1. remove two lines from "etc\system.properties" file as the port configuration in this file does not make any difference:

      # Default port for the OSGI HTTP Service
      org.osgi.service.http.port=8181
      

      This step is optional but it would reduce confusion caused to users.

      2. create a new "etc\org.ops4j.pax.web.cfg" file and add two lines in this file:

      # Default port for the OSGI HTTP Service
      org.osgi.service.http.port=8181
      

      3. remove hard coded port configuration from the apache-felix-karaf-1.4.0-fuse-01-00-features.xml:

      <feature name="http" version="1.4.0-fuse-01-00">
      <bundle>mvn:org.apache.geronimo.specs/geronimo-servlet_2.5_spec/1.1.2</bundle>
      <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jetty-bundle/6.1.22_1</bundle>
      <bundle>mvn:org.ops4j.pax.web/pax-web-api/0.7.2</bundle>
      <bundle>mvn:org.ops4j.pax.web/pax-web-spi/0.7.2</bundle>
      <bundle>mvn:org.ops4j.pax.web/pax-web-runtime/0.7.2</bundle>
      <bundle>mvn:org.ops4j.pax.web/pax-web-jetty/0.7.2</bundle>
      </feature>
      

        Activity

        Hide
        Joe Luo
        added a comment -

        It should be documented in wiki as well.

        Show
        Joe Luo
        added a comment - It should be documented in wiki as well.
        Hide
        Guillaume Nodet
        added a comment -

        THe following patch should solve the issue. Could you give it a try ?

        diff --git a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java b/karaf/features/core/src/main
        index 9202d37..9e5d685 100644
        --- a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
        +++ b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
        @@ -375,13 +375,16 @@ public class FeaturesServiceImpl implements FeaturesService {
                 for (String config : feature.getConfigurations().keySet()) {
                     Dictionary<String,String> props = new Hashtable<String, String>(feature.getConfigurations().get(config));
                     String[] pid = parsePid(config);
        -            String key = (pid[1] == null ? pid[0] : pid[0] + "-" + pid[1]);
        -            props.put(CONFIG_KEY, key);
        -            Configuration cfg = getConfiguration(configAdmin, pid[0], pid[1]);
        -            if (cfg.getBundleLocation() != null) {
        -                cfg.setBundleLocation(null);
        +            Configuration cfg = findExistingConfiguration(configAdmin, pid[0], pid[1]);
        +            if (cfg == null) {
        +                cfg = createConfiguration(configAdmin, pid[0], pid[1]);
        +                String key = (pid[1] == null ? pid[0] : pid[0] + "-" + pid[1]);
        +                props.put(CONFIG_KEY, key);
        +                if (cfg.getBundleLocation() != null) {
        +                    cfg.setBundleLocation(null);
        +                }
        +                cfg.update(props);
                     }
        -            cfg.update(props);
                 }
                 Set<Long> bundles = new HashSet<Long>();
                 for (String bundleLocation : feature.getBundles()) {
        @@ -703,17 +706,12 @@ public class FeaturesServiceImpl implements FeaturesService {
                 }
             }
         
        -    protected Configuration getConfiguration(ConfigurationAdmin configurationAdmin,
        -                                             String pid, String factoryPid) throws IOException, InvalidSyntaxException {
        -        Configuration oldConfiguration = findExistingConfiguration(configurationAdmin, pid, factoryPid);
        -        if (oldConfiguration != null) {
        -            return oldConfiguration;
        +    protected Configuration createConfiguration(ConfigurationAdmin configurationAdmin,
        +                                                String pid, String factoryPid) throws IOException, InvalidSyntaxException {
        +        if (factoryPid != null) {
        +            return configurationAdmin.createFactoryConfiguration(pid, null);
                 } else {
        -            if (factoryPid != null) {
        -                return configurationAdmin.createFactoryConfiguration(pid, null);
        -            } else {
        -                return configurationAdmin.getConfiguration(pid, null);
        -            }
        +            return configurationAdmin.getConfiguration(pid, null);
                 }
             }
        
        Show
        Guillaume Nodet
        added a comment - THe following patch should solve the issue. Could you give it a try ? diff --git a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java b/karaf/features/core/src/main index 9202d37..9e5d685 100644 --- a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java +++ b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java @@ -375,13 +375,16 @@ public class FeaturesServiceImpl implements FeaturesService { for ( String config : feature.getConfigurations().keySet()) { Dictionary< String , String > props = new Hashtable< String , String >(feature.getConfigurations().get(config)); String [] pid = parsePid(config); - String key = (pid[1] == null ? pid[0] : pid[0] + "-" + pid[1]); - props.put(CONFIG_KEY, key); - Configuration cfg = getConfiguration(configAdmin, pid[0], pid[1]); - if (cfg.getBundleLocation() != null ) { - cfg.setBundleLocation( null ); + Configuration cfg = findExistingConfiguration(configAdmin, pid[0], pid[1]); + if (cfg == null ) { + cfg = createConfiguration(configAdmin, pid[0], pid[1]); + String key = (pid[1] == null ? pid[0] : pid[0] + "-" + pid[1]); + props.put(CONFIG_KEY, key); + if (cfg.getBundleLocation() != null ) { + cfg.setBundleLocation( null ); + } + cfg.update(props); } - cfg.update(props); } Set< Long > bundles = new HashSet< Long >(); for ( String bundleLocation : feature.getBundles()) { @@ -703,17 +706,12 @@ public class FeaturesServiceImpl implements FeaturesService { } } - protected Configuration getConfiguration(ConfigurationAdmin configurationAdmin, - String pid, String factoryPid) throws IOException, InvalidSyntaxException { - Configuration oldConfiguration = findExistingConfiguration(configurationAdmin, pid, factoryPid); - if (oldConfiguration != null ) { - return oldConfiguration; + protected Configuration createConfiguration(ConfigurationAdmin configurationAdmin, + String pid, String factoryPid) throws IOException, InvalidSyntaxException { + if (factoryPid != null ) { + return configurationAdmin.createFactoryConfiguration(pid, null ); } else { - if (factoryPid != null ) { - return configurationAdmin.createFactoryConfiguration(pid, null ); - } else { - return configurationAdmin.getConfiguration(pid, null ); - } + return configurationAdmin.getConfiguration(pid, null ); } }
        Hide
        Joe Luo
        added a comment -

        Unfortunately, it still does not work with the patch.

        Show
        Joe Luo
        added a comment - Unfortunately, it still does not work with the patch.
        Hide
        Joe Luo
        added a comment -

        Tested on latest Apache Karaf trunk and it works fine. Also built a patched org.apache.felix.karaf.features.core-1.4.0-fuse-01-00.jar and placed it in Fuse ESB 4.2.0-fuse-01-00 "system\..." repository. It works fine too after a clean start.

        With the fix, a new "etc\org.ops4j.pax.web.cfg" file needs to be created with "org.osgi.service.http.port" configure:

        # Default port for the OSGI HTTP Service
        org.osgi.service.http.port=8080
        

        in order to make it work.

        Show
        Joe Luo
        added a comment - Tested on latest Apache Karaf trunk and it works fine. Also built a patched org.apache.felix.karaf.features.core-1.4.0-fuse-01-00.jar and placed it in Fuse ESB 4.2.0-fuse-01-00 "system\..." repository. It works fine too after a clean start. With the fix, a new "etc\org.ops4j.pax.web.cfg" file needs to be created with "org.osgi.service.http.port" configure: # Default port for the OSGI HTTP Service org.osgi.service.http.port=8080 in order to make it work.
        Hide
        Chris Custine
        added a comment -

        Reopening to change fix version.

        Show
        Chris Custine
        added a comment - Reopening to change fix version.

          People

          • Assignee:
            Guillaume Nodet
            Reporter:
            Joe Luo
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: