Mysterious error

Hi,

now for the second time I encountered an rather mysterious exception:


java.lang.NumberFormatException: For input string: "-0.7142857142857189"
 	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
	at java.lang.Integer.parseInt(Integer.java:458)
	at java.lang.Integer.valueOf(Integer.java:554)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.convertVariableValue(AbstractCommunicationManager.java:1233)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1034)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:561)
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:260)
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:438)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Obviously there is an integer expected and not a double.
Because I could not repeat this by intention I don’t know which component causes this.
Is there a simple way to catch the problems source or do I have to extend the Vaadin code?

Hi!

How do you get into this error? Do you have some own component? Client side has coded the variable to be of type int, but has still put a float value there.

You could use hosted mode and vaadin client side debug dialog to track down the faulty component.

cheers,
matti

As I wrote, the error occured out of nowhere and I don’t remember which component I clicked.
So far I’m not able to reproduce it, therefore the debug-mode is not really helping.
I can only hope to trip over it again - with a more informative logging.

Edit:
Now I could reproduce the exception. The owner in the actual case is a table and the variable to change is:


VAR_VALUE = 17.800000000000004
VAR_PID = PID93
VAR_NAME = pagelength
VAR_TYPE = i

I will investigate further and report what I find out.

Hi!

That’s odd. I check the code on the Table components client side counterpart and it sends int type variable. This starts to look like a pretty critical GWT bug. What browser are you using and what is the exact Vaadin version?

cheers,
matti

Hi,

I’m using the 6.2 svn trunk of Vaadin as I incorporate some changes. (But the table classes are not affected.)
So after watching the error a bit I think, it’s an javascript error in Opera 10.50.

Table sends an update pagelength to the server after it has been rendered provided it has fixed height (pixels or %). The event is not immediate so it will be sent when anything else causes a server visit. I would recommend you try to reproduce the error with a Vaadin 6.2 nightly to rule out any customizations.

If you can reproduce it you can probably make quite a reduced test case of it which shows the problem. I tried to do this but the simples possible case with a fixed height Table does not show this behavior (pagelength is sent as an integer, just like it should).

Hi,

I was able to reproduce the error constantly with following steps:

  1. Open the application in Opera
  2. Decrease the window size with mouse
  3. Click on the other tab
  4. Error message appears

Configuration:

  • Windows XP SP 3
  • Java 1.6.0_18
  • Vaadin 6.2.6
  • JBoss 5.1.0GA, default
  • Opera 10.50

Application code

import com.vaadin.Application;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.Table;
import com.vaadin.ui.Window;

public class Vaadin_testApplication extends Application 
{
  private static final long serialVersionUID = 1L;

  @Override
  public void init() 
  {
    Window mainWindow = new Window("Vaadin_test Application");
    setMainWindow(mainWindow);
    
    Window window=new Window();
    window.setCaption("usermanagement");
    window.center();
    window.setWidth(40, Window.UNITS_PERCENTAGE);
    window.setHeight(40,Window.UNITS_PERCENTAGE);
    window.setModal(true);
    mainWindow.addWindow(window);

    TabSheet tab=new TabSheet();
    tab.setSizeFull();

    tab.addTab(new TableView(),"users",null);
    tab.addTab(new TableView(),"groups",null);
        
    window.setContent(tab);    
  }

  public class TableView extends Table 
  {
    private static final long serialVersionUID = 1L;
    
    public TableView()
    {
      setSizeFull();

      addContainerProperty("name",String.class,"name");
      addContainerProperty("right",Boolean.class,"right");
    }
  }  
}

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>vaadin-test</display-name>
  <context-param>
  	<description>
  	Vaadin production mode</description>
  	<param-name>productionMode</param-name>
  	<param-value>false</param-value>
  </context-param>
  <servlet>
  	<servlet-name>Vaadin_test Application</servlet-name>
  	<servlet-class>
  	com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
  	<init-param>
  		<description>
  		Vaadin application class to start</description>
  		<param-name>application</param-name>
  		<param-value>com.example.vaadin_test.Vaadin_testApplication</param-value>
  	</init-param>
  </servlet>
  <servlet-mapping>
  	<servlet-name>Vaadin_test Application</servlet-name>
  	<url-pattern>/*</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

It sure seems like an Opera 10.50 or GWT bug. The code in VScrollTable is

        int bodyH = bodyContainer.getOffsetHeight();
        int rowsAtOnce = bodyH / rowHeight;

When bodyH is 255 and rowHeight 21, rowsAtOnce becomes 12.14 and not 12 i.e., it is not truncated as it should. The best thing to do would be to find out if it is an Opera or GWT problem and file an issue to one of their tracs. You could also create a ticket in the
Vaadin trac
and somebody might figure out a workaround for it.

The workaround (at least for this case) is simple:

int rowsAtOnce = Math.round(bodyH / rowHeight);

But I agree that there might be a fundamental problem with GWT and/or Opera 10.50.

Created
#4374
to track this issue. Math.round is not a proper solution as Math.round(10.51) returns 11 and not 10 like it should in this case.

This Opera bug (CARAKAN-1263) has been fixed in the latest Opera snapshot and so the problem will be resolved with Opera 10.54.