1

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?

Community
  • 1
  • 1
burntblark
  • 1,680
  • 1
  • 15
  • 25
  • What version of JME are you using, are you certain that all classes used by the stub actually are available in JME? – ThomasRS Oct 26 '11 at 14:33
  • The webservice returns a List of JPA entities and the stub generator converts it τ̲̅ȍ an Array of Objects. I think all classes used by the stub should be supported cos it generated the files itself. – burntblark Oct 26 '11 at 14:48
  • could you please add to your question stack trace of you exception you refer to? – gnat Oct 28 '11 at 09:17
  • I tried getting a stack trace but it prints out "No stack trace" or something close to that. I have resolved to using a RESTful web service i.e. JSR311 – burntblark Oct 29 '11 at 14:16

0 Answers0