Uploaded image for project: 'Karaf'
  1. Karaf
  2. KARAF-6612

Get NPE in FeatureDeploymentListener.bundleChanged()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 4.2.1, 4.2.8
    • None
    • karaf
    • Tested on Windows

    Description

      I'm trying to run a standard distribution with all features defined as startup.   When I do this the karaf instance starts but logs a number of errors:

       2020-01-30T21:36:36,333 | ERROR | activator-1-thread-2 | FeatureDeploymentListener        | 27 - org.apache.karaf.deployer.features - 4.2.8 | Unable to update deployed features for bundle: org.apache.karaf.features.extension - 4.2.8
      java.lang.NullPointerException: null
      	at org.apache.karaf.deployer.features.FeatureDeploymentListener.bundleChanged(FeatureDeploymentListener.java:247) [!/:?]
      	at org.apache.karaf.deployer.features.FeatureDeploymentListener.init(FeatureDeploymentListener.java:95) [!/:?]
      	at org.apache.karaf.deployer.features.osgi.Activator$DeploymentFinishedListener.deploymentEvent(Activator.java:86) [!/:?]
      	at org.apache.karaf.features.internal.service.FeaturesServiceImpl.registerListener(FeaturesServiceImpl.java:295) [!/:?]
      	at org.apache.karaf.deployer.features.osgi.Activator.doStart(Activator.java:53) [!/:?]
      	at org.apache.karaf.util.tracker.BaseActivator.run(BaseActivator.java:312) [!/:?]
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_222]
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
      	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

       

      I'm using the following pom.xml

       

       <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>    <groupId>com.bobpaulin.karaf.startup</groupId>
          <artifactId>karaf-startup-standard</artifactId>
          <version>0.0.1-SNAPSHOT</version>
          <packaging>karaf-assembly</packaging>
          <name>Startup Standard Distribution</name>
          
          <properties>
              <karaf.version>4.2.8</karaf.version>
          </properties>
          
           <!-- Import Karaf POM to use the correct version of the Karaf dependencies -->
          <dependencyManagement>
          <dependencies>
                  <dependency>
                      <groupId>org.apache.karaf</groupId>
                      <artifactId>karaf</artifactId>
                      <version>${karaf.version}</version>
                      <type>pom</type>
                      <scope>import</scope>
                  </dependency>
              </dependencies>
          </dependencyManagement>    <dependencies>
              <dependency>
              <!-- scope is compile so all features (there is only one) are installed into startup.properties and the feature repo itself is not added in etc/org.apache.karaf.features.cfg file -->
                  <groupId>org.apache.karaf.features</groupId>
                  <artifactId>framework</artifactId>
                  <version>${karaf.version}</version>
                  <type>kar</type>
              </dependency>
              <dependency>
                  <groupId>org.apache.karaf.features</groupId>
                  <artifactId>framework</artifactId>
                  <classifier>features</classifier>
                  <version>${karaf.version}</version>
                  <type>xml</type>
              </dependency>
              
              <dependency>
                  <groupId>org.apache.karaf.features</groupId>
                  <artifactId>enterprise</artifactId>
                  <classifier>features</classifier>
                  <type>xml</type>
                  <version>${karaf.version}</version>
              </dependency>
              <dependency>
                  <groupId>org.apache.karaf.features</groupId>
                  <artifactId>spring</artifactId>
                  <version>${karaf.version}</version>
                  <classifier>features</classifier>
                  <type>xml</type>
              </dependency>
              <dependency>
              <!-- scope is runtime so the feature repo is listed in etc/org.apache.karaf.features.cfg file, and features will installed into the system directory -->
                  <groupId>org.apache.karaf.features</groupId>
                  <artifactId>standard</artifactId>
                  <classifier>features</classifier>
                  <version>${karaf.version}</version>
                  <type>xml</type>
              </dependency>
          </dependencies>    <build>
              <!-- if you want to include resources in the distribution -->
              <resources>
                  <resource>
                      <directory>src/main/resources</directory>
                      <filtering>false</filtering>
                      <includes>
                          <include>**/*</include>
                      </includes>
                  </resource>
                  <resource>
                      <directory>src/main/filtered-resources</directory>
                      <filtering>true</filtering>
                      <includes>
                          <include>**/*</include>
                      </includes>
                  </resource>
              </resources>        <plugins>
                  <!-- if you want to include resources in the distribution -->
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-resources-plugin</artifactId>
                      <version>3.0.2</version>
                      <executions>
                          <execution>
                              <id>process-resources</id>
                              <goals>
                                  <goal>resources</goal>
                              </goals>
                          </execution>
                      </executions>
                  </plugin>
                  <!-- karaf-maven-plugin will call both assembly and archive goals -->
                  <plugin>
                      <groupId>org.apache.karaf.tooling</groupId>
                      <artifactId>karaf-maven-plugin</artifactId>
                      <version>${karaf.version}</version>
                      <extensions>true</extensions>
                      <configuration>
                          <startupFeatures>
                          	<startupFeature>standard</startupFeature>
                              <startupFeature>eventadmin</startupFeature>
                          </startupFeatures>
                          <javase>1.8</javase>
                      </configuration>
                  </plugin>
              </plugins>
          </build>
      </project>
      

       

      Some debugging shows the in the FeatureDeploymentListener the featuresService.listRequirements() is returning an empty map so the call to requirements.get(ROOT_REGION) is returning null before the next call to removeAll

      Map<String, Set<String>> requirements =
      featuresService.listRequirements();
      requirements.get(ROOT_REGION).removeAll(reqsToRemove);
      requirements.get(ROOT_REGION).addAll(reqsToAdd); 

       

      Not sure if we just need a simple null check here or if I'm doing something not supported.  Thanks!

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            bob Bob Paulin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: