Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting compile time error in castor generated java file  RSS feed

 
Sumeet Srivastava
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

your help would be appreciated

I am trying to call webservice which would return complex data type like my own developed java class say Psp.java, which is having setter/getter of three variables, all are of string type. I am getting this in response form from ServerClient.sendReceive(payload) method. This is like :

"<ns:getEchoStringResponse xmlns:ns="http://test.tom/xsd"><ns:return xmlns:ax21="http://service/xsd" type="service.Psp"><ax21:errDs>Success</ax21:errDs><ax21:qryId>43113</ax21:qryId><ax21:qryName>test567</ax21:qryName></ns:return></ns:getEchoStringResponse>"


Now, this is my xsd file:

<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://test.tom/xsd" xmlns:axis2="http://test.tom/" xmlns:ns="http://test.tom/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="getEchoString">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="echoStr" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="getEchoStringResponse" type="ns:psp"/>
<xs:complexType name="psp">
<xs:sequence>
<xs:element name="qryId" type="xs:integer"/>
<xs:element name="qryName" type="xs:string"/>
<xs:element name="errDs" type="xs:string"/>
</xs:sequence>
</xs:complexType>


<xs:element name="main">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="args" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Through castor's code generator, I got 8 java files (4 files for simple java and 4 files for descriptor java) from xsd file.

I am getting following complie time errors in MainDescriptor.java file:

org.exolab.castor.xml.util.XMLFieldDescriptorImpl desc = null;
desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(java.lang.String.class, "_argsList", "args", org.exolab.castor.xml.NodeType.Element);

desc.setSchemaType("list");
// complie time error #1
desc.setComponentType("string"); // complie time error is: this method in undefined for the type XMLFieldDescriptorImpl
desc.setHandler(handler);
desc.setNillable(true);
desc.setMultivalued(true);
addFieldDescriptor(desc);
// complie time error #2
addSequenceElement(desc); // complie time error is: this method in undefined for the type MainDescriptor.java

the complie time error #2 is also comming in PspDescriptor.java and GetEchoStringDescriptor.java file.

Please let me know where I am missing any steps.. Thanks in advance.


One more thing, I commented that line where I am getting error. and try to unmarsh to Java through castor. this is following code whcih I am using for un-marshalling:

response = sc.sendReceive(createPayLoad());
StAXSource staxSource = new StAXSource(response.getXMLStreamReader());
Unmarshaller unmarshaller = new Unmarshaller(GetEchoStringResponse.class);
UnmarshalHandler unmarshalHandler = unmarshaller.createHandler();
GetEchoStringResponse echoStringResponse;
try {
ContentHandler contentHandler = Unmarshaller.getContentHandler(unmarshalHandler);
SAXResult staxTarget = new SAXResult(contentHandler);
try {
// runtime error line
TransformerFactory.newInstance().newTransformer().transform(staxSource, staxTarget); } catch (TransformerFactoryConfigurationError e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
echoStringResponse = (GetEchoStringResponse) unmarshalHandler.getObject();

} catch (SAXException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (TransformerException e) {
e.printStackTrace();
throw new RuntimeException(e);
}


Getting following error while running :
Exception in thread "main" java.lang.NullPointerException
at javanet.staxutils.StAXSource$1.parse(StAXSource.java:196)
at javanet.staxutils.StAXSource$1.parse(StAXSource.java:181)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
at client.TomClient.main(TomClient.java:96)

Please help me out on this.

Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!