Wrapped java.lang.ArrayIndexOutOfBoundsException

Questions, tips and tricks and techniques for scripting in Servoy

Wrapped java.lang.ArrayIndexOutOfBoundsException

Postby mboegem » Fri Oct 02, 2009 8:44 am

Sometimes I get an ArrayIndexOutOfBounds exception which outputs the quoted error in the java console

I've been looking at line 19 of this method, but there's nothing around there which point to an array.
Does anyone have a clue? The code is below as well...

Thnkx a lot!

org.mozilla.javascript.WrappedException: Wrapped java.lang.ArrayIndexOutOfBoundsException: -1 (nav_showNavTabs#19)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1828)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:199)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:347)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:65)
at org.mozilla.javascript.gen.c251._c0(nav_showNavTabs:19)
at org.mozilla.javascript.gen.c251.call(nav_showNavTabs)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:111)
at org.mozilla.javascript.gen.c51._c0(nav_callbackTree:127)
at org.mozilla.javascript.gen.c51.call(nav_callbackTree)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:387)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3125)
at org.mozilla.javascript.gen.c51.call(nav_callbackTree)
at com.servoy.j2db.scripting.ScriptEngine.executeFunction(ScriptEngine.java:37)
at com.servoy.j2db.plugins.ClientPluginAccessProvider$MethodExecutor.run(ClientPluginAccessProvider.java:23)
at com.servoy.j2db.plugins.ClientPluginAccessProvider.executeMethod(ClientPluginAccessProvider.java:38)
at com.servoy.extensions.beans.dbtreeview.FunctionDef.exec(FunctionDef.java:28)
at com.servoy.extensions.beans.dbtreeview.SwingDBTreeView.callMethod(SwingDBTreeView.java:850)
at com.servoy.extensions.beans.dbtreeview.SwingDBTreeView.valueChanged(SwingDBTreeView.java:829)
at javax.swing.JTree.fireValueChanged(Unknown Source)
at javax.swing.JTree$TreeSelectionRedirector.valueChanged(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(Unknown Source)
at javax.swing.JTree.setSelectionPath(Unknown Source)
at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(Unknown Source)
at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(Unknown Source)
at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(Unknown Source)
at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
at java.awt.AWTEventMulticaster.mousePressed(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)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.get(Unknown Source)
at com.servoy.j2db.dataui.SpecialTabPanel.Za(SpecialTabPanel.java:121)
at com.servoy.j2db.dataui.SpecialTabPanel.stateChanged(SpecialTabPanel.java:36)
at com.servoy.j2db.dataui.Zzd.setSelectedIndex(Zzd.java:3)
at com.servoy.j2db.dataui.Zzd.addTab(Zzd.java:89)
at com.servoy.j2db.dataui.SpecialTabPanel.addTab(SpecialTabPanel.java:198)
at com.servoy.j2db.dataui.SpecialTabPanel.js_addTab(SpecialTabPanel.java:95)
at sun.reflect.GeneratedMethodAccessor190.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)
... 48 more


Code: Select all
function nav_showNavTabs()
{
   var $program   = globals.nav_program; //current program the application is in
   var $treeId      = globals.k_current_button_id; //current dbTreeView record id
   var $obj      = globals.nav.menu[$treeId]; //get part of the object for this tree to get properties
   var $tabForm   = $program + '_dtl_tab'; //define tabform
   
   var $body      = forms.nav_menu_body.elements.tp_Body;

   if($obj.tabsArr.length > 0 && forms[$tabForm]) //see if there's a tabArray in de object with length > 0
   {
      var $tabs = forms.nav_tabs.elements.tp_navTab;
      globals.nav_reset_tab(true); //initialize the form on tp_navTab

      if($body.getTabFormNameAt(1) != $tabForm) //see if the current form on the bodytab is what it should be
      {
         globals.nav_bodyform = $tabForm;
         $body.removeAllTabs();
         $body.addTab(forms[globals.nav_bodyform]);
         
         var $ds = databaseManager.convertToDataSet(globals.nav_cur_pk);
         forms[globals.nav_bodyform].controller.loadRecords($ds);
      }

      for ( var i = 0; i < $obj.tabsArr.length ; i++)
      {
         var $id = $obj.tabsArr[i];
         var $name = globals.nav.menu[$id].i18n_trans;
         $tabs.addTab(forms.Dummy, $id, $name, null, null, null, null, null,i+1);   
      }

      var $newIndex = $obj.lasttab;

      if($tabs.tabIndex != $newIndex) globals.nav.noTabCallback = 1;

      $tabs.tabIndex = $newIndex;
      globals.nav.tabindex = $newIndex //save for historyupdate
   }
   etc.etc.etc........
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1755
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Wrapped java.lang.ArrayIndexOutOfBoundsException

Postby lvostinar » Fri Oct 02, 2009 9:04 am

It seems the java.lang.ArrayIndexOutOfBoundsException is in our code. It seems the faulty line is: var $ds = databaseManager.convertToDataSet(globals.nav_cur_pk); ? Do you know what value is passed there when it fails ?
Laurian Vostinar
Servoy
lvostinar
 
Posts: 1062
Joined: Tue Feb 19, 2008 10:53 am

Re: Wrapped java.lang.ArrayIndexOutOfBoundsException

Postby mboegem » Fri Oct 02, 2009 9:24 am

lvostinar wrote:Do you know what value is passed there when it fails ?


Nope... normally this should be a UUID. There's only 4 places in our code on which this variable get's set and all of them should set the UUID.

The nasty thing of this error is that it is not consistently reproducable. I will try clicking around and get the error occur.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1755
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Wrapped java.lang.ArrayIndexOutOfBoundsException

Postby patrick » Fri Oct 02, 2009 9:43 am

I think I had a problem like that, too. Have you tried to pass that global in an array as in

Code: Select all
var $ds = databaseManager.convertToDataSet([globals.nav_cur_pk]);
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Wrapped java.lang.ArrayIndexOutOfBoundsException

Postby mboegem » Fri Oct 02, 2009 11:38 am

patrick wrote:Have you tried to pass that global in an array


should this solve it or is it the cause?

Anyway, the 'globals.nav_cur_pk' is just a string.
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1755
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Wrapped java.lang.ArrayIndexOutOfBoundsException

Postby patrick » Fri Oct 02, 2009 12:15 pm

Yes, I know. But convertToDataSet expects an array of IDs... Have you tried?
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Wrapped java.lang.ArrayIndexOutOfBoundsException

Postby lvostinar » Fri Oct 02, 2009 12:27 pm

patrick wrote:Yes, I know. But convertToDataSet expects an array of IDs... Have you tried?


It can also receive a list of Strings so I think is not a wrong call; anyway definitely a good idea to try with array.
Laurian Vostinar
Servoy
lvostinar
 
Posts: 1062
Joined: Tue Feb 19, 2008 10:53 am

Re: Wrapped java.lang.ArrayIndexOutOfBoundsException

Postby mboegem » Fri Oct 02, 2009 1:16 pm

lvostinar wrote:anyway definitely a good idea to try with array.


ok,thnkx Laurian & Patrick will try if this works...
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1755
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Wrapped java.lang.ArrayIndexOutOfBoundsException

Postby jcompagner » Mon Oct 12, 2009 12:01 pm

convertToDataSet doesnt seem to be the problem
It is something in the addTab() that goes wrong.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Wrapped java.lang.ArrayIndexOutOfBoundsException

Postby mboegem » Mon Oct 12, 2009 1:04 pm

jcompagner wrote:It is something in the addTab() that goes wrong.


That is correct, I can confirm that.
Unfortunately it is just '.addTab(forms[$form])', where $form is a string, with valid formname.

This only occurs when Servoy can't keep up with the users navigation requests > which will do various 'addTab' commands in a short time...
Unfortunately I don't have a stack trace or consistent way to reproduce this...
Marc Boegem
Solutiative / JBS Group, Partner
Servoy Specialist
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image
User avatar
mboegem
 
Posts: 1755
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam


Return to Methods

Who is online

Users browsing this forum: No registered users and 7 guests

cron