This document was generated from CDN thread
Created by: null on 10-11-2003 06:39:23 AM
The following code throwing a nullpointer exception. Can you just check the code and tell me what is wrong?[code:1:eefab7b86f]import java.util.*;
import com.audium.server.action.database.*;
import com.audium.server.proxy.VoiceElementInterface;
import com.audium.server.AudiumException;
import com.audium.server.session.ElementAPI;
import com.audium.server.xml.VoiceElementConfig;
public class PhoneList implements VoiceElementInterface
{
public VoiceElementConfig getConfig( String name,
ElementAPI elementAPI,
VoiceElementConfig defaults) throws AudiumException
{
VoiceElementConfig.AudioGroup initial = defaults.getAudioGroup("initial_audio_group", 1);
ResultSetList result = (ResultSetList)elementAPI.getSessionData("reception");
System.out.println("Value inside the phoneLIST");
// Iterate through the list of values stored in the ResultSetList object
// created from the database action
for (int i = 0; i < result.getNumRows(); i++)
{
System.out.println("The name inside for loop phoneLIST is " + result.getValue("name", i) );
System.out.println("Extension inside the for loop phoneLIST ext is " + result.getValue("extension", i) );
defaults.addSettingValue("voice_keyword", result.getValue("name", i) + "[" + result.getValue("name", i) + "]");
System.out.println("defaults in the for loop are ");
}
System.out.println("defaults are ");
// Return the Voice Element Configuration.*/
return defaults;
}
}
[/code:1:eefab7b86f]
It geerates an error when it reaches the folowing line of code[code:1:eefab7b86f]defaults.addSettingValue("voice_keyword", result.getValue("name", i) + "[" + result.getValue("name", i) + "]");[/code:1:eefab7b86f]
The error is
[code:1:eefab7b86f]172.17.1.193.1068446009243.0.Rec1,11/10/2003 17:34:07,An error has occurred.
java.lang.NullPointerException
at PhoneList.getConfig(PhoneList.java:17)
at com.audium.server.voiceElement.VoiceElementBase.determineConfig(Unknown Source)
at com.audium.server.voiceElement.VoiceElementBase.service(Unknown Source)
at com.audium.server.controller.Controller.if(Unknown Source)
at com.audium.server.controller.Controller.for(Unknown Source)
at com.audium.server.controller.Controller.a(Unknown Source)
at com.audium.server.controller.Controller.for(Unknown Source)
at com.audium.server.controller.Controller.a(Unknown Source)
at com.audium.server.controller.Controller.doPost(Unknown Source)
at com.audium.server.controller.Controller.doGet(Unknown Source)[/code:1:eefab7b86f]
Subject: RE: VoiceElementCofig
Replied by: null on 11-11-2003 06:15:35 PM
Hi Jaison,
The null pointer stack trace says it occurs on line 17 which is the first line in your method not the line you listed.
This is a dynamic voice element configuration class. The argument "defaults" contains the base configuration in it. If you chose not to have a base configuration in the Audium Builder, this argument will be null. This seems to be what is happening in your code. When you call defaults.getAudioGroup it throws the exception. So make sure you have a base configuration in the Audium Builder and you will not get a null pointer here.
Hope this helps.