Announcement

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

    NullPointer Exception is DS server object

    I am seeing some unexpected NPE coming from SmartClient Version: v8.2p_2012-05-21/Enterprise Deployment (built 2012-05-21). I basically have 2 data-bound grids. When I move (drag-n-drop) records from left to right the first time, all is fine. Then I delete the dropped record, but when I try to add it again, I get the NPE. The data is in MS SQL server.


    Code:
    INFO: === 2013-03-07 16:37:23,118 [0(4)] INFO  SQLDataSource - [builtinApplication.job_share_add] Performing add operation with
    	criteria: {ldap_uid:"00000655",rowID:1,email:"dbuick@XXX.XXX",created_on:new Date(1359158582000),employee_type:"emp",full_name:"Douglas X",job_id:"49"}	
    values: {ldap_uid:"00000655",rowID:1,email:"dbuick@XXX.XXX",created_on:new Date(1359158582000),employee_type:"emp",full_name:"Douglas X",job_id:49}
    
    INFO: === 2013-03-07 16:37:23,118 [0(4)] INFO  SQLValuesClause - [builtinApplication.job_share_add] Ignored data for non-existent or included columns: [rowID, email, created_on, employee_type, full_name]
    
    INFO: === 2013-03-07 16:37:23,119 [0(4)] DEBUG SQLValuesClause - [builtinApplication.job_share_add] Sequences: {job_share_id=__default}
    
    INFO: === 2013-03-07 16:37:23,121 [0(4)] DEBUG PoolableSQLConnectionFactory - [builtinApplication.job_share_add] Returning unpooled Connection
    
    INFO: === 2013-03-07 16:37:23,174 [0(4)] DEBUG SQLTransaction - [builtinApplication.job_share_add] Started new ilob transaction "1051563352"
    
    INFO: === 2013-03-07 16:37:23,174 [0(4)] INFO  SQLDriver - [builtinApplication.job_share_add] Executing SQL update on 'ilob': INSERT INTO batch_job_share (job_id, ldap_uid) VALUES (49, '00000655')
    
    INFO: === 2013-03-07 16:37:23,227 [0(4)] WARN  SQLDriver - [builtinApplication.job_share_add] Exception thrown during saveGeneratedKeys()
    java.sql.SQLException: Connection closed
    	at com.sun.gjc.spi.base.ConnectionHolder.checkValidity(ConnectionHolder.java:730)
    	at com.sun.gjc.spi.base.ConnectionHolder.getMetaData(ConnectionHolder.java:344)
    	at com.sun.gjc.spi.jdbc40.ConnectionWrapper40.getMetaData(ConnectionWrapper40.java:114)
    	at com.isomorphic.sql.SQLDriver.supportsGetGeneratedKeys(SQLDriver.java:1144)
    	at com.isomorphic.sql.SQLServerDriver.saveGeneratedKeys(SQLServerDriver.java:255)
    	at com.isomorphic.sql.SQLDriver.doUpdate(SQLDriver.java:539)
    	at com.isomorphic.sql.SQLDriver.update(SQLDriver.java:482)
    	at com.isomorphic.sql.SQLDriver.executeUpdate(SQLDriver.java:604)
    	at com.isomorphic.sql.SQLDataSource.executeNativeUpdate(SQLDataSource.java:403)
    	at com.isomorphic.sql.SQLDataSource.SQLExecute(SQLDataSource.java:1388)
    	at com.isomorphic.sql.SQLDataSource.processRequest(SQLDataSource.java:293)
    	at com.isomorphic.sql.SQLDataSource.executeAdd(SQLDataSource.java:245)
    	at com.isomorphic.datasource.DataSource.execute(DataSource.java:1291)
    	at com.isomorphic.application.AppBase.executeDefaultDSOperation(AppBase.java:725)
    	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:1954)
    	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:199)
    	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156)
    	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
    	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
    	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
    	...
    
    INFO: === 2013-03-07 16:37:23,228 [0(4)] DEBUG SQLDataSource - [builtinApplication.job_share_add] add operation affected 1 rows
    
    INFO: === 2013-03-07 16:37:23,228 [0(4)] INFO  SQLDriver - [builtinApplication.job_share_add] Executing SQL query on 'ilob': SELECT SCOPE_IDENTITY()
    
    INFO: === 2013-03-07 16:37:23,280 [0(4)] WARN  RequestContext - dsRequest.execute() failed: 
    java.lang.NullPointerException
    	at com.isomorphic.servlet.IDACall.handleDSRequest(IDACall.java:212)
    	at com.isomorphic.servlet.IDACall.processRPCTransaction(IDACall.java:156)
    	at com.isomorphic.servlet.IDACall.processRequest(IDACall.java:121)
    	at com.isomorphic.servlet.IDACall.doPost(IDACall.java:73)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
    	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
    	...
    
    INFO: === 2013-03-07 16:37:23,281 [0(4)] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
    
    INFO: === 2013-03-07 16:37:23,282 [0(4)] DEBUG SQLTransaction - Rolling back ilob transaction "1051563352"
    
    
    INFO: === 2013-03-07 16:37:23,333 [0(4)] DEBUG DataSource - In DS.forName() for 'job_share' with DSRequest: com.isomorphic.datasource.DSRequest@60d114d0
    
    INFO: === 2013-03-07 16:37:23,334 [0(4)] DEBUG DataSource - Creating instance of DataSource 'job_share'
    
    INFO: === 2013-03-07 16:37:23,334 [0(4)] DEBUG DataSource - In DS.forName() for 'ldap_lookup' with DSRequest: null
    
    INFO: === 2013-03-07 16:37:23,335 [0(4)] DEBUG DataSource - Creating instance of DataSource 'ldap_lookup'
    
    INFO: === 2013-03-07 16:37:23,336 [0(4)] DEBUG RPCManager - non-DMI response, dropExtraFields: false
    
    INFO: === 2013-03-07 16:37:23,337 [0(4)] DEBUG SQLTransaction - Ending ilob transaction "1051563352"

    Here is the DS definition:

    Code:
    <DataSource
        ID="job_share"
        serverType="sql"
        tableName="batch_job_share"   
    >
    
        <fields>
    	     <field name="job_share_id" primaryKey="true" type="sequence" hidden="true" title="ID" />
    	     <field name="ldap_uid"    type="text"      foreignKey="ldap_lookup.ldap_uid" title="UID" />
    	     <field includeFrom="ldap_lookup.full_name"  />
    	     <field name="job_id"                         type="integer"   hidden="true" title="Job ID" />
    	     <field name="notify_by_email"                type="boolean"    canEdit="true" title="Email?" sqlStorageStrategy="number" sqlFalseValue="0" />	     
    	 </fields>
        
        <operationBindings>
    		<operationBinding operationType="fetch">
    		    <whereClause>($defaultWhereClause) #if($criteria.job_id)  AND job_id= $criteria.job_id #end </whereClause>
    		</operationBinding>
    	</operationBindings>
        
    </DataSource>
    An this is the relvant Java code:
    Code:
    final private FetchDataHandler jobIdCriteriaAdder = new FetchDataHandler(){
    
    			@Override
    			public void onFilterData(FetchDataEvent event) {
    				addJobIdCriteria(event.getCriteria());			
    			}
          	
          };
    ...
    //Share results with 
    	  final private ListGrid shareWithGrid= new ListGrid(){{
    				  setWidth("40%");  
    			      setHeight100();    
    			     // setBorder("0px solid white");  
    			      
    			      setCanAcceptDroppedRecords(true);  
    			      setCanRemoveRecords(true);   
    			      setPreventDuplicates(true);
    			      setDragDataAction(DragDataAction.COPY);
    
    			      setAutoFetchData(false);
    			      
    			      setDataSource(DataSource.get("job_share"));
    			      
    			      setFields(
    			          new ListGridField("job_share_id","ID"){{ setHidden(true); setCanEdit(false); }},
    			    	  new ListGridField("ldap_uid","UID"){{setWidth("50%"); setCanEdit(false);}},
    					  new ListGridField("full_name","Name"){{setWidth("100%"); setCanEdit(false);}},
    				      new ListGridField("notify_by_email","Notify?"){{setWidth("40%"); setType(ListGridFieldType.BOOLEAN); setCanEdit(true); }}					  
    			      );
    			      
    			      addFetchDataHandler(jobIdCriteriaAdder);
    			      			    
    		}};
    Last edited by hstoyanov; 7 Mar 2013, 16:57.

    #2
    Best guess, this is an application server or JDBC driver bug or misconfiguration at the JDBC driver or application server level, hence out of our control.

    What's happening is: we successfully execute your SQL ("INSERT INTO batch_job_share...") using PreparedStatement.executeUpdate(). Then, a few lines later, using the same preparedStatement object, we are calling preparedStatement.getConnection().getMetaData().

    At this point, your JDBC driver - well actually, some wrapper around it, looks like a manager class from Glassfish? - throws an Exception indicating the connection we just successfully used for an update is now closed. So it seems like it's either configured to auto-close connections right after certain SQL operations are executed, or your JDBC driver has some kind of bug where it get mixed up about which Connection belongs with which Statement, or the wrapper classes in use are not correctly tracking the open/closed state of the wrapped connections.

    Comment


      #3
      Thanks ,
      It does sound like GlassFish bug:

      http://java.net/jira/browse/GLASSFISH-19475

      Comment

      Working...
      X