Hi Isomorphic,
I'm starting to use BatchUploader in current 4.1p (v9.1p_2015-02-07) and hit a short and unmeaningful exception in serverside BU code.
I'm getting the following error in the client UI:
SmartGWT Warning window with just the text "charsetName".
Tomcat server logs are (see screenshots for client-request):
I used different files as test (included, renamed to .txt for the forum):
This client code inside a Window:
No special server code. I copied and sc/DataSourceLoader-loaded batchUpload.ds.xml as suggested in the docs.
This is my simple testing target .ds.xml:
Referenced V_LEADUPLOAD serverObject is just return request.execute():
LMSIDACall.java should not be responsible:
Do you have an idea what is causing this exception with no good error message? Is it possible that this is a bug? I did not find anything related to "charset" or "encoding" in the BatchUploader-docs. I'll try to experiment with batchUploader.setDataURL() as in the sample now, but I think the error is somewhere before.
Thank you & Best regards,
Blama
I'm starting to use BatchUploader in current 4.1p (v9.1p_2015-02-07) and hit a short and unmeaningful exception in serverside BU code.
I'm getting the following error in the client UI:
SmartGWT Warning window with just the text "charsetName".
Tomcat server logs are (see screenshots for client-request):
Code:
=== 2015-02-13 11:11:04,627 [ec-5] INFO RequestContext - URL: '/lms/lms/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0': Moz (Gecko) with Accept-Encoding header === 2015-02-13 11:11:04,630 [c-31] INFO RequestContext - URL: '/lms/lms/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0': Moz (Gecko) with Accept-Encoding header === 2015-02-13 11:11:04,630 [ec-5] DEBUG RPCManager - Processing 1 requests. === 2015-02-13 11:11:04,630 [ec-5] DEBUG RPCManager - Request #1 (RPCRequest) data: { appID:"isc_builtin", className:"com.isomorphic.tools.BuiltinRPC", methodName:"setAttributes", arguments:[ "session", [ { name:"dsName", type:"hidden", value:"V_LEADUPLOAD" }, { name:"delimiter", type:"hidden", value:"," }, { name:"quoteString", type:"hidden", value:"\"" } ], null ], is_ISC_RPC_DMI:true } === 2015-02-13 11:11:04,630 [ec-5] INFO LMSIDACall - Performing 1 operation(s) === 2015-02-13 11:11:04,630 [ec-5] DEBUG RPCDMI - appConfig: isc.Application.create({ rpcBindings:[ { ID:"builtin", className:"com.isomorphic.rpc.BuiltinRPC", visibleMethods:[ { name:"downloadWSDL" }, { name:"downloadClientContent" }, { name:"downloadClientExport" }, { name:"xmlToJS" }, { name:"uploadProgressCheck" }, { name:"saveFile" }, { name:"appendToFile" }, { name:"loadFile" }, { name:"deleteFile" }, { name:"loadSharedXML" }, { name:"saveSharedXML" }, { name:"getAvailableScriptEngines" }, { name:"devConsoleEvalServerScript" }, { name:"evalJava" }, { name:"getLogNames" }, { name:"getLogEntries" }, { name:"clearLogEntries" }, { name:"getLogThresholds" }, { name:"setLogThreshold" }, { name:"setTemporaryLogThreshold" }, { name:"revertTemporaryLogThresholds" }, { name:"getPdfObject" }, { name:"exportImage" }, { name:"areServerTimingsTracked" }, { name:"trackServerTimings" } ] }, { ID:"builtin_tools", className:"com.isomorphic.tools.BuiltinRPC", visibleMethods:[ { name:"getDataSourceFromTable" }, { name:"getDataSourceJSONFromTable" }, { name:"getDataSourceFromHibernateMapping" }, { name:"getDataSourceJSONFromHibernateMapping" }, { name:"getTables" }, { name:"getFieldsFromTable" }, { name:"getBeanFields" }, { name:"getHibernateBeans" }, { name:"getDatabaseProductNameAndVersion" }, { name:"getDatabaseTableTypes" }, { name:"setAttributes" }, { name:"clearAttributes" }, { name:"getAttributes" }, { name:"getAttribute" }, { name:"getDataSourceConfigFromJavaClass" }, { args:"cName", language:"groovy", name:"getJavaSource", script:"\n if (!com.isomorphic.auth.DevModeAuthFilter.devModeAuthorized(request)) throw new Exception(\"Not Authorized\"); \n //import org.apache.bcel.Repository;\n\n try {\n return org.apache.bcel.Repository.lookupClass(cName).toString();\n } catch (Throwable e) {\n return \"Unable to reverse engineer class \"+cName+\": \"+e.getMessage();\n }\n " }, { name:"loadDataSource" }, { name:"dsFromXML" }, { name:"dsConfigFromXML" }, { name:"getDefinedDataSources" } ] }, { ID:"builtin_adminconsole", className:"com.isomorphic.tools.AdminConsole", visibleMethods:[ { name:"getDefinedDatabases" }, { name:"testDB" }, { name:"saveDBConfig" }, { name:"setDefaultDB" }, { name:"importDataSources" }, { name:"discoverJNDIDatabases" } ] } ] }) === 2015-02-13 11:11:04,630 [ec-5] DEBUG RPCDMI - rpc returned data === 2015-02-13 11:11:04,630 [ec-5] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8 === 2015-02-13 11:11:04,630 [ec-5] INFO Compression - /lms/lms/sc/IDACall: 67 -> 73 bytes === 2015-02-13 11:11:04,646 [c-31] DEBUG RPCManager - Processing 1 requests. === 2015-02-13 11:11:04,646 [c-31] DEBUG RPCManager - Request #1 (DSRequest) payload: { criteria:{ }, values:{ file:"lead2.csv", dsName:"V_LEADUPLOAD", delimiter:",", quoteString:"\"", _transaction:null }, operationConfig:{ dataSource:"batchUpload", repo:null, operationType:"update", textMatchStyle:"exact" }, componentId:"isc_DynamicForm_0", appID:"builtinApplication", operation:"upload", oldValues:{ dsName:"V_LEADUPLOAD", delimiter:",", quoteString:"\"" } } === 2015-02-13 11:11:04,646 [c-31] INFO LMSIDACall - Performing 1 operation(s) === 2015-02-13 11:11:04,646 [c-31] DEBUG DataSourceDMI - Invocation threw exception java.lang.NullPointerException: charsetName at java.io.InputStreamReader.<init>(Unknown Source) at com.isomorphic.tools.BatchUpload.batchUpload(BatchUpload.java:124) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:975) at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:416) at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:64) at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2531) at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:215) at com.lmscompany.lms.server.LMSIDACall.handleDSRequest(LMSIDACall.java:57) at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:172) at com.lmscompany.lms.server.LMSIDACall.processRequest(LMSIDACall.java:39) at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73) at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:260) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:611) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) === 2015-02-13 11:11:04,646 [c-31] WARN RequestContext - dsRequest.execute() failed: java.lang.NullPointerException: charsetName at java.io.InputStreamReader.<init>(Unknown Source) at com.isomorphic.tools.BatchUpload.batchUpload(BatchUpload.java:124) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.isomorphic.base.Reflection.adaptArgsAndInvoke(Reflection.java:975) at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:416) at com.isomorphic.datasource.DataSourceDMI.execute(DataSourceDMI.java:64) at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2531) at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:215) at com.lmscompany.lms.server.LMSIDACall.handleDSRequest(LMSIDACall.java:57) at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:172) at com.lmscompany.lms.server.LMSIDACall.processRequest(LMSIDACall.java:39) at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73) at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:260) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:611) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:409) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1044) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) === 2015-02-13 11:11:04,646 [c-31] DEBUG RPCManager - Content type for RPC transaction: text/html; charset=UTF-8 === 2015-02-13 11:11:04,646 [c-31] DEBUG RPCManager - non-DMI response, dropExtraFields: false === 2015-02-13 11:11:04,646 [c-31] INFO Compression - /lms/lms/sc/IDACall: 656 -> 409 bytes
- Your sample supplyItemTest.csv (UTF8 w/o BOM, Unix line endings)
- Own lead.csv (UTF8 w/o BOM, Dos/Windows line endings) (only "normal"-ANSI characters inside)
- Own lead.csv (ANSI, Dos/Windows line endings)
This client code inside a Window:
Code:
batchUploader = new BatchUploader(); batchUploader.setWidth(600); batchUploader.setUploadDataSource(leadUploadDS); TextItem stringValue = new TextItem("stringValue", "String Value"); IntegerItem numberValue = new IntegerItem(); numberValue.setName("numericValue"); numberValue.setTitle("Numeric Value"); batchUploader.setUploadFormItems(stringValue, numberValue); addItem(batchUploader);
This is my simple testing target .ds.xml:
Code:
<DataSource dbName="Oracle" tableName="T_LEAD" ID="V_LEADUPLOAD" serverType="sql" serverConstructor="com.lmscompany.lms.server.LMSSQLDataSource"> <fields> <field primaryKey="true" hidden="true" name="ID" type="sequence"/> <field hidden="true" name="TENANT_ID" type="integer" canEdit="false" /> <field foreignKey="V_USER_CREATED_BY.ID" relatedTableAlias="USER_CREATED_BY" name="CREATED_BY" title="Erstellt von" type="creator" /> <field name="CREATED_AT" title="Erstellt am" type="creatorTimestamp" /> <field foreignKey="T_CAMPAIGN.ID" name="CAMPAIGN_ID" displayField="CAMPAIGN_NAME" title="Kampagne" type="integer" required="true" /> <field includeFrom="T_CAMPAIGN.NAME" name="CAMPAIGN_NAME" hidden="true" /> <field foreignKey="T_LEADTEMPERATURE.ID" name="LEADTEMPERATURE_ID" displayField="LEADTEMPERATURE_NAME" title="Leadtemperature" type="integer" required="true" /> <field includeFrom="T_LEADTEMPERATURE.NAME" name="LEADTEMPERATURE_NAME" hidden="true" /> <field foreignKey="T_LEADTYPE.ID" name="LEADTYPE_ID" displayField="LEADTYPE_NAME" title="Leadtyp" type="integer" joinType="outer" /> <field includeFrom="T_LEADTYPE.NAME" name="LEADTYPE_NAME" hidden="true" /> <field name="POTREV_RESELLER" title="Gesamtprojekt netto (geschätzt)" type="integer"> <validators> <validator type="integerRange" min="1" errorMessage="Bitte geben Sie einen Betrag größer Null ein." /> </validators> </field> </fields> <serverObject lookupStyle="new" className="com.lmscompany.lms.server.worker.V_LEADUPLOAD" /> <operationBindings> <operationBinding operationType="add" requiresRole="addLead, addLeadByMail"> </operationBinding> </operationBindings> </DataSource>
Code:
public class V_LEADUPLOAD { // requiresRole="addLead, addLeadByMail" in ds.xml public DSResponse add(DSRequest request, HttpServletRequest servletRequest) throws Exception { DSResponse response = request.execute(); return response; } };
Code:
package com.lmscompany.lms.server; import java.io.IOException; import java.util.Arrays; import java.util.LinkedList; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.isomorphic.datasource.BasicDataSource; import com.isomorphic.datasource.DSRequest; import com.isomorphic.datasource.DSResponse; import com.isomorphic.rpc.RPCManager; import com.isomorphic.servlet.IDACall; import com.isomorphic.servlet.RequestContext; import com.lmscompany.lms.server.util.User; public class LMSIDACall extends IDACall { private static final long serialVersionUID = 4543651445782711736L; /* * See http://www.smartclient.com/smartgwtee/javadoc/com/smartgwt/client/docs/serverds/OperationBinding.html#requiresRole */ @Override public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Long userId = User.getUserId(request); if (userId != null) { try { RequestContext context = RequestContext.instance(this, request, response); RPCManager rpc = new RPCManager(request, response); rpc.setUserId(userId.toString()); // rpc.setAuthenticated(true); // rpc.setUserRoles((String) roles); // call processRPCTransaction() to iterate through all RPCRequests and // DSRequests and execute them processRPCTransaction(rpc, context); } catch (Throwable e) { handleError(response, e); } } else { super.processRequest(request, response); } } @Override public DSResponse handleDSRequest(DSRequest dsRequest, RPCManager rpc, RequestContext context) throws Exception { String allowedClientOperationTypesProperty = ((BasicDataSource) dsRequest.getDataSource()).getProperty("allowedClientOperationTypes"); if (allowedClientOperationTypesProperty != null) { List<String> allowedClientOperationTypesList = new LinkedList<String>(Arrays.asList(allowedClientOperationTypesProperty.split(" "))); if (!allowedClientOperationTypesList.contains(dsRequest.getOperationType())) return new DSResponse().setDataSource(dsRequest.getDataSource()).setFailure("OperationType not allowed"); } return super.handleDSRequest(dsRequest, rpc, context); } }
Thank you & Best regards,
Blama
Comment