errors in server, not in developer

I get error running the smartclient in server, vs. from within developer. The server is run as a localhost off the same copy of servoy. The same problems occur if run on a remote sever. Here is one, can someone point me in the right direction? All I’m doing in this case is updating two global variables, used as a data sources for fields on the form. Neither are date fields, I don’t know why the reference to calendar.

java.lang.NullPointerException
	at net.stuff.servoy.beans.calendar.swing.SwingDateChooser.valueChanged(SwingDateChooser.java:385)
	at com.servoy.j2db.dataprocessing.Zgb.valueChanged(Zgb.java:117)
	at com.servoy.j2db.scripting.Zf.Zc(Zf.java:21)
	at com.servoy.j2db.scripting.Zf.Zb(Zf.java:140)
	at com.servoy.j2db.scripting.Zf.put(Zf.java:145)
	at org.mozilla.javascript.ScriptableObject.putProperty(ScriptableObject.java:1768)
	at org.mozilla.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1532)
	at org.mozilla.javascript.ScriptRuntime.setObjectProp(ScriptRuntime.java:1520)
	at org.mozilla.javascript.gen.c153._c0(calc_cliinfo:440)
	at org.mozilla.javascript.gen.c153.call(calc_cliinfo)
	at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:101)
	at org.mozilla.javascript.gen.c151._c0(on_show_form:170)
	at org.mozilla.javascript.gen.c151.call(on_show_form)
	at com.servoy.j2db.scripting.Ztb.executeFunction(Ztb.java:120)
	at com.servoy.j2db.Zub.Za(Zub.java:638)
	at com.servoy.j2db.Zub.Za(Zub.java:1275)
	at com.servoy.j2db.Zub.ZN(Zub.java:670)
	at com.servoy.j2db.Zub.access$1400(Zub.java:933)
	at com.servoy.j2db.Zxb.run(Zxb.java:2)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.Dialog$1.run(Unknown Source)
	at java.awt.Dialog$3.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.Dialog.show(Unknown Source)
	at java.awt.Component.show(Unknown Source)
	at java.awt.Component.setVisible(Unknown Source)
	at java.awt.Window.setVisible(Unknown Source)
	at java.awt.Dialog.setVisible(Unknown Source)
	at com.servoy.j2db.util.JEscapeDialog.setVisible(JEscapeDialog.java:37)
	at com.servoy.j2db.Zrf.setVisible(Zrf.java:14)
	at com.servoy.j2db.Zcc.Za(Zcc.java:25)
	at com.servoy.j2db.scripting.JSApplication.js_showFormInDialog(JSApplication.java:71)
	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 org.mozilla.javascript.MemberBox.invoke(MemberBox.java:179)
	at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:353)
	at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:81)
	at org.mozilla.javascript.gen.c149._c0(btn_edit:44)
	at org.mozilla.javascript.gen.c149.call(btn_edit)
	at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:387)
	at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3127)
	at org.mozilla.javascript.gen.c149.call(btn_edit)
	at com.servoy.j2db.scripting.Ztb.executeFunction(Ztb.java:120)
	at com.servoy.j2db.Zub.Za(Zub.java:638)
	at com.servoy.j2db.Zub.Za(Zub.java:943)
	at com.servoy.j2db.Zac.Za(Zac.java:3)
	at com.servoy.j2db.ui.BaseEventExecutor.fireEventCommand(BaseEventExecutor.java:16)
	at com.servoy.j2db.ui.BaseEventExecutor.fireEventCommand(BaseEventExecutor.java:60)
	at com.servoy.j2db.ui.BaseEventExecutor.fireActionCommand(BaseEventExecutor.java:6)
	at com.servoy.j2db.dataui.Zh.mouseReleased(Zh.java:3)
	at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)

Hi,

Seems you are using Patrick Talbot’s DateChooser bean. Perhaps this bean doesn’t load correctly ?
Can you check the Servoy log on the server and the Webstart log on the client ?
It would explain that it does work in Developer but not in Client.

Thanks. Yes I am using the bean. But the form loads fine in both developer and server as long as I don’t run a specific piece of code that really doesn’t have anything to do with the bean or the data bound to it. The server log shows pretty much the same error as that reported in the java console, that was in the original message. I tried the last two version of the bean, servoy 5.01 and 5.1 and java 63-bit 1.6.14 and 32 bit 1.6.17

Hi Michael,

So this form has the 2 globals but also other fields ? And one of these fields uses the DateChooser bean?
Does the form have any records when this happends ?
Perhaps you can also post the method that triggers the error.

Thanks Robert. The globals are updated with some calculated values that appear in regular text fields on the form. There are two datetime fields in the table the form is based on, they are the datasources for the two date beans on the form, their value is not changed in any way.

I did some experimenting, any code that changes the value of the globals causes the error in the smart client on the server (btw the web client does not seem to error). So calling this function causes the error:

function calc_cliinfo()
{
	globals.gnclifee = 0
	globals.gccalclipay = ""
        return
}

while this does not:

function calc_cliinfo()
{
        return
	globals.gnclifee = 0
	globals.gccalclipay = ""
}

The form’s foundset is loaded with one record by the calling form:

		forms.c6cal_event.foundset.loadRecords(forms.c6cliapp1x.c6pkey)
		application.closeFormDialog()
		application.showFormInDialog(forms.c6cal_event, -1, -1, -1, -1,'Edit Appt', false, false, false);

Again, this works fine in the developer but in server, the first row of the database always gets loaded, in both smart and webclient. This happens whether or not the date bean error occurs, so I’m not sure if they are related. What a mess!

Are you using 5.1 final?

there is bug with this function: forms.c6cal_event.foundset.loadRecords(forms.c6cliapp1x.c6pkey)

maybe that is related?

Are you using 5.1 final?

there is bug with this function: forms.c6cal_event.foundset.loadRecords(forms.c6cliapp1x.c6pkey)

maybe that is related? so question is, what happens if the loadRecord fails? and there is no data, do you get the nullpointer than also?

Thanks Harjo - yes I think we are on 5.1 final, build 956, I downloaded today. But the same behavior was in 5.0.1. I’m going to investigate what is being loaded, exactly. Is there any easy way to debug code running on a server?

are you also using tableFilerParam?

what you could do is output something after this:

forms.c6cal_event.foundset.loadRecords(forms.c6cliapp1x.c6pkey)

and show than a dialog: foundset.getSize() or the value: forms.c6cliapp1x.c6pkey

That’s what I did, show a dialog with the pkey of the record it’s trying to load if the load fails. Turns out it does fails even thought the key is valid. I supposed this is a bug in server, since it works fine in developer. Now I need to do a workaround. Thanks for you suggestions folks.

So it seems this problem with loadrecords affects my application in numerous places, and it looks like other people as well. On the server, neither loadrecords(pkey) or loadrecords(dataset) seems to work right, but loadrecords(pk query) does (though it’s more cumbersome). Is this something Servoy is working on?

yes loading the pk by a query does work indeed.

we also find out, that setting the pk with a dataset that it works the second/third time

it is already fixed in 5.1.1. and we are also (eagerly) waiting for that release

OK, good to know.

Once again I spent considerable time developing and testing a solution in developer only to find it does not work on server. I guess loadrecords (pk query) doesn’t always work and now I find problems with newrRecord or saveRecord.

This little bit of code is supposed to load a record if one exists, or add one if it doesn’t:

	forms.c6eveditfields1002.foundset.clear()
	var laargs = new Array()
	laargs[0] = globals.gnevent_id
	laargs[1] = globals.gctenant_id
	forms.c6eveditfields1002.foundset.loadRecords("SELECT c6pkey FROM c6cev002 WHERE c6cev002.evtrans_id=? and tenant_id =?",laargs);
	if (globals.gnevent_id != null && forms.c6eveditfields1002.foundset.getSize() == 0)
	{
		forms.c6eveditfields1002.foundset.newRecord(false,true)
		var lnindex = forms.c6eveditfields1002.foundset.getSelectedIndex()
		var loevrec = forms.c6eveditfields1002.foundset.getRecord(lnindex)
		loevrec.evtrans_id = globals.gnevent_id
		databaseManager.saveData(loevrec)
		globals.gnevent_id = 0
	}

This all works fine in developer. In server, it never finds existing records, and when it tries to create a new one, I get this error:

ERROR [RMI TCP Connection(2)-127.0.0.1] com.servoy.j2db.util.Debug - insert into “#TEMP_8432550506” (C6PKEY_8432550508, TRANS_ID_8432550509) SELECT c6pkey FROM c6cev002 WHERE c6cev002.evtrans_id=? parameters: [‘5260’ ,type: java.lang.String]
com.sybase.jdbc3.jdbc.SybSQLException: SQL Anywhere Error -207: Wrong number of values for INSERT

Like it thinks both c6pkey and trans_id are PK’s. Trans_id used to be the pk, but that changed. Maybe Servoy server doesn’t know that. How do I tell it? Why does developer work OK? And is there any reliable way to load records into a form?

Oy.

So the error didn’t occur when it tried to create a new record. Apparently it was trying to insert the pk’s in a temporary table, and for some reason it was creating two columns instead of just the primary pk, but loading only the pk data. Dropping the second column from the table, which was no longer used anyway, resolved the issue. The bigger issue though is inconsistent behavior between developer and server. It used to be one could have confidence that if something worked in developer, it could be deployed on server without error. That’s no longer the case.

Michael,

This sql error will occur when you load records by custom sql and the pk columns do not match the number of columns in the sql.

Servoy will always treat a column as PK when either

  • the column is marked a row_ident in the solution (resources project)
  • the column is marked as PK by the db (as reported by the driver)

Most likely the different behaviour in develop/server is caused by a different data model.

When in the db where you develop against the table has a single PK, the sql with 1 select value will work in developer.
If you then run the same solution in server against another db that has 2 columns marked as pk in its datamodel, Servoy will use them as a composite PK and the select with 1 value will fail.

Since Servoy will not drop columns when a solution is imported in the server, in the scenario that you reduce the set of pk columns of a table you will have to correct this directly in the db.

Hope this explains the issue,

Rob