Hey, I have 2
java project one is main application project, and other is the worker project. I am using xsd as contract.now the common schema(xsd) resides in application project. In the worker project I have the response schema which has the common as include schema.
so when I compile both projects, using jaxb first, it creates the java classes for common schema in both application, as well as in worker project.
I have some common functionality, in the application project, which uses the java classes of jaxb compiled common schema. but when I invoke this functionality from worker project, it takes the input as java classes from application project, so I need to cast the jaxb compiled java classes from the worker project to jaxb compiled java classes of application project.
but at run time this cast always fails, with java.lang.ClassCastException.
I even tried to use, Class.cast(Object o) method, to perform the casting, but no luck
{no format}Please suggest me the ways of casting?{no format}
For eg:
List<com.abc.xyz.application.contributions.BusinessContactType> bConList = null;
if (cpReq.getBusinessContacts() != null
&& cpReq.getBusinessContacts().getBusinessContact() != null) {
bConList = (List<com.abc.xyz.application.contributions.BusinessContactType
><div class="jive-quote">) cpReq</div>
.getBusinessContacts().getBusinessContact();
}
if (bConList.size() > 0) {
busCode = ctwfUtils.addUpdBusinessContactDetails(wiidarr,
bConList, param);
}
in abocve code
cpReq.getBusinessContacts().getBusinessContact()
returns me the list of business contacts of type com.abc.xyz.worker.contributions.BusinessContactType & my function
ctwfUtils.addUpdBusinessContactDetails(wiidarr,bConList, param);
require the bCon list of com.abc.xyz.application.contributions.BusinessContactType.
While BusinessContactType is the common xml schema complex type. which is used in the request of worker xml schema. Jaxb compiler created the BusinessContactType
in appliccation as well as in the worker project.
xml
Always, {Code} bConList = (List<com.abc.xyz.application.contributions.BusinessContactType
) cpReq.getBusinessContacts().getBusinessContact();{code}
this casting fails.
I am not able to find any reasons.>