cancel
Showing results for 
Search instead for 
Did you mean: 

4.2.c regression on custom constraint

scouil
Star Contributor
Star Contributor
I've developped a custom constraint extending the ListOfValuesConstraint.
It was running fine in 4.2.b and before but ends up giving me trouble in 4.2.c

The error happens when looking at the "Workflow Details" of a workflow containing a field based on that constraint.
I get a simple "Failure" popup and a log message including:

Caused by: java.lang.NullPointerException
        at org.alfresco.web.scripts.forms.FormUIGet.processFieldConstraintControl(FormUIGet.java:1956)


The problem seems to be that fieldConfig is null.
Previous version of the file didn't include this check using fieldConfig hence didn't trigger the bug.
The following changed the 7th of december in commit 44483 in the file org.alfresco.web.scripts.forms.FormUIGet.java by replacing

Collections.sort(optionsList, new OptionsComparator());

with

if (fieldConfig.isSorted())
{
    Collections.sort(optionsList, new OptionsComparator());
}


I don't really know what this fieldConfig corresponds to and if the spec marks it as mandatory (I tend to believe it's not since a check on it is made a few lines before) so I didn't report it on jira just yet.

PS: Removing the check altogether isn't an option since it would bring back this bug: https://issues.alfresco.com/jira/browse/ALF-16157
9 REPLIES 9

armino
Champ in-the-making
Champ in-the-making
Same problem here: https://forums.alfresco.com/forum/end-user-discussions/alfresco-share/redering-custom-model-broken-4....

It appears that 4.2.c cannot handle any reference to a custom constraint. My exception chain looks the same. Going back to 4.2.b instantly resolved the issue.

It is frustrating and immensely time consuming that such basic things dont work!!!

-Armin



nmcminn
Champ in-the-making
Champ in-the-making
The fieldConfig object referenced in line 1956 of FormUIGet.java appears to be populated by the form config in share-config-custom.xml.  I was running into the same NullPointerException at that line when rendering a custom action form.  What I did was add a very simple form section to share-config-custom.xml for that form, like so:


    <config evaluator="string-compare" condition="your_condition">
       <forms>
           <form>
                <appearance>
                    <field id="the_field_using_the_constraint"></field>
                </appearance>
            </form>
        </forms>
    </config>


It seems that just having the field defined in the form config is enough to make sure that the FormField object is not null, and the NPE goes away.

Hope it works for you

scouil
Star Contributor
Star Contributor
Hello Nathan,

Yes I came up with the same workaround,

I signaled it on another forum thred that was created on the same issue short after this one (http://forums.alfresco.com/comment/129477#comment-129477) but forgot to report it here as well.
Thanks for your input.

monocromo
Champ in-the-making
Champ in-the-making
Hi, i have the same problem with alfresco 4.2.c and ubuntu 12.04.2 LTS, when i want to edit the property (using share) of a file that use a custom-content with constraint list alfresco share show this error:

An error has occured in the Share component: /share/service/components/form.
It responded with a status of 500 - Internal Error.
Error Code Information: 500 - An error inside the HTTP server which prevented it from fulfilling the request.
Error Message: 03100006 Wrapped Exception (with status template): null
Server: Alfresco Spring WebScripts - v1.2.0 (Release 1207) schema 1.000
Time: 10-apr-2013 15.51.46
Click here to view full technical information on the error.
Exception: org.springframework.extensions.webscripts.WebScriptException - 03100006 Wrapped Exception (with status template): null
org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1067)


it's possible solve the problem?
The solution of nmcminn not work!

zorglub
Champ in-the-making
Champ in-the-making
Tried your workaround, and still have the NPE. I can't figure out what "your_condition" should be.

scouil
Star Contributor
Star Contributor
Hi,

The idea behind this workaround is that if you redefine the form fields explicitly, the NPE will disappear.
Please refer to http://wiki.alfresco.com/wiki/Forms to configure forms in share.

zorglub
Champ in-the-making
Champ in-the-making
Hi, thanks for your reply.
You mean that I should not rely on the automatic form generation and explicitly define a creation/modification form for custom type(s) relying on LIST constraint ?
I added
<code lang="xml">
   <config evaluator="string-compare" condition="your_condition">
      <forms>
         <form>
            <appearance>
               <field id="ag:documentNature"></field>
            </appearance>
         </form>
      </forms>
   </config>
</code>
in share-config-custom.xml and it doesn't correct the NPE.

scouil
Star Contributor
Star Contributor
Hi,

Yes. For this specific version of Alfresco, a bug forces you to redefine the form instead of relying on the automatic one when you have a custom list constraint.

I'd like to avoid giving you just the snippet of code because otherwise you'll just paste it and forget about it and it might cause you trouble with future customisation.
Basically the part that is wrong here is your first line where "your_condition" should obviously be replace by something that is specific to your actual model.
And actually, if you read the link I sent you, you'll more often see examples using
<config evaluator="node-type" condition="your_condition">


Good luck with your customisation.

I know I'm a little late to the party but I need to solve this for a 4.2.c that I'm working with unfortunately. I tried your fix using the following


    <config evaluator="string-compare" condition="activiti$activitiCreateEvenement">
        <forms>
            <form>
                <appearance>
                    <field id="wfevt:theme1" />
                    <field id="wfevt:theme2" />
                </appearance>
            </form>
        </forms>
    </config>


to no joy I'm afraid. I still get the null error. I hope to be able to solve this soon because it's eating my day.
Will post back if I do. In the mean time if anyone has any ideas, I'd be happy to receive them. I'm working in a 4.2.c maven build