J2ME 存根生成 JPA 实体类型的未知异常

发布于 2024-12-12 07:12:56 字数 1665 浏览 3 评论 0原文

我使用 NetBeans 7.0 创建了一个 Web 服务存根,当我尝试使用它时,它抛出一个未知异常。我什至不知道要在此处显示代码的哪一部分,我所知道的是粗体线会生成未知的异常:

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;
}`

我尝试使用 Web 应用程序使用相同的 Web 服务,并且它运行得很好。我对导致此异常的原因一无所知。任何评论将不胜感激。

更新

我尝试了返回字符串数据类型的其他服务,它工作正常。所以我认为 J2ME 可能存在 JPA 实体类型问题。

所以我的问题是如何正确返回数据以便J2ME客户端可以很好地读取

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文