Can't draw Associations within a package

I have this block of code that read my project, iterate through every element in a package. I do a check:
if the element is an instanceof IClass, then I draw the class. I was able to draw all the classes.
If the element is an instanceof IAssociation, the draw the association. But I wasn’t able to draw associations. Can anyone help? Thanks.

public void createClassDiagram(DiagramManager manager,
IModelElementFactory factory) {

	// create and open a new class diagram
	IClassDiagramUIModel diagram = (IClassDiagramUIModel) manager

	// create a system boundary and the corresponding UI model
	ISystem system = factory.createSystem();
	system.setName("System 1");
	IShapeUIModel systemShape = ((IShapeUIModel) manager
			.createDiagramElement(diagram, system));
	systemShape.setBounds(0, 0, 700, 700);

	// load project
	IProject project = ApplicationManager.instance().getProjectManager()
	Iterator iter1 = project
	while (iter1.hasNext()) {
		IPackage obj1 = (IPackage);
		Iterator iter2 = obj1.childIterator();
		while (iter2.hasNext()) {
			Object obj =;
			if (obj instanceof IClass) {
				IClass theClass = (IClass) obj;
				IShapeUIModel classShape = ((IShapeUIModel) manager
						.createDiagramElement(diagram, theClass));
				classShape.setBounds(10, 10, 10, 10);
				classShape.setLocation(20, 20);
			} else if (obj instanceof IAssociation) {
				IAssociation theAssociation = (IAssociation) obj;
				IShapeUIModel associationShape = ((IShapeUIModel) manager
						.createDiagramElement(diagram, theAssociation));
				associationShape.setBounds(10, 10, 10, 10);
				associationShape.setLocation(20, 20);

Hi user,

Thank you for post. It seems that you have submitted a ticket with the same query, please check your ticket if I’m right.

If there are any inquiries, please feel free to ask.

Best regards,
Lilian Wong