users@jaxb.java.net

Null pointer exception at client side with CXF framework

From: dharmnaresh <naresh.dharmisetty_at_gmail.com>
Date: Sun, 19 Apr 2009 21:54:32 -0700 (PDT)

Hi,

I am exposing a method that will take two parameters and return a
ResultArray class.

Problem: At the CXF/XFire client code arraysize is coming exactly, but the
ids are becoming null.

I verified the functionality with soap utility by sending a request with
proper jobId and username. The response object is carrying proper superId.
In the java code only it is failing.

Analysis: I have done some research. I removed adapter class on MyId class
then it is working fine. I am not understanding why it is failing with
adapter in both super and sub classes.

Please tell me why this problem is happening.

Syntax for my services like this.
=============================================
@Webmethod
public ResultArray getResultArray(Long jobId, String username);

========================================
ResultArray :

@XmlRootElement(name = "ResultArray")
public class ResultArray
{
private MyIds[] myId;

public ResultArray()
{
}

public MyIds[] getMyIds()
{
return myId;
}

public void setMyIds(MyIds[] myId)
{
this.myId= myId;
}

}
======================================
MyId class:

@XmlJavaTypeAdapter(MyIdAdapter.class)
public class MyId extends SuperId implements Serializable
{
// nothing
}
=======================================
public class MyIdAdapter extends XmlAdapter<String, MyId >
{

@Override
public String marshal(MyId id) throws Exception
{
if (id == null)
{
return null;
}
else
{
return id.asString();
}
}

@Override
public MyId unmarshal(String id) throws Exception
{
return new MyId(id);
}

}
======================================

@XmlJavaTypeAdapter(SuperIdAdapter.class)
@XmlRootElement(name = "SuperId")
public class SuperId implements Serializable, Cloneable
{
protected String _id;

public SuperId()
{
}


/**
* Constructs an identifier from a string.
*
* @param id The unique identifier for the entity.
*/
public SuperId(String id)
{
_id = id;
}


//intended for hibernate use only
@XmlElement(required = true)
public void setSuperId(String id)
{
_id = id;
}

public Object clone()
{
try
{
return super.clone();
}
catch (CloneNotSupportedException e)
{
//should never happen
return null;
}
}


public List<SuperId> asSuperIdList()
{
List<SuperId> idList = new ArrayList<SuperId>();
idList.add(this);
return idList;
}

public String getSuperId()
{
return _id;
}

public String asString()
{
return _id;
}

public String toString()
{
return _id;
}
}
======================================
@XmlRootElement(name = "SuperIdAdapter")
public class SuperIdAdapter extends XmlAdapter<String, SuperId>
{

@Override
public String marshal(SuperId id) throws Exception
{
if (id == null)
{
return null;
}
else
{
return id.asString();
}
}

@Override
public SuperId unmarshal(String id) throws Exception
{
return new SuperId(id);
}

}
===============================

Thanks,
Naresh.D.

-- 
View this message in context: http://www.nabble.com/Null-pointer-exception-at-client-side-with-CXF-framework-tp23130364p23130364.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.