File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Product and Other Certifications and the fly likes problem converting xml into bean using betwixt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "problem converting xml into bean using betwixt" Watch "problem converting xml into bean using betwixt" New topic

problem converting xml into bean using betwixt


Joined: Jul 28, 2007
Posts: 4
Hi,i need to parse a xml,which contains a list(UserPermissions) and an object(Users) into an object called "UserResponse". after parsing iam able to get that object(Users),but,iam unable to get the list(UserPermissions),instead i am getting the "NullPointerException".i am posting the xml:

and the class "SelectUserResponse":
public class SelectUsersResponse {
public SelectUsersResponse(){}

private List storeLists;
private Users users;

public Users getUsers() {
return users;

public void setUsers(Users users) {
this.users = users;

public List getStoreObjects() {
return storeLists;

public void setStoreObjects(List storeObjects) {
this.storeLists = storeObjects;


and the registration of these classes at custom path:
public static Object xmlToBean(byte[] theXml) throws IntrospectionException, IOException, SAXException {

BeanReader beanReader = new BeanReader();
beanReader.registerBeanClass( "users",Users.class);
beanReader.registerBeanClass("SelectUserPermissionsRequest", SelectUserPermissionsRequest.class);
beanReader.registerBeanClass("SelectUsersResponse",SelectUsersResponse.class );
beanReader.registerBeanClass("storeObjects",List.class );

System.out.println("the xml ready to be parsed is"+new String(theXml));
Object o = beanReader.parse(new ByteArrayInputStream(theXml));
return o;
please help me out. i tried my level best to frame the question.thanks in advance
Martijn Verburg

Joined: Jun 24, 2003
Posts: 3274

Hi there and welcome to Javaranch, a couple of admin things first.

1.) Please do adhere to the Javaranch naming policy e.g. Your display name needs to be a 'real' first and last name.

2.) Please do use when listing your sample code.

Now onto your question .

As far as I can see you have the UserPermissions tag appearing in your XML on more than one occasion, yet you are trying to bind it to a single object, are you sure you shouldn't be binding it to a list as well?

Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
wood burning stoves
subject: problem converting xml into bean using betwixt