J2EE Application Using GWT Spring and Hibernate
J2EE Application Using GWT Spring and Hibernate
Version 0.1
1
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Table of Contents
1. Introduction 3
2. Setting up the environment 3
2.1 GWT 3
2.2 Spring 3.x 3
2.3 Hibernate 3.x 3
2.4 Eclipse Galileo 3.5 3
2.5 Application Server 4
3. Setting up GWT module and folder structure 4
3.1 Setting up the GWT 4
3.2 For integrated application (GWT + spring + Hibernate) 8
3.3 Writing UI code, Service (RPC mechanism) and its implementation 15
3.4 Business Logic involves integration of Hibernate with Spring 21
4. Deploying the .WAR file to the Web-logic 28
4.1 Create a User defined web-logic configuration 28
4.2 Setting up the User-defined Admin Console and server as per the requirement 35
4.3 Defining JNDI 37
4.4 Setting the logging in web-logic (log 4j) 49
4.5 Deploying the WAR file into the server 51
2
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
1. Introduction
This document explains the procedure to develop and deploy a J2EE web application which adheres
to the AJAX (GWT), spring and Hibernate Framework.
Advantages of using GWT, spring and Hibernate Framework
Eradicates performance issue
Good UI presentation
Code maintainability and less lines of codes to get functionality done.
GUI and Server code can be written separately.
MVC architecture.
Efficient logging
2.1 GWT
Link to download GWT plug-in for Eclipse Galileo 3.5
GWT Plug-in - http://dl.google.com/eclipse/plugin/3.5
Google Web Toolkit SDK 2.0.3
Google App Engine Java SDK 1.4.2
Link to download GWT – ext
http://extjs.com/deploy/ext-2.0.2.zip
http://code.google.com/webtoolkit/download.html (official site from Google)
2.2 Spring 3.x
Link to download Spring 3.x
http://www.springsource.org/download
2.3 Hibernate 3.x
Link to download Hibernate 3.x
http://olex.openlogic.com/packages/hibernate
http://www.hibernate.org/
2.4 Eclipse Galileo 3.5
Link to download Eclipse Galileo 3.5
3
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Eclipse version - Galileo 3.5 (Eclipse Java EE IDE for Web Developers)
http://www.eclipse.org/downloads/
2.5 Application Server
Weblogic 10.0
After installing GWT plug-in one will have following icon in Eclipse
4
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
5
Developing & Deploying J2EE Application using
Contains images, data,
GWT Spring and Hibernate js and GWT module
xml to start
application locally.
Contains JUnit/test
classes for GWT service
and impl
Java System
Library (5
and above)
6
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
7
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
8
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Hibernate
resources
files
ApplicationContext.xml
contains Hibernate
configuration for local
environment; weblogic
environment and Bean
definition.
9
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
10
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Can be set as
welcome page and
loading message
WAR to
deploy
Build.xml to build
war for deployment 11
on weblogic 10.0
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
12
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
So in inherit name
would be
com.gwtext.GwtExt
BRASInterface.html BRASInterface.css
Above html and css, gets created using New Web Application Project
Modifications done by developer are:
13
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Can be replacing by loading message, loading image, title can be customized according to app name
14
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Naming convention
Service is GenerateBRASHistoryService so append Async to get GenerateBRASHistoryServiceAsync and
its implementation would be GenerateBRASHistoryServiceImpl, append impl after service.
Method convention
Need to write logic for fetching records from database for instance consider this method:
15
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
16
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
17
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
How Service, ServiceAsync and ServiceImpl are tied together with web.xml of application and Spring?
Integration has been done by using spring4gwt-0.0.1 jar
Servlet name as indicated in web.xml is mapped to services and html is set as welcome file for
app.
18
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
And these URL pattern has mapped to Service class using Spring annotation
@RemoteServiceRelativePath as shown in below code
Flow goes to business logic implementation and completing processing it returns to ServiceSync class
which gets called in GUI as below:
where AsyncCallback is anonymous class which would handle failure and success of incoming request
19
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
20
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Give location of
Hibernate resources
21
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Give location of
Hibernate resources
datasource bean is referenced in sessionFactory bean block and this sessionFactory gets called in
serviceImpl class using Spring annotation @Autowired
22
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
DAO provides sessionFactory to serviceImpl class using Spring annotation @Repositry, @Autowired
Now remaining with fetching of records using Hibernate mapping and DTO.
DTO is pojo class and mapping file does ORM – Object Relation Mapping with pojo class and tables in
Oracle Database.DTO gets used in serviceImpl class to write query as Java object.
23
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
24
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
25
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Paging in GWT
(feature)
Obtaining application context in code (feature of Spring)
Using ApplicationContextProvider Class and bean definition in applicationContext
26
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
27
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Go to Start -> All Programs -> BEA -> Tools -> Configuration Wizard
28
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
29
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
30
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
31
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
32
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Select “NO”
33
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Enter the name and location for the domain and then click on “Create”
34
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
35
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Once the server is in RUNNING MODE, open the Admin server Console and enter your
credentials
36
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
37
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
38
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
39
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
40
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Database Name
Host Name
Port
Database user name
Password
41
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Note: In the Test Table Name column, enter a valid SQL statement prefixed with
“SQL”
On success
42
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
43
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
The changes would be activated and specified if restart of the server is required or not.
44
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
To monitor, if the Data source is working, click on Data Source Name and select the
Monitoring tab
45
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Click on the Monitoring tab and then select the Testing sub-tab. Select the Admin server
and then click on Test Data Source button
We get the above mentioned error. To avoid the above error, follow the below steps
46
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
47
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
48
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Note: These jars should placed in the user defined project lib directory
49
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
50
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
51
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
On Click of the Install button in the screen, select the location of the WAR file & click on Next
52
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Choose targeting style ( since we are deploying a web-application, we choose the first option) &
click on Next
53
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
Click on Finish
54
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
55
Developing & Deploying J2EE Application using
GWT Spring and Hibernate
56