Thursday 28 February 2013

Vaadin + Spring Roo Basic Project Setup

Vaadin Install Addon Commands(Tested on Spring roo 1.2.2)

Download Spring roo 1.2.2 / and STS latest version 

Run the following commands to install vaadin addon in spring roo

osgi obr url add --url http://vaadin.com/springroo/repository.xml
osgi obr start --bundleSymbolicName com.vaadin.spring.roo.addon
osgi obr url remove --url http://vaadin.com/springroo/repository.xml
osgi obr url add --url http://spring-roo-os-commands.googlecode.com/svn/repo/repository.xml
osgi obr start --bundleSymbolicName net.stsmedia.roo.addon.oscommands
osgi obr url remove --url http://spring-roo-os-commands.googlecode.com/svn/repo/repository.xml

Create Vaadin + Spring Roo Project

1. create spring roo from sts / command line

project --topLevelPackage org.szanto --projectName vaadin-roo-example --java 6

2. Database setup

jpa setup --provider HIBERNATE --databaseName test--userName root --password root --database MYSQL 

3. Create Entity

entity jpa --class ~.server.domain.Employee--testAutomatically  

4. Add attributes to entity

field string description 

5. Vaadin project setup and create UI

vaadin setup --applicationPackage ~.web 

vaadin generate all -pakage ~.web.ui













Friday 15 February 2013

Steps in creating gwt project using spring roo 1.2.3

Steps in creating gwt project using spring roo 1.2.3

  1. Create TestProjectRoo1.2.3 from STS



  1. Roo commands

a.) jpa setup --provider HIBERNATE --databaseName test--userName root --password root --database MYSQL
b.) entity jpa --class ~.server.domain.TestEntity --testAutomatically
c.) field string description
d.) create all entities of your project
e.) gwt project set up commands
  1. web gwt setup
  2. web gwt all --proxyPackage test.client.managed.proxy --requestPackage test.client.managed.request


  1. You will get build error- Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:exec-maven-plugin:1.2:exec (execution: default, phase: process-classes)

To solve this error add following code inside pom.xml below given code

<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>

put this code below <outputDirectory>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>
exec-maven-plugin
</artifactId>
<versionRange>[1.2,)</versionRange>
<goals>
<goal>exec</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>

  1. You will get this error when runinng this project
    The RequestFactory ValidationTool must be run for the test.client.managed.request.ApplicationRequestFactory RequestFactory type
To Solve this error

1. pom.xml
<dependency>
<groupId>org.springframework.roo</groupId>
<artifactId>org.springframework.roo.annotations</artifactId>
<version>${roo.version}</version>
<scope>provided</scope> delete this line
</dependency>


2. Run Validation Tool(Save below file as validation.bat and run it after running project from STS)



:: made by TestProjectRoo1.2.3 TEAM
::@echo off
cls

:: Must change for project specific path(Project path)
d:
cd D:\D Drive Data\BME\workspace1\TestProjectRoo1.2.3

set TARGET=.\target
:: Must change web-inf path specfic to project
set BASE=%TARGET%\LogBook-0.1.0.BUILD-SNAPSHOT\WEB-INF
   
::----------------------------
:: don't have to edit below - unless you have more Application Request Factories

set OUTPUT=%BASE%\classes
::set OUTPUT=%TARGET%\generated-sources\gwt

IF NOT EXIST %TARGET% (
 echo %TARGET% doesn't exists, Please check your directory structure.
 echo Validation file must run from project root directory.
 pause
 exit
)

IF exist %OUTPUT% ( 
 echo %OUTPUT% exists 
) ELSE ( 
 mkdir %OUTPUT% && echo %OUTPUT% created. 
)

set CP=
set CP=%CP%%BASE%\classes;
set CP=%CP%%BASE%\lib\*;
:: '*' will only work with java 1.6+

:: these need to be in there
::CP="%CP%%BASE%/lib/requestfactory-apt.jar:";
::CP="%CP%%BASE%/lib/requestfactory-server+src.jar:";

echo DEBUG ClassPath: %CP%

:: these need to be in there
set PATH=C:\Program Files\Java\jdk1.6.0_32\bin\
::set CLASSPATH=.;C:\Users\tapant\.m2\repository\.

:: Validation tool must run for requestfactory class for which exception was thrown
java -cp %CP% com.google.web.bindery.requestfactory.apt.ValidationTool %OUTPUT% test.client.managed.request.ApplicationRequestFactory
:: Do you need more Request Factories???

:: the end
pause
::exit


  1. final Screen after above steps are perfect
     
6. Now create your own entry class and reuse the auto generated code. Thanks to Spring roo community for that.

Author : Milan D Ashara