Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SGWT.mobile - SQL request error not brought on UI

    I am using sql type datasources and executing CRUD operations using the default methods provided by the framework (saveData(), removeData(), ...).

    When executing a CRUD operation that produces an SQL error (e.g. foreign key constraint violation on record deletion, or duplicate entry for unique key, ...), the error generates an exception (see log) that stops the execution on the server side and does not call the DSCallback on the client side. There is therefore no way to handle the error and warn the user about the problem.

    In SGWT (desktop version), SQL errors are catch and reported on the client side with a warning message.

    Here is the log of a tentative to delete a record that cannot be delete because of foreign key constraint. This exception stops execution on the server and the never sends the response to the caller code. No prompt is presented to the user.
    Code:
    === 2013-03-15 12:09:14,857 [l0-4] INFO  RequestContext - URL: '/isomorphic/RESTHandler', User-Agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22': Safari with Accept-Encoding header
    === 2013-03-15 12:09:15,127 [l0-4] DEBUG RestRequestParser - Parsing json object: '{"transactionNum":31,"dataSource":"ui_form_prospects","operationType":"remove","requestId":"31","showPrompt":null,"data":{"id":38}}'
    === 2013-03-15 12:09:15,215 [l0-4] DEBUG RestRequestParser - Parameter:'isc_dataFormat'. Value:'json'.
    === 2013-03-15 12:09:15,586 [l0-4] INFO  RESTHandler - Performing 1 operation(s)
    === 2013-03-15 12:09:15,589 [l0-4] DEBUG DeclarativeSecurity - Processing security checks for DataSource null, field null
    === 2013-03-15 12:09:15,592 [l0-4] DEBUG DeclarativeSecurity - DataSource ui_form_prospects is not in the pre-checked list, processing...
    === 2013-03-15 12:09:15,616 [l0-4] DEBUG AppBase - [builtinApplication.ui_form_prospects_remove] No userTypes defined, allowing anyone access to all operations for this application
    === 2013-03-15 12:09:15,622 [l0-4] DEBUG AppBase - [builtinApplication.ui_form_prospects_remove] No public zero-argument method named '_ui_form_prospects_remove' found, performing generic datasource operation
    === 2013-03-15 12:09:15,722 [l0-4] INFO  SQLDataSource - [builtinApplication.ui_form_prospects_remove] Performing remove operation with
    	criteria: {id:38}	values: {id:38}
    === 2013-03-15 12:09:15,799 [l0-4] DEBUG PoolableSQLConnectionFactory - [builtinApplication.ui_form_prospects_remove] Executing pingTest 'select 1 from dual' on connection 2086393606
    === 2013-03-15 12:09:15,808 [l0-4] DEBUG SQLConnectionManager - [builtinApplication.ui_form_prospects_remove] Returning borrowed connection '2086393606'
    === 2013-03-15 12:09:15,816 [l0-4] DEBUG SQLTransaction - [builtinApplication.ui_form_prospects_remove] Started new Mysql transaction "2086393606"
    === 2013-03-15 12:09:15,821 [l0-4] DEBUG SQLDriver - [builtinApplication.ui_form_prospects_remove] About to execute SQL update in 'Mysql' using connection'2086393606'
    === 2013-03-15 12:09:15,825 [l0-4] INFO  SQLDriver - [builtinApplication.ui_form_prospects_remove] Executing SQL update on 'Mysql': call deleteProspect(38)
    === 2013-03-15 12:09:15,878 [l0-4] DEBUG SQLDriver - [builtinApplication.ui_form_prospects_remove] FAILED to execute SQL update in 'Mysql' using connection'2086393606'
    === 2013-03-15 12:09:15,881 [l0-4] WARN  RequestContext - dsRequest.execute() failed: 
    com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`moon_db`.`_sim_incomes_forecast_detail`, CONSTRAINT `fk-simulations_sfd-id_prospect` FOREIGN KEY (`id_prospect`) REFERENCES `prospects` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    	at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    	at com.mysql.jdbc.Util.getInstance(Util.java:386)
    	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1040)
    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4074)
    	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4006)
    	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2468)
    	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2629)
    	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2719)
    	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
    	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2450)
    	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2371)
    	at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2355)
    	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
    	at com.isomorphic.sql.SQLDriver.doUpdate(SQLDriver.java:750)
    	at com.isomorphic.sql.SQLDriver.update(SQLDriver.java:700)
    	at com.isomorphic.sql.SQLDriver.executeUpdate(SQLDriver.java:824)
    	at com.isomorphic.sql.SQLDataSource.executeNativeUpdate(SQLDataSource.java:419)
    	at com.isomorphic.sql.SQLDataSource.SQLExecute(SQLDataSource.java:1464)
    	at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:306)
    	at com.isomorphic.sql.SQLDataSource.executeRemove(SQLDataSource.java:262)
    	at com.isomorphic.datasource.DataSource.execute(DataSource.java:1377)
    	at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:726)
    	at com.isomorphic.application.AppBase.executeAppOperation(AppBase.java:658)
    	at com.isomorphic.application.AppBase.execute(AppBase.java:491)
    	at com.isomorphic.datasource.DSRequest.execute(DSRequest.java:2017)
    	at com.isomorphic.servlet.RESTHandler.handleDSRequest(RESTHandler.java:341)
    	at com.isomorphic.servlet.RESTHandler.processRequest(RESTHandler.java:319)
    	at com.isomorphic.servlet.RESTHandler.doPost(RESTHandler.java:259)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
    	at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259)
    	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
    	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
    	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
    	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
    	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
    	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    	at org.mortbay.jetty.Server.handle(Server.java:324)
    	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
    	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
    	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
    	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    === 2013-03-15 12:09:15,988 [l0-4] DEBUG RPCManager - Content type for RPC transaction: text/html; charset=UTF-8
    === 2013-03-15 12:09:15,993 [l0-4] DEBUG SQLTransaction - Rolling back Mysql transaction "2086393606"
    === 2013-03-15 12:09:16,204 [l0-4] DEBUG RPCManager - non-DMI response, dropExtraFields: false
    === 2013-03-15 12:09:16,269 [l0-4] DEBUG SQLTransaction - Returning transactional connection for Mysql with hashcode "2086393606"
    === 2013-03-15 12:09:16,270 [l0-4] DEBUG SQLTransaction - Ending Mysql transaction "2086393606"
    === 2013-03-15 12:09:16,272 [l0-4] DEBUG SQLConnectionManager - About to close PoolableConnection with hashcode "2086393606"
    === 2013-03-15 12:09:16,274 [l0-4] DEBUG PoolableSQLConnectionFactory - Executing pingTest 'select 1 from dual' on connection 2086393606
    Last edited by bda@n-side.com; 15 Mar 2013, 03:15.

    #2
    Thanks for pointing this out. We've added approximate parity to normal SmartGWT here: the default for an unrecoverable error is to show a Dialog with the error message, and there is the ability to add an error handler on RPCManager to customize this.

    Comment


      #3
      Thanks for fixing it!

      Comment

      Working...
      X