You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Wan Agus <br...@akewan.com> on 2007/05/01 07:28:52 UTC

File upload + ModelService.ERROR_MESSAGE_LIST = ClassCastException

Hi all,

We're getting a ClassCastException from our simple screen that lets the 
users upload files to the server.    We're using the Form xml to render 
the screen:

    <form name="UploadFiles" type="upload" target="uploadFiles" 
title="Upload Files">
        <field  name="fileContent" title="Select File"><file/></field>     
        <field.... other fields>
        <field name="submitButton" title="Upload Start" 
widget-style="smallSubmit"><submit button-type="button"/></field>
    </form>

We're reusing opentaps' main-financial-decorator as the screen layoug.   
The controller.xml mapping:

    <request-map uri="uploadFiles">
        <security https="true" auth="true"/>
        <event type="service" invoke="uploadFiles" />    
        <response name="success" type="view" value="uploadFiles"/>
        <response name="error" type="view" value="uploadFiles"/>
    </request-map>

inside the uploadFiles service, towards the end of the method, we have this:

        if (errMessage.size() > 0)  {
            results.put(ModelService.ERROR_MESSAGE_LIST, errMessage);
            results.put(ModelService.RESPONSE_MESSAGE, 
ModelService.RESPOND_ERROR);
        }

        return results;

So far, it's all pretty standard stuff.  However, when errMessage is not 
empty, the error messages will get rendered, and here's the exception 
thrown:

java.lang.Exception: Error rendering screen 
[component://lulu-financials/widget/lulu-financials/screens/common/CommonScreens.xml#main-financials-decorator]: 
java.lang.ClassCastException
org.ofbiz.entity.transaction.TransactionUtil.setRollbackOnly(TransactionUtil.java:287)
org.ofbiz.entity.transaction.TransactionUtil.rollback(TransactionUtil.java:237)
org.ofbiz.widget.screen.ModelScreen.renderScreenString(ModelScreen.java:150)
org.ofbiz.widget.screen.ModelScreenWidget$DecoratorScreen.renderWidgetString(ModelScreenWidget.java:500)
org.ofbiz.widget.screen.ModelScreenWidget.renderSubWidgetsString(ModelScreenWidget.java:161)
org.ofbiz.widget.screen.ModelScreenWidget$Section.renderWidgetString(ModelScreenWidget.java:254)

If we comment out the line that sets the ModelService.ERROR_MESSAGE_LIST 
in result, then we don't get the exception.  Now, if we leave the line 
alone, but didn't upload a file (fill the other fields, and hit submit), 
we don't get the exception here.  I hope this make sense.  Basically, we 
get this ClassCastException if we uploaded a file and set 
ModelService.ERROR_MESSAGE_LIST in the result.

We're using opentaps 0.9.3 right now.  If you have any ideas, we'd be 
ecstatic to hear it.  I know there's probably not enough information in 
this post to diagnose the issue.  If that's the case, I can post more 
part of the code here.

thanks,
wan