I am using SmartGWT 3.1-P20130714.
I am using FileItem to upload files.
Here is my code that sets up FileItem
Here is the code I used to do the upload:
Here is the data source XML file used in the upload:
This code successfully creates a row in the database that can be read both on the client and server side.
On the server side, using Hibernate, I can read the row. However, I cannot read the blob in the row. Hibernate returns a null value for the blob field.
After restarting the server the file content blob can be read with Hibernate on the server.
An additional symptom is that after doing the upload MySQL will shut down access to our server after 10 hours. This is because the MySQL I’m using has a ten hour time limit on open sessions.
Of course, I don’t know what may be the issue causing this problem. However, my theory is that the Isomorphic code is committing the creation of the row that contains the upload meta data (e.g. UploadedFile_filename, UploadedFile_filesize) but it is not committing the writing of the blob that contains the content of the file. Additionally, I believe the session used to write the blob is left open leaving a permanent connection to the MySQL database.
The server restart causes this commit to happen and releases the database connection causing the blob to become available.
I’m also wondering if there is something I need to do after the upload completes to force the commit of the file content blob on the server side.
This is a side note: I have been using this upload code successfully for several months and never noticed the missing file content blob problem. This was because I frequently restarted the server as part of development and testing. However, now that we have deployed this to our production server this problem has been exposed. It's stopping our production server from functioning properly and causes us to need to restart the server after every upload.
I am using FileItem to upload files.
Here is my code that sets up FileItem
Code:
final FileItem upload = new FileItem(Schema.DSF_UPLOADEDFILE); upload.setTitle(Constants.BROWSE_TAXONOMY_OR_CONTACTLIST); upload.setEndRow(true); RegExpValidator regExpValidator = new RegExpValidator(); regExpValidator.setExpression(Constants.FILE_NAME_VALIDATION); regExpValidator.setErrorMessage(ErrorMessages.NOT_XLSX); upload.setValidators(regExpValidator); upload.setValidateOnChange(true);
Code:
uploadForm.saveData(new DSCallback() { @Override public void execute(DSResponse response, Object rawData, DSRequest request) { uploadForm.clearValues(); uploadList.getUploadList().refresh(); } });
Code:
<DataSource dbName="Mysql" tableName="uploads" ID="uploads" dataSourceVersion="1" generatedBy="v8.3p_2013-02-26/EVAL Deployment 2013-02-26" serverType="sql" > <fields> <field name="ID" title="ID" type="sequence" hidden="true" primaryKey="true" /> <field name="AccountID" title="Account ID" type="integer" hidden="true" foreignKey="accounts.ID"/> <field name="Name" title="Name" type="text" length="45" hidden="false" /> <field name="Type" title="Type" type="text" length="20" hidden="true" /> <field name="UploadedFile" title="Uploaded File" type="binary" hidden="true" /> <field name="UploadedFile_filename" title="File Name" type="text" length="255" hidden="false" /> <field name="UploadedFile_filesize" title="Size" type="integer" hidden="false" /> <field name="UploadedFile_date_created" title="Date Created" type="datetime" hidden="false" /> </fields> </DataSource>
On the server side, using Hibernate, I can read the row. However, I cannot read the blob in the row. Hibernate returns a null value for the blob field.
After restarting the server the file content blob can be read with Hibernate on the server.
An additional symptom is that after doing the upload MySQL will shut down access to our server after 10 hours. This is because the MySQL I’m using has a ten hour time limit on open sessions.
Of course, I don’t know what may be the issue causing this problem. However, my theory is that the Isomorphic code is committing the creation of the row that contains the upload meta data (e.g. UploadedFile_filename, UploadedFile_filesize) but it is not committing the writing of the blob that contains the content of the file. Additionally, I believe the session used to write the blob is left open leaving a permanent connection to the MySQL database.
The server restart causes this commit to happen and releases the database connection causing the blob to become available.
I’m also wondering if there is something I need to do after the upload completes to force the commit of the file content blob on the server side.
This is a side note: I have been using this upload code successfully for several months and never noticed the missing file content blob problem. This was because I frequently restarted the server as part of development and testing. However, now that we have deployed this to our production server this problem has been exposed. It's stopping our production server from functioning properly and causes us to need to restart the server after every upload.
Comment