Thursday, March 5, 2015

Oracle MAF Error : java.lang.Integer cannot be cast to oracle.adfmf.util.GenericType

Hi Developers,

I faced the following error when I was implementing a tutorial :
http://www.ateam-oracle.com/going-mobile-with-adf-programmatically-invoking-soap-web-services-with-complex-types/



The detail analysis for this error can be found out on following link :

https://community.oracle.com/thread/3647460

But if you want to quickly solve the error modify the DepartmentService.java file as described below :

-------------------------------------------------------------------------------------------------------------------------
package oracle.ateam.mobile.soapdemo.model;

import java.util.ArrayList;
import java.util.List;

import oracle.adfmf.framework.api.AdfmfJavaUtilities;
import oracle.adfmf.framework.api.GenericTypeBeanSerializationHelper;
import oracle.adfmf.framework.exception.AdfException;
import oracle.adfmf.util.GenericType;

public class DepartmentService {
    List departments = new ArrayList();

    public DepartmentService() {
        super();
        findAll();
    }

    public Department[] getDepartments() {
        Department[] departmentArray = (Department[]) departments.toArray(new Department[departments.size()]);
        return departmentArray;
    }

    public void findAll() {
        try {
            GenericType result =
                (GenericType) AdfmfJavaUtilities.invokeDataControlMethod("HRSOAPService", null, "findDepartments",
                                                                         new ArrayList(), new ArrayList(),
                                                                         new ArrayList());
            result = result.getParent(); // this line will solve error
            for (int i = 0; i < result.getAttributeCount(); i++) {
                GenericType entityGenericType = (GenericType) result.getAttribute(i);

                Department department =
                    (Department) GenericTypeBeanSerializationHelper.fromGenericType(Department.class,
                                                                                    entityGenericType);
                departments.add(department);
            }
        } catch (Exception e) {
            throw new AdfException(e.getLocalizedMessage(), AdfException.ERROR);
        }
    }
}
------------------------------------------------------------------------------------------------------------------------

NOTE :   Following code actually solves the problem of your life :

                 result = result.getParent();

That is it, now enjoy your life with programmatic implementation of WSDL using JAVA in MAF.




No comments:

Post a Comment