vaadin spring hibernate

bonjour tout le monde
dans le cadre de mon stage de fin d’études je dois faire une application web en utilisant les framework Vaadin hibernate et spring
J’ai fait plusieurs recherches mais je n’ai pas trouver des tutoriels ou des exemples pratiques!
pourriez-vous m’aider s’il vous plaît

-------https://vaadin.com/wiki/-/wiki/Main/Spring%20Integration

//* exemple

-------http://code.google.com/p/vaadin-user-manager/downloads/detail?name=cp.zip&can=2&q=

//*vaadin-user-manager - Example app with Maven, Spring, Hibernate, Vaadin, MVP

http://code.google.com/p/springhbnjpatemplate/
//* spring template project

-----chercher le book LEARNING VAADIN pdf

//*voir chapitre 9 [ Integration with Third-party Products *Spring *Java EE 6 *Hibernate]

------ http://stackoverflow.com/questions/8096147/how-integrate-the-controller-with-form-hibernate-spring-vaadin

//* un petit prob qui pourrait vous aiguiller

bon courage

Hello Vaadin Solution Providers and Solvers,

I’m using Vaadin 6.8 version. I had created the Service and DAO layer using Spring 3.1 and Hibernate 3 and Injected the service in main Application class in vaadin using @AutoWired annotation. The problem is I’m getting button component error.

=================================================================================================
com.vaadin.event.ListenerMethod$MethodException: Invocation of method buttonClick in com.example.testvaadin6spring.Testvaadin6springApplication$1 failed.
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:530)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219)
at com.vaadin.ui.Button.fireClick(Button.java:567)
at com.vaadin.ui.Button.changeVariables(Button.java:223)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.changeVariables(AbstractCommunicationManager.java:1460)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1404)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1329)
at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:761)
at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:325)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at com.example.testvaadin6spring.Testvaadin6springApplication.saveCustomer(Testvaadin6springApplication.java:90)
at com.example.testvaadin6spring.Testvaadin6springApplication$1.buttonClick(Testvaadin6springApplication.java:66)
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 com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
… 31 more

Main Class Code:

package com.example.testvaadin6spring;

import org.springframework.beans.factory.annotation.Autowired;

import com.example.Service.CustomerService;
import com.example.pojo.Customer;
import com.vaadin.Application;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;

/**

  • Main application class.
    */
    public class Testvaadin6springApplication extends Application {

    private static final long serialVersionUID = 1L;
    // private TextField nametxt;
    // private TextArea address;
    // private TextField desigtxt;
    private com.vaadin.ui.Button savebtn;

    @Autowired
    private CustomerService customerService;

    @Override
    public void init() {
    Window mainWindow = new Window(“Testvaadin6spring Application”);

     mainWindow.addComponent(createPanel());
     setMainWindow(mainWindow);
    

    }

    @SuppressWarnings(“serial”)
    public Panel createPanel() {

     final Panel fpanel = new Panel("Employee Information");
    
     final FormLayout flayout = new FormLayout();
    
     // nametxt = new TextField("Name");
     // nametxt.setWidth("200px");
     // nametxt.setImmediate(true);
     // desigtxt = new TextField("Designation");
     // desigtxt.setWidth("200px");
     // address = new TextArea("Address");
     // address.setWidth("200px");
     // address.setHeight("80px");
     savebtn = new com.vaadin.ui.Button("Save");
     savebtn.setWidth("90px");
     savebtn.addListener(new ClickListener() {
    
         @Override
         public void buttonClick(ClickEvent event) {
             saveCustomer();
    
         }
     });
     // flayout.addComponent(nametxt);
     // flayout.addComponent(desigtxt);
     // flayout.addComponent(address);
     flayout.addComponent(savebtn);
     fpanel.setCaption("MyPanel");
     fpanel.addComponent(flayout);
    
     return fpanel;
    

    }

    @SuppressWarnings(“serial”)
    public void saveCustomer() {

     Customer saveCust = new Customer();
     saveCust.setName("VAADIN");
     saveCust.setAddress("VAADIN ADDRESS");
     System.out.println("Customer Data is:" + saveCust.getName());
     customerService.addCustomerDetails(saveCust);
    

    }

}

=================================================================================================
Application Context File:

<?xml version="1.0" encoding="UTF-8"?>

<!-- Property place holder database configuration -->

<context:property-placeholder location='classpath:resources/db.properties' />

<!-- Business and Data component annotated package to be scanned -->

<!-- <context:component-scan base-package="com.beans" /> -->
<!-- <context:component-scan base-package="com.Controller" /> -->
<context:component-scan base-package="com.example.Dao" />
<context:component-scan base-package="com.example.DaoImpl" />
<context:component-scan base-package="com.example.Services" />
<context:component-scan base-package="com.example.ServicesImpl" />
<context:component-scan base-package="com.example.myvaadin6" />

<context:annotation-config/>

<!-- Turn on AspectJ @Configurable support -->
<context:spring-configured />


<!-- Turn on @Autowired, @PostConstruct etc support -->
<bean
    class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
<bean
    class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />




<!-- Use this Datasource Configuartion for Development Purpose Only -->

<bean id="myDataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${database.driver}" />
    <property name="url" value="${database.url}" />
    <property name="username" value="${database.user}" />
    <property name="password" value="${database.password}" />
</bean>

<!-- SessionFactory Configuration -->
<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="myDataSource" />
    <property name="annotatedClasses">
        <list>
            <value>com.pojo.Customer</value>
            <!-- <value>com.pojo.Login</value> -->
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
        </props>
    </property>
</bean>




<!-- Transaction Manager -->
<tx:annotation-driven transaction-manager="transactionManager" />

<bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

=================================================================================================
web.xml File:

<?xml version="1.0" encoding="UTF-8"?>


TestVaadin6Spring


Vaadin production mode
productionMode
true

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:/WEB-INF/config/applicationContext.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>

<servlet>
    <servlet-name>Testvaadin6spring 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.testvaadin6spring.Testvaadin6springApplication</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>Testvaadin6spring Application</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Testvaadin6spring Application</servlet-name>
    <url-pattern>/VAADIN/*</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>

Service Interface

package com.example.Service;

import java.util.List;

import com.example.pojo.Customer;

public interface CustomerService {

public void addCustomerDetails(Customer customer);

public void removeCustomerDetails(Customer customer);

public List<Customer> getAllCustomersDetails();

public Customer getCustomerDetails(Customer customer);

}

Service Class

package com.example.ServiceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.Dao.CustomerDao;
import com.example.Service.CustomerService;
import com.example.pojo.Customer;

@Service
@Transactional
public class CustomerServiceImpl implements CustomerService {

@Autowired
private CustomerDao customerDAO;

@Override
public void addCustomerDetails(Customer customer) {
	if (customer != null) {
		customerDAO.addCustomerDeailsDao(customer);
	}

}

@Override
public void removeCustomerDetails(Customer customer) {
	customerDAO.removeCustomerDetailsDao(customer);

}

@Override
public List<Customer> getAllCustomersDetails() {
	List<Customer> allCustomersDetails = customerDAO
			.getAllCustomersDetailsDao();

	return allCustomersDetails;
}

@Override
public Customer getCustomerDetails(Customer customer) {
	Customer c = new Customer();
	c = customerDAO.getCustomerDetails(customer);
	return c;
}

}

DAOImpl class

package com.example.DaoImpl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.example.Dao.CustomerDao;
import com.example.pojo.Customer;

@Repository
public class CustomerDaoImpl implements CustomerDao{

@Autowired
private SessionFactory sessionfactory;

@Override
public void addCustomerDeailsDao(Customer customer) {
	sessionfactory.getCurrentSession().saveOrUpdate(customer);

	
}

@Override
public void removeCustomerDetailsDao(Customer customer) {
	sessionfactory.getCurrentSession().createQuery("delete from Customer c where c.id="+customer.getId()).executeUpdate();
	
}

@SuppressWarnings("unchecked")
@Override
public List<Customer> getAllCustomersDetailsDao() {
	return sessionfactory.getCurrentSession().createQuery("from Customer")
			.list();		
}

@Override
public Customer getCustomerDetails(Customer c) {
	Customer returnCustomer = new Customer();
	returnCustomer = (Customer) sessionfactory.getCurrentSession().get(
			Customer.class, c.getId());
	return returnCustomer;
}

}

This is my overall Structure of Simple app. Can Anbody provide Solution For above posted problem.