some examples are not working

hi guys
trying to get the most benefits of vaadin because i really like it - currently iam trying to create a RIA and off course i reach the moment of forms , i tried to look in the forms and datamodels examples in the demo section i found the form section , simply i took that code i revamp it to my needs (imports , package , etc). did not work out , i even copy the code i paste it like it is same error happen (cannot cast to com.vaadin.application) , same error happen even when i use the login form code:

http://demo.vaadin.com/sampler/#LoginForm
http://demo.vaadin.com/sampler/#FormBasic

i gone through the forum to check why is this problem happening iam afraid i didnot reach to any solutions , mean while the tutorial work like a charm :http://vaadin.com/tutorial
i cant understand if the problem is in the code or in my usage , please help and thanks in advance.

iam using eclipse Ganymede , vaadin 6.2.6

Regards

Hi!

Sorry but I did not really catch what the problem was. Could you describe exactly which code you copied, what was the problem that you encountered, what steps did you take to produce that error (was it on startup, visual or after that you pressed something). A stack trace would also help.

hi jens
Thanks for the reply , here is the code :

package com.example;

import com.vaadin.ui.LoginForm;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.LoginForm.LoginEvent;

@SuppressWarnings("serial")
public class combo extends VerticalLayout {

    public combo() {

        LoginForm login = new LoginForm();
        login.setWidth("100%");
        login.setHeight("300px");
        login.addListener(new LoginForm.LoginListener() {
            public void onLogin(LoginEvent event) {
                getWindow().showNotification(
                        "New Login",
                        "Username: " + event.getLoginParameter("username")
                                + ", password: "
                                + event.getLoginParameter("password"));
            }
        });
        addComponent(login);

    }
}

stack trace:

javax.servlet.ServletException: java.lang.ClassCastException: com.example.combo cannot be cast to com.vaadin.Application
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.handleServiceException(AbstractApplicationServlet.java:852)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:484)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

java.lang.ClassCastException: com.example.combo cannot be cast to com.vaadin.Application
	com.vaadin.terminal.gwt.server.ApplicationServlet.getNewApplication(ApplicationServlet.java:82)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.createApplication(AbstractApplicationServlet.java:826)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.findApplicationInstance(AbstractApplicationServlet.java:654)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:395)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

thanks for your help

Any help???

My guess is that you have defined your combo class as the application class in your web.xml. You should have an actual application class defined as you application in the web.xml.

Your code should look something like this


public YourApplication extends Application {
    @Override
    public void init() {
        Window mainWindow = new Window();
        setMainWindow(mainWindow);
        mainWindow.addComponent(new combo());
    }

}

The code for each sample in the Sampler is not a self-contained working application. It’s more of a CustomComponent, that you can place inside your application.

So the easiest way to copy-paste code from the Sampler is to create a stub application first, and then copy the contents (i.e. the code in the constructor) of a sample inside the init method of your stub application.

Kim thanks for your relpy , but iam not sure i get you well , iam just doing what has been came in the tutorials and the vaadin book.

here is my web.xml file:

<?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>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>combo</servlet-name>
  	<servlet-class>
  	com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
  	<init-param>
  		<description>combo class to start</description>
  		<param-name>application</param-name>
  		<param-value>com.example.combo</param-value>
  	</init-param>
  </servlet>
  <servlet-mapping>
  	<servlet-name>combo</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>

What do i need to change ?

Thanks in advance

Jouni thanks for your reply , would you please describe to me how i can do that step in details , or if you have an online example for it ,sorry iam totally new to it and i have broke my head trying to find a solution for it.

Regards

yeah, the problem is that you have the entry point to your example set to com.example.combo in your web.xml. This should point to something that extends Application. Your code is a VerticalLayout, and a layout is just one of many things that goes into an application. So what you need is an application that takes use of your layout.

Maybe the easiest way to get started is to copy paste the code that Kim posted into your application, and make web.xml point to that class (for example com.example.MyApplication where MyApplication extends Application). Working through the tutorials wouldn’t be a bad idea either.

The tutorials are working fine , the problem happen when i take that code from the samples , the errors began.
now iam trying to to work using custom composite - will try to put the inputs by the experimental editor , i just dont understand how iam gonna call that file.:frowning: