Hi Fady,
Legstar has been really a great software and has been useful to many of our projects. We have been using it for converting COBOL message as a String to Java and this is the first time , we have had a requirement to do javaToHost to push the message over MQ. When trying to convert java to Host we are receiving the below exception even though we have choice defined.
Exception:-
com.legstar.coxb.transform.HostTransformException: No alternative found for choice element GtmLeRoleChoice
at com.legstar.coxb.transform.AbstractJavaToHostTransformer.transform(AbstractJavaToHostTransformer.java:204)
at com.legstar.coxb.transform.AbstractJavaToHostTransformer.transform(AbstractJavaToHostTransformer.java:119)
at com.legstar.coxb.transform.AbstractJavaToHostTransformer.transform(AbstractJavaToHostTransformer.java:100)
at com.legstar.coxb.transform.AbstractTransformers.toHost(AbstractTransformers.java:95)
at main.TestLegstar.main(TestLegstar.java:33)
Caused by: No alternative found for choice element GtmLeRoleChoice
at com.legstar.coxb.impl.visitor.CobolMarshalVisitor.visit(CobolMarshalVisitor.java:204)
at com.legstar.coxb.common.CChoiceBinding.accept(CChoiceBinding.java:81)
at com.legstar.coxb.impl.visitor.CobolMarshalVisitor.visit(CobolMarshalVisitor.java:106)
at com.legstar.coxb.common.CComplexBinding.accept(CComplexBinding.java:72)
at com.legstar.coxb.impl.visitor.CobolMarshalVisitor.visit(CobolMarshalVisitor.java:235)
at com.legstar.coxb.common.CArrayComplexBinding.accept(CArrayComplexBinding.java:71)
at com.legstar.coxb.impl.visitor.CobolMarshalVisitor.visit(CobolMarshalVisitor.java:106)
at com.legstar.coxb.common.CComplexBinding.accept(CComplexBinding.java:72)
at com.legstar.coxb.impl.visitor.CobolMarshalVisitor.visit(CobolMarshalVisitor.java:106)
at com.legstar.coxb.common.CComplexBinding.accept(CComplexBinding.java:72)
at com.legstar.coxb.transform.AbstractJavaToHostTransformer.transform(AbstractJavaToHostTransformer.java:173)
... 4 more
Please see below all the information I have.
Copybook Layout:
*****************************************************************
01 GTM-ACCOUNTCP-UPDATE.
05 GTM-CPACCT-PROPERTIES.
10 GTM-CPACCT-PROP-DETAIL OCCURS 50 TIMES.
15 GTM-LE-ROLE PIC X(12).
15 GTM-SERV-PREF-VALUE REDEFINES GTM-LE-ROLE.
20 GTM-SERV-PREF-VAL PIC X(8).
20 GTM-SERV-PREF-VAL-FILLER PIC X(4).
Legstar Generated XSD:-
Please see attachment
Java Test Class
public static void main(String[] args) {
// TODO Auto-generated method stub
GtmAccountcpUpdate header = new GtmAccountcpUpdate();
GtmCpacctPropDetail gtmCpacctPropDetail=new GtmCpacctPropDetail();
gtmCpacctPropDetail.setGtmLeRole("TESTLEROLE");
GtmCpacctProperties gtmCpacctProperties=new GtmCpacctProperties();
gtmCpacctProperties.getGtmCpacctPropDetail().add(gtmCpacctPropDetail);
header.setGtmCpacctProperties(gtmCpacctProperties);
GtmAccountcpUpdateTransformers accountcpUpdateTransformers = new GtmAccountcpUpdateTransformers();
try {
byte[] out = accountcpUpdateTransformers.toHost(header, "ISO-8859-1");
System.out.println(new String(out));
} catch (HostTransformException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
When I use the same program to do Host To Java , it works perfectly , whereas java to host gives me that exception.
At the same time , if I remove OCCURS 50 TIMES , it works with no issues for both java to host and host to java.
I am really stuck here and don't understand why it would throw an error for choice class, when I have defined my choice class in XSD.
Please advise.
Thanks,
Athul