Please post the full stack trace of the error. What line is causing the ClassCastException?
The reason is simply a Casting issue, but let's find out why it's occurring.
Main Topics
Browse All TopicsI tried to add a child XML based content to a XML based virtual content programatically and getting the following error. The child content and virtual content reside in the repository. Any idea why I am getting the following error.
thanks in advance
java.lang.ClassCastExcepti
sample code
public boolean checkoutVDM(String docId){
try {
IDfCheckoutOperation coOp = clientx.getCheckoutOperati
//coOp.setDestinationDirec
IDfDocument doc = (IDfDocument) session.getObject(new DfId(docId));
IDfCheckoutNode coNode;
if (doc.isVirtualDocument()){
IDfVirtualDocument vDoc = doc.asVirtualDocument( "CURRENT",false);
coNode = (IDfCheckoutNode)coOp.add(
} else {
coNode = (IDfCheckoutNode)coOp.add(
}
if (coOp.execute()) {
return true;
} else {
return false;
}
} catch(Exception ex){
ex.printStackTrace();
System.out.println("checko
}
return false;
}
public boolean checkinVDM(String docId){
try {
IDfCheckinOperation cio = clientx.getCheckinOperatio
cio.setCheckinVersion(IDfC
cio.setVersionLabels("CURR
IDfDocument doc = (IDfDocument) session.getObject(new DfId(docId));
if (doc.isVirtualDocument()){
IDfVirtualDocument vDoc = doc.asVirtualDocument( "CURRENT",false);
IDfCheckinNode node = (IDfCheckinNode) cio.add(vDoc);
} else{
IDfCheckinNode node = (IDfCheckinNode) cio.add(doc);
}
if (!cio.execute())
{
return false;
}
} catch(Exception ex){
ex.printStackTrace();
System.out.println("checki
}
return true;
}
public boolean createVDMNode(String parentIdString, String childIdString, String versionLabel, String siblingIdString){
try {
boolean bCheckoutSuccess = checkoutVDM(parentIdString
if (bCheckoutSuccess) {
IDfVirtualDocument vDoc = null;
IDfId parentIdObject = clientx.getId(parentIdStri
IDfSysObject sysObj = (IDfSysObject) session.getObject(parentId
if (versionLabel.equals("")) versionLabel = null;
if (sysObj != null){
vDoc = sysObj.asVirtualDocument(n
IDfVirtualDocumentNode root = vDoc.getRootNode();
IDfId childId = session.getIdByQualificati
IDfSysObject childObj = (IDfSysObject) session.getObject(childId)
IDfVirtualDocumentNode siblingNode = null;
if (!siblingIdString.equals(n
IDfId siblingId = session.getIdByQualificati
IDfSysObject siblingObj = (IDfSysObject) session.getObject(siblingI
String siblingChronId = siblingObj.getChronicleId(
siblingNode = vDoc.find(root,siblingChro
}
IDfVirtualDocumentNode childVDNode = vDoc.addNode(root, siblingNode, childObj.getChronicleId(),
//vDoc.addNode(root, siblingNode, childObj.getChronicleId(),
boolean bCheckinSuccess = checkinVDM(parentIdString)
if (bCheckinSuccess) {
return true;
} else {
return false;
}
}
}
} catch(Exception ex){
ex.printStackTrace();
System.out.println("checki
}
return false;
}
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
com.documentum.vdm.impl.Ad
at com.documentum.vdm.impl.Vi
at com.deloitte.da.cms.ems.ut
at com.deloitte.da.cms.ems.ut
at sun.reflect.NativeMethodAc
at sun.reflect.NativeMethodAc
at sun.reflect.DelegatingMeth
at java.lang.reflect.Method.i
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.junit.internal.runners
at org.eclipse.jdt.internal.j
at org.eclipse.jdt.internal.j
at org.eclipse.jdt.internal.j
at org.eclipse.jdt.internal.j
at org.eclipse.jdt.internal.j
at org.eclipse.jdt.internal.j
Are you passing an uninstantiated object into the insertAfterNode (i.e., siblingNode) parameter?
If you change this line:
IDfVirtualDocumentNode childVDNode = vDoc.addNode(root, siblingNode, childObj.getChronicleId(),
to:
IDfVirtualDocumentNode childVDNode = vDoc.addNode(root, null, childObj.getChronicleId(),
does that work?
Secondly, are you sure that the childObj is populated correctly?
Thanks for info, I already verified by pass valide sibilingNode and also null, both cases issue is same.
I also verified with pdf as virtual document and childs components are also pdf with same code it works fine.
my actual requirement is virtual document is xml and child component also xml, this case it is throwing exception as specified.
Business Accounts
Answer for Membership
by: vittalmareddyPosted on 2009-10-22 at 08:23:34ID: 25635280
Any idea on this issue