Karaf
  1. Karaf
  2. KARAF-1617

Blueprint deployer in combination with maven URL deployer creates wrong OSGi/blueprint/ file

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.8
    • Fix Version/s: 2.2.9, 2.3.0, 3.0.0
    • Component/s: karaf-core
    • Labels:
    • Environment:

      Karaf 2.2.8

      • org/apache/karaf/deployer/org.apache.karaf.deployer.blueprint/2.2.8
      • org/apache/aries/blueprint/org.apache.aries.blueprint/0.3.2

      Description

      We are using the Aries JNDI service for providing database-datasources via JNDI.

      The datasource definition is a blueprint-XML file like this one and is located in our Maven repository.

      I try to install the datasource definition like:

      bundle:install -s blueprint:mvn:my.product.database/my.product.database.layer//xml/datasource-hsqldb

      or via Kara feature:

      feature:install datasource-hsqldb

      features.xml
      [...]
      
        <feature name="datasource-hsqldb" version="${project.version}" resolver="(obr)">
          <feature>hsqldb</feature>
          <bundle >blueprint:mvn:my.product.database/my.product.database.layer/${project.version}/xml/datasource-hsqldb</bundle>
        </feature>
      
      [...]
      

      The bundle will be installed but the blueprint service was not created.

      The blueprint deployer creates a bundle-JAR file and including a new ZipEntry as blueprint service descriptor into OSGi/blueprint/.

      org.apache.karaf.deployer.blueprint.BlueprintTransformer.transform(URL, OutputStream)
      [...]
      
              String name = url.getPath();
              int idx = name.lastIndexOf('/');
              if (idx >= 0) {
                  name = name.substring(idx + 1);
              }
      
      [...]
      
              e = new ZipEntry("OSGI-INF/blueprint/" + name);
              out.putNextEntry(e);
              // Copy the new DOM
              if (tf == null) {
                  tf = TransformerFactory.newInstance();
              }
              tf.newTransformer().transform(new DOMSource(doc), new StreamResult(out));
              out.closeEntry();
      
      [...]
      

      Based on the mvn: URL the name of the blueprint descriptor file is datasource-hsqldb (w/o the .xml extension).

      The blueprint service needs the .xml file extension.

      org.apache.aries.blueprint.container.BlueprintExtender.checkBundle(Bundle)
      [...]
                 addEntries(bundle, name, "*.xml", pathList);
      [...]
      

        Activity

        Uwe Barthel created issue -
        Uwe Barthel made changes -
        Field Original Value New Value
        Description We are using the Aries JNDI service for providing database-datasources via JNDI.

        The datasource definition is a blueprint-XML file like [this one|https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-derby.xml] and is located in our Maven repository.

        I try to install the datasource definition like:

        {quote}
        bundle:install -s blueprint:mvn:my.product.database/my.product.database.layer//xml/datasource-hsqldb
        {quote}

        The bundle will be installed but the blueprint service was not created.

        The blueprint deployer creates a bundle-JAR file and including a new ZipEntry as blueprint service descriptor into {{OSGi/blueprint/}}.


        {code:title=org.apache.karaf.deployer.blueprint.BlueprintTransformer.transform(URL, OutputStream)}
        [...]

                String name = url.getPath();
                int idx = name.lastIndexOf('/');
                if (idx >= 0) {
                    name = name.substring(idx + 1);
                }

        [...]

                e = new ZipEntry("OSGI-INF/blueprint/" + name);
                out.putNextEntry(e);
                // Copy the new DOM
                if (tf == null) {
                    tf = TransformerFactory.newInstance();
                }
                tf.newTransformer().transform(new DOMSource(doc), new StreamResult(out));
                out.closeEntry();

        [...]
        {code}

        Based on the {{mvn:}} URL the name of the blueprint descriptor file is {{datasource-hsqldb}} (w/o the {{.xml}} extension).

        The blueprint service needs the {{.xml}} file extension.

        {code:title=org.apache.aries.blueprint.container.BlueprintExtender.checkBundle(Bundle)}
        [...]
                   addEntries(bundle, name, "*.xml", pathList);
        [...]
        {code}
        We are using the Aries JNDI service for providing database-datasources via JNDI.

        The datasource definition is a blueprint-XML file like [this one|https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-derby.xml] and is located in our Maven repository.

        I try to install the datasource definition like:

        {quote}
        bundle:install -s blueprint:mvn:my.product.database/my.product.database.layer//xml/datasource-hsqldb
        {quote}

        or via Kara feature:

        {quote}
        feature:install datasource-hsqldb
        {quote}

        {code:title=features.xml}
        [...]

          <feature name="datasource-hsqldb" version="${project.version}" resolver="(obr)">
            <feature>hsqldb</feature>
            <bundle >blueprint:mvn:my.product.database/my.product.database.layer/${project.version}/xml/datasource-hsqldb</bundle>
          </feature>

        [...]
        {code}

        The bundle will be installed but the blueprint service was not created.

        The blueprint deployer creates a bundle-JAR file and including a new ZipEntry as blueprint service descriptor into {{OSGi/blueprint/}}.


        {code:title=org.apache.karaf.deployer.blueprint.BlueprintTransformer.transform(URL, OutputStream)}
        [...]

                String name = url.getPath();
                int idx = name.lastIndexOf('/');
                if (idx >= 0) {
                    name = name.substring(idx + 1);
                }

        [...]

                e = new ZipEntry("OSGI-INF/blueprint/" + name);
                out.putNextEntry(e);
                // Copy the new DOM
                if (tf == null) {
                    tf = TransformerFactory.newInstance();
                }
                tf.newTransformer().transform(new DOMSource(doc), new StreamResult(out));
                out.closeEntry();

        [...]
        {code}

        Based on the {{mvn:}} URL the name of the blueprint descriptor file is {{datasource-hsqldb}} (w/o the {{.xml}} extension).

        The blueprint service needs the {{.xml}} file extension.

        {code:title=org.apache.aries.blueprint.container.BlueprintExtender.checkBundle(Bundle)}
        [...]
                   addEntries(bundle, name, "*.xml", pathList);
        [...]
        {code}
        Freeman Fang made changes -
        Assignee Freeman Fang [ ffang ]
        Uwe Barthel made changes -
        Attachment patch_karaf_1617.txt [ 12535578 ]
        Uwe Barthel made changes -
        Labels newbie newbie patch
        Freeman Fang made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Freeman Fang made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Fix Version/s 2.2.9 [ 12321741 ]
        Fix Version/s 2.3.0 [ 12320554 ]
        Fix Version/s 3.0.0 [ 12316040 ]
        Resolution Fixed [ 1 ]
        Uwe Barthel made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Freeman Fang
            Reporter:
            Uwe Barthel
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development