(PeakFlow)thing.getData() giving NullPointer

Jun 21, 2012 at 8:14 AM

Hi Everybody,

I have downloaded the latest version of java sdk version R1.3.1. But still i am getting NullPointer at 

PeakFlow peakFlow = (PeakFlow)thing.getData();

getData() method in this case returns null. Do i need to any other methods. How i can get the Object from this.

I am, putting my sample code below

 

	
List <PeakFlow> peakFlowList = new ArrayList<PeakFlow>(); 
    	try{
    		GetThingsResponse gtResponse = (GetThingsResponse)requestTemplate.makeRequest(info,getPersonInfo());
    		List<Thing> pfList = gtResponse.getGroup().get(0).getThing();
    		logger.info("pfList.size() == "+pfList.size()); // It returns size 5 for example
    		Iterator<Thing> iterator = pfList.iterator();
    		while ( iterator.hasNext() ){
    			Thing thing = (Thing)iterator.next();
    			PeakFlow peakFlow = (PeakFlow)thing.getData(); // --> Here comes NullPointer when accessing getData()
    			logger.info("peakFlow thing = "+peakFlow); //--> peakFlow object is null here
    			peakFlowList.add(peakFlow);
    		}
	}catch (Exception e) {
    		e.printStackTrace();
    	}

 

Any reply from you will be helpful to us.

Thanks

Hasan

Coordinator
Jun 21, 2012 at 11:17 PM

Hi Hasan,

It looks like PeakFlow was a versioned type and I added it incorrectly to the type mapping.

If you look at com.microsoft.hsg.thing.oxm.jaxb.thing.TypeManager, you will see a table of type-ids to classes.  Change the type-id for PeakFlow from "921588d1-27bf-423c-8e55-650d2fedb3e0" to "5d8419af-90f0-4875-a370-0f881c18f6b3" and everything should work.  I'll be pushing a new release within the next two weeks and I'll add that to the list for an official build.  In the mean time if you make the change to your local copy you can continue with development.

--Rob


Jun 22, 2012 at 8:39 AM

Thanks Rob. Much appreciated.

 

Regards,

Hasan