Go Back   SmartClient Forums > Smart GWT Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 6th Aug 2010, 05:17
jcollery jcollery is offline
Registered Developer
 
Join Date: Jul 2010
Posts: 4
Default fetchData(criteria) causing null pointer exception

Hi,

I am using SmartGWTPower 2.3 with SmartClient 7.0 Power Edition. I am trying to create a simple login procedure and eventually I would like to call a custom operation on the server for user authentication. The problem is when I call fetchData against my data source with any arguments I get a null pointer exception. If I call a pure fetchData with no arguments I get no error. I'm not getting much from the console to point me in the right direction. Here is what I am doing:

Client code:
Code:
package t1.client;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.PasswordItem;
import com.smartgwt.client.widgets.form.fields.TextItem;


public class login implements EntryPoint {

	@Override
	public void onModuleLoad() {

		final Window winModal = new Window();  
		winModal.setWidth(360);  
		winModal.setHeight(115);  
		winModal.setTitle("SmartClient Login");  
		winModal.setShowMinimizeButton(false);  
		winModal.setIsModal(true);  
		winModal.setShowModalMask(true);  
		winModal.centerInPage();  		
		DynamicForm form = new DynamicForm();  
		form.setHeight100();  
		form.setWidth100();  
		form.setPadding(5);  
		form.setLayoutAlign(VerticalAlignment.BOTTOM);  
		final TextItem userName = new TextItem();  
		final PasswordItem password = new PasswordItem();
		userName.setTitle("Username");
		password.setTitle("Password");
		IButton blogin = new IButton("Login");
		blogin.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {
				DataSource ds = new DataSource();
				ds = DataSource.get("users");
				Criteria userdata = new Criteria();
				userdata.addCriteria("username", userName.getValue().toString());
				userdata.addCriteria("password", password.getValue().toString());
				ds.fetchData(userdata);
			}
		});
		form.setFields(userName, password);  
		winModal.addItem(form);
		winModal.addItem(blogin);
		winModal.show();  		
		
		
		
	}

}
war/shared/ds/users.ds.xml
Code:
<DataSource ID="users" serverType="sql" tableName="users">

    <fields>
        <field name="userid" type="sequence" title="Patid" hidden="true" primaryKey="true"/>
        <field name="username" type="text" length="32" title="Firstname"/>
        <field name="password" type="text" length="32" title="Lastname"/>
        <field name="firstname" type="text" length="32" title="Address1"/>
    </fields>
<!-- I have the custom operation commented out until I get my exception solved so this is just a vanilla data source
<operationBindings>
<binding operationId="login" operationType="fetch" serverMethod="fetchlogin">
<serverObject lookupStyle="new" className="t1.server.login"/>
</binding>
</operationBindings> -->

    <dataSourceVersion>1</dataSourceVersion>
    <generatedBy>7.0rc2/SDK Development Only 2009-05-30</generatedBy>
</DataSource>
When I click on the login button I get

Code:
"Uncaught exception escaped : com.google.gwt.core.client.JavaScriptException
(null): null
See the Development console log for details.
Register a GWT.setUncaughtExceptionHandler(..) for custom uncaught exception handling."
and the console gives me

Code:
14:17:29.076 [ERROR] [t1] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (null): null
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:284)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
    at com.smartgwt.client.data.DataSource.fetchData(DataSource.java)
    at t1.client.login$1.onClick(login.java:48)
    at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:96)
    at com.smartgwt.client.widgets.events.ClickEvent.dispatch(ClickEvent.java:1)
    at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:65)
    at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:53)
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:178)
    at com.smartgwt.client.widgets.BaseWidget.fireEvent(BaseWidget.java:67)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
    at com.google.gwt.dev.shell.BrowserChannel.reactToMessagesWhileWaitingForReturn(BrowserChannel.java:1714)
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:165)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
    at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1669)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
    at java.lang.Thread.run(Thread.java:636)
It seems such a simple thing, any ideas where I could be going wrong?

Thanks,
Justin
Reply With Quote
  #2  
Old 6th Aug 2010, 05:25
Isomorphic Isomorphic is online now
Administrator
 
Join Date: May 2006
Posts: 37,428
Default

You refer to using "SmartGWTPower 2.3 with SmartClient 7.0 Power Edition". If you mixed two downloaded packages (SmartClient and SmartGWT) you could create a problem like this. Never do this - each package is self-contained.
Reply With Quote
  #3  
Old 6th Aug 2010, 05:55
jcollery jcollery is offline
Registered Developer
 
Join Date: Jul 2010
Posts: 4
Default

Thanks for the quick response Isomorphic.

So I created a new project, only configured it for SmartGWT Power 2.3 and ran the same code. I get exactly the same problem. Any ideas?

Thanks again,
Justin
Reply With Quote
  #4  
Old 6th Aug 2010, 05:57
Isomorphic Isomorphic is online now
Administrator
 
Join Date: May 2006
Posts: 37,428
Default

Given that Power ships with tons of samples that show this API working, you most likely made a mistake during installation. Full instructions for adding to an existing project are here.
Reply With Quote
  #5  
Old 6th Aug 2010, 10:27
jcollery jcollery is offline
Registered Developer
 
Join Date: Jul 2010
Posts: 4
Default

Thanks Isomorphic for the quick info again. I think there is a bug here.

I have tested this configuration on Windows and Linux x64

I downloaded and installed SmartGWT2.3, Eclipse 3.6, Sun JDK 1.6.0_21, and GWT 2.0.4 on both machines.

I imported and configured the sample projects into eclipse as per the instructions

As my test I then run the DataSourceDMI project

On windows the project compiles and runs perfectly, however on Ubuntu 10.04 x64 I get the error described above.
Reply With Quote
  #6  
Old 6th Aug 2010, 10:33
Isomorphic Isomorphic is online now
Administrator
 
Join Date: May 2006
Posts: 37,428
Default

Try deploying the included showcase.war directly to a Tomcat on Ubuntu and trying a few of the samples that call fetchData() (eg, SQL -> Dynamic Reporting). If there's no issue with that, it indicates either a corrupted project or a bug somewhere in the toolchain - your IDE or the GWT compiler.
Reply With Quote
  #7  
Old 6th Aug 2010, 12:38
jcollery jcollery is offline
Registered Developer
 
Join Date: Jul 2010
Posts: 4
Default

Interesting!

When I deploy the showcase.war on Ubuntu x64 it works perfectly.

Then I use the build.xml file from the DataSourceDMI project to build the project and deploy it on a Tomcat server on my Ubuntu box and it also works perfectly.

The only time it does not work perfectly is when running in dev mode in eclipse, something up with the web server there obviously
Reply With Quote
  #8  
Old 15th Dec 2010, 10:30
micsky micsky is offline
Registered Developer
 
Join Date: Nov 2010
Posts: 45
Default

I also experience the same problem in just DEVMODE
Windows x64
SmartGWT 2.3 (nightly: 12/15/2010)

Note: DataSource.fetchData(Criteria) works just fine, it's when ListGrid.fetchData(Criteria) is called that NPE is thrown.

Does anyone know if there is a fix to DEVMODE? ...as I'd hate to have to build out in order to test.
Reply With Quote
  #9  
Old 15th Dec 2010, 11:14
micsky micsky is offline
Registered Developer
 
Join Date: Nov 2010
Posts: 45
Default

Workaround so I could use DevMode was to do something like this

Code:
        Criteria criteria = new Criteria();
        criteria.addCriteria("batchId", batchId);
        dataSource.fetchData(criteria, new DSCallback() {
            public void execute(DSResponse response, Object rawData, DSRequest request) {
                listGrid.setData(response.getData());
            }
        });
Anyone at Isomorphic think of any reasons why I *should not* leave it this way?
Reply With Quote
  #10  
Old 15th Dec 2010, 12:03
smartgwt.dev smartgwt.dev is offline
Registered Developer
 
Join Date: Nov 2008
Posts: 1,091
Default

Quote:
Originally Posted by micsky
I also experience the same problem in just DEVMODE
Windows x64
SmartGWT 2.3 (nightly: 12/15/2010)

Note: DataSource.fetchData(Criteria) works just fine, it's when ListGrid.fetchData(Criteria) is called that NPE is thrown.

Does anyone know if there is a fix to DEVMODE? ...as I'd hate to have to build out in order to test.
Please post the stacktrace of the exception. Based on the code a NPE should not occur.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


© 2010,2011 Isomorphic Software. All Rights Reserved