Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-8605

NullPointerExceptions NPEs when starting Magnolia 6.3 in development mode

XMLWordPrintable

      Steps to reproduce

      1. Navigate to magnolia-6.3-SNAPSHOT\apache-tomcat-9.0.64\bin and run with magnolia_control.bat start
      2. In http://localhost:8080/ install required packages
      3. After everything is installed and Magnolia started, close it
      4. Change property magnolia.develop from 'false' to 'true' in magnolia-6.3-SNAPSHOT\apache-tomcat-9.0.64\webapps\magnoliaAuthor\WEB-INF\config\default\magnolia.properties
      5. Run Magnolia again as described in step 1.

      Actual results

      ERROR info.magnolia.config.source.yaml.YamlConfigurationSource 02.11.2022 14:45:24 -- 1 severe problems have been encountered:
      ERROR info.magnolia.config.source.yaml.YamlConfigurationSource 02.11.2022 14:45:24 -- 
      Severity type:   SEVERE 
      Title:           /: [Definition resolution] - Parsing configuration data from [/ui-admincentral/fieldTypes/timeZone.yaml] failed 
      Problem details: Failed to parse YAML file:
      Null pointer
      java.lang.NullPointerException: null
      ERROR info.magnolia.config.source.yaml.YamlConfigurationSource 02.11.2022 14:45:24 -- 1 severe problems have been encountered:
      ERROR info.magnolia.config.source.yaml.YamlConfigurationSource 02.11.2022 14:45:24 -- 
      Severity type:   SEVERE 
      Title:           /: [Definition resolution] - Parsing configuration data from [/ui-framework/fieldTypes/basicUpload.yaml] failed 
      Problem details: Failed to parse YAML file:
      I o: Resource is already open -- cannot open it again without first calling close()
      java.io.IOException: Resource is already open -- cannot open it again without first calling close()
          at io.github.classgraph.ClasspathElementZip$1.open(ClasspathElementZip.java:386) ~[classgraph-4.8.149.jar:4.8.149]
          at info.magnolia.resourceloader.classpath.service.impl.devmode.DevelopmentModeClasspathFile.openStream(DevelopmentModeClasspathFile.java:80) ~[magnolia-resource-loader-6.3-SNAPSHOT.jar:?]
          at info.magnolia.resourceloader.classpath.ClasspathResourceOrigin.doOpenStream(ClasspathResourceOrigin.java:152) ~[magnolia-resource-loader-6.3-SNAPSHOT.jar:?]
          at info.magnolia.resourceloader.classpath.ClasspathResourceOrigin.doOpenStream(ClasspathResourceOrigin.java:67) ~[magnolia-resource-loader-6.3-SNAPSHOT.jar:?]
          at info.magnolia.resourceloader.AbstractResourceOrigin.openStream(AbstractResourceOrigin.java:190) ~[magnolia-resource-loader-6.3-SNAPSHOT.jar:?]
          at info.magnolia.resourceloader.AbstractResourceOrigin.openReader(AbstractResourceOrigin.java:203) ~[magnolia-resource-loader-6.3-SNAPSHOT.jar:?]
          at info.magnolia.resourceloader.AbstractResource.openReader(AbstractResource.java:109) ~[magnolia-resource-loader-6.3-SNAPSHOT.jar:?]
          at info.magnolia.resourceloader.layered.LayeredResourceOrigin.openReader(LayeredResourceOrigin.java:204) ~[magnolia-resource-loader-6.3-SNAPSHOT.jar:?]
          at info.magnolia.resourceloader.layered.LayeredResourceOrigin.openReader(LayeredResourceOrigin.java:72) ~[magnolia-resource-loader-6.3-SNAPSHOT.jar:?]
          at info.magnolia.resourceloader.AbstractResource.openReader(AbstractResource.java:109) ~[magnolia-resource-loader-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.source.yaml.YamlReader.doReadWithDependencies(YamlReader.java:119) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.source.yaml.YamlReader.readWithDependencies(YamlReader.java:100) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.source.yaml.YamlReader.readWithDependencies(YamlReader.java:96) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.source.yaml.YamlDefinitionProvider.getYamlConversionResult(YamlDefinitionProvider.java:85) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.source.yaml.AbstractYamlDefinitionProvider.resolve(AbstractYamlDefinitionProvider.java:198) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.source.yaml.AbstractYamlDefinitionProvider.getDelegate(AbstractYamlDefinitionProvider.java:133) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.registry.AbstractDefinitionProviderWrapper.getMetadata(AbstractDefinitionProviderWrapper.java:56) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.registry.RegistryMap.asStringKey(RegistryMap.java:184) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.registry.RegistryMap.put(RegistryMap.java:98) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.source.yaml.AbstractFileResourceConfigurationSource.register(AbstractFileResourceConfigurationSource.java:190) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.source.yaml.YamlConfigurationSource.loadAndRegister(YamlConfigurationSource.java:115) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.source.yaml.AbstractFileResourceConfigurationSource.lambda$start$2(AbstractFileResourceConfigurationSource.java:138) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          ...
          at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) ~[?:?]
          at info.magnolia.config.source.yaml.AbstractFileResourceConfigurationSource.start(AbstractFileResourceConfigurationSource.java:136) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at java.util.ArrayList.forEach(ArrayList.java:1541) ~[?:?]
          at info.magnolia.config.source.composite.CompositeConfigurationSource.start(CompositeConfigurationSource.java:77) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.source.decoration.DecoratingConfigurationSource.start(DecoratingConfigurationSource.java:87) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.source.decoration.YamlDecorationConfigurationSource.start(YamlDecorationConfigurationSource.java:112) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.config.source.ConfigurationSourceFactory$DefaultConfigSourcesBuilder.build(ConfigurationSourceFactory.java:245) ~[magnolia-configuration-6.3-SNAPSHOT.jar:?]
          at info.magnolia.ui.UiFrameworkJcrModule.lambda$start$1(UiFrameworkJcrModule.java:128) ~[magnolia-ui-framework-jcr-6.3-SNAPSHOT.jar:?]
          at java.util.Optional.ifPresent(Optional.java:183) ~[?:?]
          at info.magnolia.ui.UiFrameworkJcrModule.start(UiFrameworkJcrModule.java:122) ~[magnolia-ui-framework-jcr-6.3-SNAPSHOT.jar:?]
          ...
          at info.magnolia.init.MagnoliaServletContextListener.contextInitialized(MagnoliaServletContextListener.java:136) ~[magnolia-core-6.3-SNAPSHOT.jar:?]
          ...
      

      Development notes

      This is happening because start() method in AbstractFileResourceConfigurationSource is being called twice, from DecoratingConfigurationSource.start() and ConfigurationSourceFactory$DefaultConfigSourcesBuilder.build(). When in production mode (magnolia.develop=false) this does not cause issues because actual opening of yaml resources does not result in opening jars, they are read internally. When in development mode, yaml files are read with classgraph in ClasspathElementZip, on the second run of the start() method a different Resource instance is created for the same path/file so the isOpen() check is false in ClasspathElementZip -> newResource -> open() and the error appears when it starts reading the same file that has not been previously closed.

        Acceptance criteria

              mduerig Michael Duerig
              Jdev Janek Valgma
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved:
                Work Started: