Sandro Boehme created SLING-4117:
------------------------------------

             Summary: 'mountByFS=true' doesn't work a second time
                 Key: SLING-4117
                 URL: https://issues.apache.org/jira/browse/SLING-4117
             Project: Sling
          Issue Type: Bug
          Components: Maven Plugins and Archetypes
    Affects Versions: Maven Sling Plugin 2.1.0
            Reporter: Sandro Boehme


When calling 2.1.1-SNAPSHOT of the maven-sling-plugin with 'mountByFS=true' a 
second time the following exception is thrown and the build fails:
{code}
org.apache.sling.commons.json.JSONException: JSONObject["provider.file"] not 
found.
        at org.apache.sling.commons.json.JSONObject.get(JSONObject.java:372)
        at 
org.apache.sling.commons.json.JSONObject.getJSONObject(JSONObject.java:466)
        at 
org.apache.sling.maven.bundlesupport.AbstractBundleInstallMojo.getCurrentFileProviderConfigs(AbstractBundleInstallMojo.java:544)
        at 
org.apache.sling.maven.bundlesupport.AbstractBundleInstallMojo.configure(AbstractBundleInstallMojo.java:367)
        at 
org.apache.sling.maven.bundlesupport.AbstractBundleInstallMojo.execute(AbstractBundleInstallMojo.java:222)
        at 
org.apache.sling.maven.bundlesupport.BundleInstallMojo.execute(BundleInstallMojo.java:58)
        
[ERROR] Failed to execute goal 
org.apache.sling:maven-sling-plugin:2.1.1-SNAPSHOT:install (install-bundle) on 
project resource-editor: Reading configuration from 
http://localhost:8080/system/console/configMgr/(service.factoryPid=org.apache.sling.fsprovider.internal.FsResourceProvider).json
 failed, cause: JSONObject["provider.file"] not found.
{code}
As the error message suggest in 
org.apache.sling.maven.bundlesupport.AbstractBundleInstallMojo.getCurrentFileProviderConfigs()
 line 544 the call to the 'provider.file' key of the JSON structure fails 
because it is not directly accessible but nested in a 'properties' element. The 
patch first reads the 'properties' element and only then the 'provider.file' 
and the 'provider.roots' elements to fix the error.

As the method name says this code is for loading the current file provider 
configs. This is why it is not called when the maven-sling-plugin is called 
with the 'mountByFS=true' parameter the first time when there is no config / 
JSON result yet.

Looking at the history of the AbstractBundleInstallMojo and 
org.apache.felix.webconsole.internal.configuration.MetaTypeServiceSupport 
(generates the "properties" part of the JSON at the server side) the nesting in 
the "properties" element seem to have always been that way. Thats why I'm 
wondering why this seem to have never worked. Either people didn't care enough 
to get the mount call working a second time or I do something wrong and miss 
some basic information.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to