J2ME Stub generates an unknown exception with JPA

2019-06-08 06:30发布

问题:

I created a web service stub using NetBeans 7.0 and when I try using it, it throws an unknown Exception. I don't even know what part of my code to show here, all I know is that bolded line generates an unknown Exception:

public Businesses[] findBusiness(String query) throws java.rmi.RemoteException {
    Object inputObject[] = new Object[]{
        query
    };

    Operation op = Operation.newInstance(_qname_operation_findBusiness, _type_findBusiness, _type_findBusinessResponse);
    _prepOperation(op);
    op.setProperty(Operation.SOAPACTION_URI_PROPERTY, "");
    Object resultObj;
    try {
        resultObj = op.invoke(inputObject);
    } catch (JAXRPCException e) {
        Throwable cause = e.getLinkedCause();
        if (cause instanceof java.rmi.RemoteException) {
            throw (java.rmi.RemoteException) cause;
        }
        throw e;
    }

    return businesses_ArrayfromObject((Object[]) resultObj);
}

private static Businesses[] businesses_ArrayfromObject(Object obj[]) {
    if (obj == null) {
        return null;
    }
    Businesses result[] = new Businesses[obj.length];
    for (int i = 0; i < obj.length; i++) {
        result[i] = new Businesses();
        Object[] oo = (Object[]) obj[i];
        result[i].setAddress((String) oo[0]); // **exception here**
        result[i].setEmail((String) oo[1]);
        result[i].setId((Integer) oo[2]);
        result[i].setName((String) oo[3]);
        result[i].setPhoneno((String) oo[4]);
        result[i].setProducts((String) oo[5]);
    }
    return result;
}`

I tried to consume the same webservice using a web application and it works quite well. I don't have a single clue to what is causing this exception. Any comment would be appreciated.

Update

I tried other services that return a String data type and it works fine. So I thought maybe J2ME has issues with JPA Entity types.

So my question is how do I return the data properly so that the J2ME client can read it well?