dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38146
Re: TrackedEntityInstance update
Hi Morten
It seems this one is still an issue for me and I need to investigate
further what is going on.
Essentially, it seems that if I do the following:
1. Create TrackedEntityAttributes with OptionSets
2. Create TrackedEntityInstance and set attribute values
3. Update TrackedEntityAttributes with OptionSets
4. Update TrackedEntityInstance and update attribute values
I get the NullPointerException for
TrackedEntityAttribute.isValidOptionValue()
I can't see any difference in the TrackedEntityAttributes and OptionSets
before and after the update.
The TrackedEntityAttribute has 'lost' the association with the OptionSet
though.
Any suggestions of other entities that I can check might have been
incorrectly updated?
I guess what would be useful is for me to run DHIS2 from my IDE so I can
debug. Is this fairly easy to set up?
Many thanks
Alan
On Fri, Jun 19, 2015 at 8:04 AM, Alan Hill <ahill@xxxxxxxxxx> wrote:
> Thanks Morten
>
> I have completely wiped my DB and started from scratch with the latest
> build and all seems to OK now.
>
> Many thanks for your support.
>
> Alan
>
>
> On Fri, Jun 19, 2015 at 3:08 AM, Lars Helge Øverland <larshelge@xxxxxxxxx>
> wrote:
>
>> Hi Alan,
>>
>> while perhaps not fixing the real problem, I have fixed a nullpointer
>> vulnerability in that method now in trunk.
>>
>> Lars
>>
>>
>> On Fri, Jun 19, 2015 at 8:36 AM, Alan Hill <ahill@xxxxxxxxxx> wrote:
>>
>>> OK...will do.
>>>
>>> Thanks
>>>
>>> Alan
>>>
>>> On Thu, Jun 18, 2015 at 11:34 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx
>>> > wrote:
>>>
>>>> Hi
>>>>
>>>> I was not able to reproduce this locally. I created a simple TE with
>>>> two TEAs (name, gender), and I was able to both create and update these
>>>> without any issues. If I changed the gender to be an invalid gender, it
>>>> would complain back with invalid option for optionset.
>>>>
>>>> I think this is still related to your optionSet, could you please try
>>>> and create a new one through the UI, and a few options, and see if that
>>>> works?
>>>>
>>>> --
>>>> Morten
>>>>
>>>> On Fri, Jun 19, 2015 at 12:24 PM, Morten Olav Hansen <
>>>> mortenoh@xxxxxxxxx> wrote:
>>>>
>>>>> Hm, ok. I will need to look more into this then, from the stack trace
>>>>> is seems related to invalid code. I will try it out here locally and see if
>>>>> I an reproduce.
>>>>>
>>>>> --
>>>>> Morten
>>>>>
>>>>> On Fri, Jun 19, 2015 at 11:59 AM, Alan Hill <ahill@xxxxxxxxxx> wrote:
>>>>>
>>>>>> Hi again and thanks so much for getting back to me so quickly.
>>>>>>
>>>>>> I'm pretty confident that all of my options have codes as per the
>>>>>> option set JSON:
>>>>>>
>>>>>>
>>>>>> - options:
>>>>>> [
>>>>>> -
>>>>>> {
>>>>>> - id: "Fnkf3CXYjtU",
>>>>>> - name: "northern",
>>>>>> - code: "1",
>>>>>> - created: "2015-06-18T22:27:50.583+0000",
>>>>>> - lastUpdated: "2015-06-18T23:51:10.554+0000",
>>>>>> - href: "http://localhost:8000/api/options/Fnkf3CXYjtU"
>>>>>> },
>>>>>> -
>>>>>> {
>>>>>> - id: "p6xLuMAZ6Kx",
>>>>>> - name: "central",
>>>>>> - code: "2",
>>>>>> - created: "2015-06-18T22:27:50.720+0000",
>>>>>> - lastUpdated: "2015-06-18T23:51:10.675+0000",
>>>>>> - href: "http://localhost:8000/api/options/p6xLuMAZ6Kx"
>>>>>> },
>>>>>> -
>>>>>> {
>>>>>> - id: "XJa5QiUzKgb",
>>>>>> - name: "southern",
>>>>>> - code: "3",
>>>>>> - created: "2015-06-18T22:27:50.910+0000",
>>>>>> - lastUpdated: "2015-06-18T23:51:10.803+0000",
>>>>>> - href: "http://localhost:8000/api/options/XJa5QiUzKgb"
>>>>>> }
>>>>>> ]
>>>>>>
>>>>>>
>>>>>> The value I'm setting is "3" which there is definitely an option for.
>>>>>>
>>>>>> Cheers
>>>>>>
>>>>>> Alan
>>>>>>
>>>>>>
>>>>>> On Thu, Jun 18, 2015 at 9:44 PM, Morten Olav Hansen <
>>>>>> mortenoh@xxxxxxxxx> wrote:
>>>>>>
>>>>>>> I was looking at the stack trace, and the code it points to, is
>>>>>>> checking the option.code against the value you are sending in.. but it
>>>>>>> seems maybe some of your options don't have code? which is required
>>>>>>>
>>>>>>> --
>>>>>>> Morten
>>>>>>>
>>>>>>> On Fri, Jun 19, 2015 at 11:28 AM, Alan Hill <ahill@xxxxxxxxxx>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi again Morten...sorry, can you clarify, where do you see that?
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>>
>>>>>>>> Alan
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thu, Jun 18, 2015 at 6:56 PM, Morten Olav Hansen <
>>>>>>>> mortenoh@xxxxxxxxx> wrote:
>>>>>>>>
>>>>>>>>> Hi Alan
>>>>>>>>>
>>>>>>>>> Seems like you have an invalid optionset, i..e an optionset
>>>>>>>>> without code?
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Morten
>>>>>>>>>
>>>>>>>>> On Fri, Jun 19, 2015 at 7:47 AM, Alan Hill <ahill@xxxxxxxxxx>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> Hi there
>>>>>>>>>>
>>>>>>>>>> *Version 2.20-SNAPSHOT, Build #19453*
>>>>>>>>>>
>>>>>>>>>> Trying to update a TrackedEntityInstance but this is failing for
>>>>>>>>>> attributes that have an optionSet assigned.
>>>>>>>>>>
>>>>>>>>>> I've stripped my JSON update down to a single attribute.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> *API call:*
>>>>>>>>>>
>>>>>>>>>> PUT http://localhost:8000/api/trackedEntityInstances/gGCuCUO5Iu0
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> *JSON: Here's the json I'm sending for the update:*
>>>>>>>>>>
>>>>>>>>>> {
>>>>>>>>>> "trackedEntity":"An3UR3eaTTa",
>>>>>>>>>> "orgUnit":"FEGZA6BEAjj",
>>>>>>>>>> "attributes":[
>>>>>>>>>> {"attribute":"kxvbQMX8Yss","value":"3"}
>>>>>>>>>> ]
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> *Here's the TrackedEntityAttribute:*
>>>>>>>>>>
>>>>>>>>>> {
>>>>>>>>>>
>>>>>>>>>> - id: "kxvbQMX8Yss",
>>>>>>>>>> - created: "2015-06-18T22:27:51.242+0000",
>>>>>>>>>> - name: "DHS 2010 - sample domain",
>>>>>>>>>> - href: "
>>>>>>>>>> http://localhost:8000/api/trackedEntityAttributes/kxvbQMX8Yss"
>>>>>>>>>> ,
>>>>>>>>>> - lastUpdated: "2015-06-18T22:27:51.286+0000",
>>>>>>>>>> - code: "DHS 2010 - v023",
>>>>>>>>>> - shortName: "DHS 2010 - sample domain",
>>>>>>>>>> - displayDescription: "sample domain",
>>>>>>>>>> - unique: false,
>>>>>>>>>> - programScope: false,
>>>>>>>>>> - displayInListNoProgram: false,
>>>>>>>>>> - orgunitScope: false,
>>>>>>>>>> - displayOnVisitSchedule: false,
>>>>>>>>>> - dataDimension: true,
>>>>>>>>>> - description: "sample domain",
>>>>>>>>>> - externalAccess: false,
>>>>>>>>>> - valueType: "optionSet",
>>>>>>>>>> - confidential: false,
>>>>>>>>>> - publicAccess: "rw------",
>>>>>>>>>> - allItems: false,
>>>>>>>>>> - inherit: false,
>>>>>>>>>> - dimension: "kxvbQMX8Yss",
>>>>>>>>>> - optionSetValue: true,
>>>>>>>>>> - displayName: "DHS 2010 - sample domain",
>>>>>>>>>> - displayShortName: "DHS 2010 - sample domain",
>>>>>>>>>> - optionSet:
>>>>>>>>>> {
>>>>>>>>>> - id: "CnFzpGPWbJg",
>>>>>>>>>> - name: "DHS 2010 - sample domain",
>>>>>>>>>> - code: "DHS 2010 - v023",
>>>>>>>>>> - created: "2015-06-18T22:27:51.101+0000",
>>>>>>>>>> - lastUpdated: "2015-06-18T23:51:10.981+0000",
>>>>>>>>>> - href: "http://localhost:8000/api/optionSets/CnFzpGPWbJg"
>>>>>>>>>> },
>>>>>>>>>> - access:
>>>>>>>>>> {
>>>>>>>>>> - update: true,
>>>>>>>>>> - externalize: false,
>>>>>>>>>> - write: true,
>>>>>>>>>> - delete: true,
>>>>>>>>>> - read: true,
>>>>>>>>>> - manage: true
>>>>>>>>>> },
>>>>>>>>>> - user:
>>>>>>>>>> {
>>>>>>>>>> - id: "M4XhsWJlIhk",
>>>>>>>>>> - name: "admin admin",
>>>>>>>>>> - created: "2015-06-18T15:26:06.062+0000",
>>>>>>>>>> - lastUpdated: "2015-06-18T16:07:29.473+0000",
>>>>>>>>>> - href: "http://localhost:8000/api/users/M4XhsWJlIhk"
>>>>>>>>>> },
>>>>>>>>>> - attributeValues: [ ],
>>>>>>>>>> - items: [ ],
>>>>>>>>>> - userGroupAccesses: [ ]
>>>>>>>>>>
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> *Here's the OptionSet:*
>>>>>>>>>>
>>>>>>>>>> {
>>>>>>>>>>
>>>>>>>>>> - lastUpdated: "2015-06-18T23:51:10.981+0000",
>>>>>>>>>> - code: "DHS 2010 - v023",
>>>>>>>>>> - id: "CnFzpGPWbJg",
>>>>>>>>>> - created: "2015-06-18T22:27:51.101+0000",
>>>>>>>>>> - name: "DHS 2010 - sample domain",
>>>>>>>>>> - href: "http://localhost:8000/api/optionSets/CnFzpGPWbJg",
>>>>>>>>>> - publicAccess: "rw------",
>>>>>>>>>> - version: 0,
>>>>>>>>>> - externalAccess: false,
>>>>>>>>>> - displayName: "DHS 2010 - sample domain",
>>>>>>>>>> - access:
>>>>>>>>>> {
>>>>>>>>>> - update: true,
>>>>>>>>>> - externalize: false,
>>>>>>>>>> - write: true,
>>>>>>>>>> - delete: true,
>>>>>>>>>> - read: true,
>>>>>>>>>> - manage: true
>>>>>>>>>> },
>>>>>>>>>> - user:
>>>>>>>>>> {
>>>>>>>>>> - id: "M4XhsWJlIhk",
>>>>>>>>>> - name: "admin admin",
>>>>>>>>>> - created: "2015-06-18T15:26:06.062+0000",
>>>>>>>>>> - lastUpdated: "2015-06-18T16:07:29.473+0000",
>>>>>>>>>> - href: "http://localhost:8000/api/users/M4XhsWJlIhk"
>>>>>>>>>> },
>>>>>>>>>> - userGroupAccesses: [ ],
>>>>>>>>>> - options:
>>>>>>>>>> [
>>>>>>>>>> -
>>>>>>>>>> {
>>>>>>>>>> - id: "Fnkf3CXYjtU",
>>>>>>>>>> - name: "northern",
>>>>>>>>>> - code: "1",
>>>>>>>>>> - created: "2015-06-18T22:27:50.583+0000",
>>>>>>>>>> - lastUpdated: "2015-06-18T23:51:10.554+0000",
>>>>>>>>>> - href: "http://localhost:8000/api/options/Fnkf3CXYjtU"
>>>>>>>>>> },
>>>>>>>>>> -
>>>>>>>>>> {
>>>>>>>>>> - id: "p6xLuMAZ6Kx",
>>>>>>>>>> - name: "central",
>>>>>>>>>> - code: "2",
>>>>>>>>>> - created: "2015-06-18T22:27:50.720+0000",
>>>>>>>>>> - lastUpdated: "2015-06-18T23:51:10.675+0000",
>>>>>>>>>> - href: "http://localhost:8000/api/options/p6xLuMAZ6Kx"
>>>>>>>>>> },
>>>>>>>>>> -
>>>>>>>>>> {
>>>>>>>>>> - id: "XJa5QiUzKgb",
>>>>>>>>>> - name: "southern",
>>>>>>>>>> - code: "3",
>>>>>>>>>> - created: "2015-06-18T22:27:50.910+0000",
>>>>>>>>>> - lastUpdated: "2015-06-18T23:51:10.803+0000",
>>>>>>>>>> - href: "http://localhost:8000/api/options/XJa5QiUzKgb"
>>>>>>>>>> }
>>>>>>>>>> ]
>>>>>>>>>>
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> However, this fails and I see an exception in tomcat logs:
>>>>>>>>>>
>>>>>>>>>> SEVERE: Servlet.service() for servlet [webapi] in context with
>>>>>>>>>> path [] threw exception [Request processing failed; nested exception is
>>>>>>>>>> java.lang.NullPointerException] with root cause
>>>>>>>>>> java.lang.NullPointerException
>>>>>>>>>> at
>>>>>>>>>> org.hisp.dhis.trackedentity.TrackedEntityAttribute.isValidOptionValue(TrackedEntityAttribute.java:162)
>>>>>>>>>> at
>>>>>>>>>> org.hisp.dhis.dxf2.events.trackedentity.AbstractTrackedEntityInstanceService.validateAttributeType(AbstractTrackedEntityInstanceService.java:582)
>>>>>>>>>> at
>>>>>>>>>> org.hisp.dhis.dxf2.events.trackedentity.AbstractTrackedEntityInstanceService.checkAttributes(AbstractTrackedEntityInstanceService.java:404)
>>>>>>>>>> at
>>>>>>>>>> org.hisp.dhis.dxf2.events.trackedentity.AbstractTrackedEntityInstanceService.updateTrackedEntityInstance(AbstractTrackedEntityInstanceService.java:293)
>>>>>>>>>> at
>>>>>>>>>> org.hisp.dhis.dxf2.events.trackedentity.JacksonTrackedEntityInstanceService.updateTrackedEntityInstanceJson(JacksonTrackedEntityInstanceService.java:198)
>>>>>>>>>> at sun.reflect.GeneratedMethodAccessor895.invoke(Unknown
>>>>>>>>>> Source)
>>>>>>>>>> at
>>>>>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>>>>>>>> at java.lang.reflect.Method.invoke(Method.java:606)
>>>>>>>>>> at
>>>>>>>>>> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
>>>>>>>>>> ...
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Any advice greatly appreciated.
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>>
>>>>>>>>>> Alan
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> Mailing list: https://launchpad.net/~dhis2-devs
>>>>>>>>>> Post to : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>>>>>>>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>>>>>>>>> More help : https://help.launchpad.net/ListHelp
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~dhis2-devs
>>> Post to : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>> More help : https://help.launchpad.net/ListHelp
>>>
>>>
>>
>>
>> --
>> Lars Helge Øverland
>> Lead developer, DHIS 2
>> University of Oslo
>> Skype: larshelgeoverland
>> http://www.dhis2.org <https://www.dhis2.org>
>>
>>
>
References
-
TrackedEntityInstance update
From: Alan Hill, 2015-06-19
-
Re: TrackedEntityInstance update
From: Morten Olav Hansen, 2015-06-19
-
Re: TrackedEntityInstance update
From: Alan Hill, 2015-06-19
-
Re: TrackedEntityInstance update
From: Morten Olav Hansen, 2015-06-19
-
Re: TrackedEntityInstance update
From: Alan Hill, 2015-06-19
-
Re: TrackedEntityInstance update
From: Morten Olav Hansen, 2015-06-19
-
Re: TrackedEntityInstance update
From: Morten Olav Hansen, 2015-06-19
-
Re: TrackedEntityInstance update
From: Alan Hill, 2015-06-19
-
Re: TrackedEntityInstance update
From: Lars Helge Øverland, 2015-06-19
-
Re: TrackedEntityInstance update
From: Alan Hill, 2015-06-19