I am trying to add global settings for my plugin.  I think I have the form 
jelly correct, as the form loads.  When I fill out data in the global 
settings and try to save, I get the following error:

javax.servlet.ServletException: net.sf.json.JSONException: 
JSONObject["consulHostUrl"] not found.


The configure method is here:

        @Override
        public boolean configure(StaplerRequest req, JSONObject formData) 
throws FormException {
            LOGGER.warning(formData.toString());

            consulHostUrl = formData.getString("consulHostUrl");  //errors 
here

            req.bindJSON(this, formData);
            save();
            return super.configure(req, formData);
        }


And, before the error, I log the formData object, and I see:

{"consul-kv-builder":{"consulHostUrl":"http://localhost:8500","consulAclToken":"","consulApiUri":"","consulTimeoutConnection":"","consulTimeoutResponse":"","consulTestUri":"","consulTestResponseCode":""}}

The global.jelly is:

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" 
xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" 
xmlns:f="/lib/form">
<f:section title="Global Consul Settings" name="consul-kv-builder">
    <f:entry title="Host URL" help="help-hostUrl.html">
        <f:textbox field="consulHostUrl" name="consulHostUrl" />
    </f:entry>
    <f:entry title="ACL Token" help="help-token.html">
        <f:textbox field="consulAclToken" name="consulAclToken" value="" />
    </f:entry>
    <f:entry title="API URI (/v1/kv/)" help="help-urlOverride.html">
        <f:textbox field="consulApiUri" name="consulApiUri" />
    </f:entry>
    <f:entry title="Connection Timeout (10000)" 
help="help-timeoutConnection.html">
        <f:textbox field="consulTimeoutConnection" 
name="consulTimeoutConnection" />
    </f:entry>
    <f:entry title="Response Timeout (30000)" 
help="help-timeoutResponse.html">
        <f:textbox field="consulTimeoutResponse" 
name="consulTimeoutResponse" />
    </f:entry>
    <f:entry title="Test URI (/status/leader)" help="help-testUri.html">
        <f:textbox field="consulTestUri" name="consulTestUri" />
    </f:entry>
    <f:entry title="Test Response Code (200)" 
help="help-testResponseCode.html">
        <f:textbox field="consulTestResponseCode" 
name="consulTestResponseCode" />
    </f:entry>
    <f:validateButton
        title="${%Test Connection}" progress="${%Testing...}"
        method="testConnection" 
with="consulHostUrl,consulTestUri,consulTestResponseCode" />
  </f:section>
</j:jelly>

And the *Test Connection* works as well.

I know I am doing something stupid, but I just haven't stumbled on it yet.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/592cb495-4239-49a6-9e35-9f09c0f8a521%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to