SlideShare a Scribd company logo
1



 The author has made every effort in the preparation of this book to ensure the accuracy of the information.
However, information in this book is sold without warranty either expressed or implied. The author will not be
    held liable for any damages caused or alleged to be caused either directly or indirectly by this book.




JSF, Facelets, Spring, Hibernate, Maven2 &
                  Eclipse


                                   Putting it All together



                                                    by




                                        K. Arulkumaran


                                                     &

                                             A. Sivayini




               Website: http://www.lulu.com/java-success


             Feedback email: java-interview@hotmail.com
2

                                                 Table Of Contents


Notations ..................................................................................................................... 3
Tutorial 9 – JSF, Facelets, Spring, Hibernate & Maven 2 ............................... 4
Tutorial 10 – Maven 2 ............................................................................................. 18
3
                                     Notations

Command prompt:




Eclipse:




File Explorer or Windows Explorer:




Internet Explorer:
4
Tutorial 9 – JSF, Facelets, Spring, Hibernate & Maven 2


This tutorial will put together tutorials 1-8. It will also incorporate dependencies
between the simpleWeb (c:tutorialsjsimpleWeb) and simple
(c:tutorialsjsimple) projects as it would be in a real application.
Step 1:

Firstly create a dependency between simpleWeb and simple. In fact simpleWeb depends on simple
for business service functions and data access and storage. So we need to define this in our pom.xml
file under simpleWeb (c:tutorialsjsimpleWeb).


    <dependency>
        <groupId>com.mytutorial</groupId>
        <artifactId>simple</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>jar</type>
    </dependency>


c:tutorialssimpleWebpom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-
v4_0_0.xsd">
         <modelVersion>4.0.0</modelVersion>
         <groupId>com.mytutorial</groupId>
         <artifactId>simpleWeb</artifactId>
         <packaging>war</packaging>
         <version>1.0-SNAPSHOT</version>
         <name>simpleWeb Maven Webapp</name>
         <url>http://maven.apache.org</url>
         <dependencies>
                   <dependency>
                           <groupId>com.mytutorial</groupId>
                           <artifactId>simple</artifactId>
                           <version>1.0-SNAPSHOT</version>
                           <type>jar</type>
                   </dependency>

                 <dependency>
                         <groupId>junit</groupId>
                         <artifactId>junit</artifactId>
                         <version>3.8.1</version>
                         <scope>test</scope>
                 </dependency>

                 <dependency>
                         <groupId>commons-digester</groupId>
                         <artifactId>commons-digester</artifactId>
                         <version>1.8</version>
                 </dependency>

                 <dependency>
                         <groupId>commons-collections</groupId>
                         <artifactId>commons-collections</artifactId>
                         <version>3.2</version>
                 </dependency>
5
        <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring</artifactId>
                <version>2.0.6</version>
        </dependency>

        <!-- JSF/JSTL/Facelets -->
        <dependency>
                 <groupId>javax.faces</groupId>
                 <artifactId>jsf-api</artifactId>
                 <version>1.2</version>
        </dependency>
        <dependency>
                 <groupId>javax.faces</groupId>
                 <artifactId>jsf-impl</artifactId>
                 <version>1.2_04</version>
        </dependency>
        <dependency>
                 <groupId>com.sun.facelets</groupId>
                 <artifactId>jsf-facelets</artifactId>
                 <version>1.1.11</version>
        </dependency>
        <dependency>
                 <groupId>javax.servlet</groupId>
                 <artifactId>jstl</artifactId>
                 <version>1.1.2</version>
        </dependency>
        <dependency>
                 <groupId>javax.el</groupId>
                 <artifactId>el-api</artifactId>
                 <version>1.0</version>
                 <scope>provided</scope>
        </dependency>
        <dependency>
                 <groupId>com.sun.el</groupId>
                 <artifactId>el-ri</artifactId>
                 <version>1.0</version>
        </dependency>

</dependencies>
<build>
        <finalName>simpleWeb</finalName>
        <pluginManagement>
                <plugins>
                         <plugin>
                                 <groupId>org.apache.maven.plugins</groupId>
                                 <artifactId>maven-compiler-plugin</artifactId>
                                 <version>2.0.2</version>
                                 <configuration>
                                           <source>1.5</source>
                                           <target>1.5</target>
                                 </configuration>
                         </plugin>
                         <plugin>
                                 <groupId>org.apache.maven.plugins</groupId>
                                 <artifactId>maven-eclipse-plugin</artifactId>
                                 <version>2.4</version>
                                 <configuration>
                                           <downloadSources>false</downloadSources>
                                           <wtpversion>1.5</wtpversion>
                                 </configuration>
                         </plugin>
                </plugins>
6
                  </pluginManagement>
         </build>
         <repositories>
                  <repository>
                           <id>maven-repository.dev.java.net</id>
                           <name>Java Dev Net Repository</name>
                           <url>http://download.java.net/maven/2/</url>
                           <releases>
                                    <enabled>true</enabled>
                                    <updatePolicy>never</updatePolicy>
                           </releases>
                           <snapshots>
                                    <enabled>false</enabled>
                           </snapshots>
                  </repository>
         </repositories>
</project>

Step 2: Exit out of eclipse and run the following maven command in a command
prompt:

C:tutorialssimpleWeb>mvn eclipse:clean eclipse:eclipse




STEP: WorkAround

The JSF 1.2 requires eclipse web facet 2.5. You need to open the file
“org.eclipse.wst.common.project.facet.core.xml” under C:tutorialssimpleWeb.settings as shown
below from version=2.4 to version=2.5. Every time you use the eclipse:clean command, you will have
to manually fix this up as shown below.




Step 3: Get back into eclipse and refresh the simpleWeb project by highlighting it and pressing “F5”.
Now right click and select “Properties”.
7




Since simpleWeb depends on simple maven2 has transitively brought all it dependencies into the
simpleWeb’s build path. In order to build a war file inside eclipse (pom.xml file is useful for building
war file and deploying externally) you need to define the J2EE module dependencies inside eclipse by
right clicking on simpleWeb and then selecting “Properties” and then “J2EE module depndencies”.

We need most jar files except for the el-api-1.0.jar & servlet-api-2.3.jar. Make sure that these 2 jars
are not ticked because they are available under Tomcat’s lib directory. All the ticked jar files end up in
“/WEB-INF/lib” directory when packaged inside Eclipse.




When you package it outside eclipse using mvn command “mvn clean package” pom.xml file will be
used for packaging these dependency jar files under “/WEB-INF/lib” inside the war file
8
Step 4: Let’s make the following changes for this tutorial


App.java in simple project
package com.mytutorial;

import java.util.ArrayList;
import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {

    public static void main(String[] args) {

          ApplicationContext ctx = new ClassPathXmlApplicationContext(        "applicationContext-
                         mytutorial.xml");

          List<Course> courses = new ArrayList<Course>(10);

          Course c1 = new Course();
          c1.setName("John");
          c1.setCourse("Java");

          courses.add(c1);

          Course c2 = new Course();
          c2.setName("Peter");
          c2.setCourse("Hibernate");

          courses.add(c2);

          //CourseService service = new CourseServiceImpl();
          CourseService service = (CourseService) ctx.getBean("courseService");

          service.processCourse(courses);

          List<Course> listCourses = service.getCourses(); //added

          System.out.println("Retrieved courses and names are " + listCourses); //added

     }
}


CourseService.java in simple project
package com.mytutorial;

import java.util.List;

public interface CourseService {

          public abstract void processCourse(List<Course> courses);

          public abstract List<Course> getCourses(); //added
}
9
CourseServiceImpl.java in simple project
package com.mytutorial;

import java.util.List;

public class CourseServiceImpl implements CourseService {

        private CourseDao courseDao;

        public CourseDao getCourseDao() {
              return courseDao;
        }

        public void setCourseDao(CourseDao courseDao) {
              this.courseDao = courseDao;
        }

        //Modified
        public void processCourse(List<Course> courses) {
              // CourseDao dao = new CourseDaoImpl();
              courseDao.create(courses);
        }

        //Added
        public List<Course> getCourses() {
              List<Course> list = getCourseDao().findAll();
              return list;
        }
}


CourseControllerBean.java in simpleWeb project
package com.mytutorial;

import java.util.List;

public class CourseControllerBean {

        private CourseService courseService; // injected via spring

        public List<Course> getCourses(){
              return getCourseService().getCourses();
        }


        public CourseService getCourseService() {
              return courseService;
        }

        public void setCourseService(CourseService courseService) {
              this.courseService = courseService;
        }
}

greeting.jspx in simpleWeb project
<?xml version="1.0" encoding="ISO-8859-1" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:ui="http://java.sun.com/jsf/facelets" version="2.0">
10

        <ui:composition>
                <html>
                <head>

                 <title>greeting page</title>
                 </head>
                 <body>
                 <f:loadBundle basename="com.mytutorial.messages" var="msg" />
                 <h3><h:outputText value="#{msg.greeting_text}" />, <h:outputText
                          value="#{personBean.personName}" /> <h:outputText
                          value="#{msg.sign}" /></h3>


                 <h:dataTable id="courses" value="#{courseBean.courses}" var="course"
                             border="1">
                        <h:column>
                                 <f:facet name="header">
                                          <h:outputText value="Name" />
                                 </f:facet>
                                 <h:outputText value="#{course.name}" />
                        </h:column>

                         <h:column>
                                 <f:facet name="header">
                                          <h:outputText value="Course" />
                                 </f:facet>
                                 <h:outputText value="#{course.course}" />
                         </h:column>
                 </h:dataTable>


                 </body>
                 </html>
         </ui:composition>
</jsp:root>
11




applicationContext.xml in simpleWeb project
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

        <bean id="person" class="com.mytutorial.PersonBean" />

        <bean id="personBean" class="com.mytutorial.PersonControllerBean" scope="session">
                <property name="person" ref="person" />
        </bean>

        <bean id="courseBean" class="com.mytutorial.CourseControllerBean" scope="session">
                <property name="courseService" ref="courseService" />
        </bean>

</beans>
12




finally the web.xml file.

web.xml in simpleWeb project: find both spring applicationContext files.
            <context-param>
                <param-name>contextConfigLocation</param-name>

               <param-value>
                     <![CDATA[
                     /WEB-INF/applicationContext.xml
                     classpath:applicationContext-mytutorial.xml
                     ]]>
               </param-value>
          </context-param>

The web.xml file should look like:

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
          <context-param>
                    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                    <param-value>server</param-value>
          </context-param>
          <context-param>
                    <param-name>javax.faces.CONFIG_FILES</param-name>
                    <param-value>/WEB-INF/faces-config.xml</param-value>
          </context-param>
          <context-param>
                    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                    <param-value>.jspx</param-value>
          </context-param>

         <context-param>
                  <param-name>contextConfigLocation</param-name>

                  <param-value>
                          <![CDATA[
                          /WEB-INF/applicationContext.xml
                          classpath:applicationContext-mytutorial.xml
                          ]]>
                  </param-value>
         </context-param>
13
         <!-- Special Debug Output for Development -->
         <context-param>
                   <param-name>facelets.DEVELOPMENT</param-name>
                   <param-value>true</param-value>
         </context-param>
         <!-- Optional JSF-RI Parameters to Help Debug -->
         <context-param>
                   <param-name>com.sun.faces.validateXml</param-name>
                   <param-value>true</param-value>
         </context-param>
         <context-param>
                   <param-name>com.sun.faces.verifyObjects</param-name>
                   <param-value>true</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>

         <!-- Faces Servlet -->
         <servlet>
                   <servlet-name>Faces Servlet</servlet-name>
                   <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                   <load-on-startup>1</load-on-startup>
         </servlet>

         <!-- Faces Servlet Mapping -->
         <servlet-mapping>
                   <servlet-name>Faces Servlet</servlet-name>
                   <url-pattern>*.jsf</url-pattern>
         </servlet-mapping>

</web-app>


Step 5: Now install the “simple” project into maven repository with the new changes by:

C:tutorialssimple>mvn clean install

This should install the “simple-1.0-SNAPSHOT.jar” under
“C:java.m2repositorycommytutorialsimple1.0-SNAPSHOT”. Refresh the simpleWeb project inside
eclipse. Now Republish/package the simpleWeb project inside eclipse and start the Tomcat Server.
14




Make sure that your Database server is running:

C:javahsqldb>java -cp ./lib/hsqldb.jar org.hsqldb.Server
15




Also preferably run the “DatabaseManeger”


C:javahsqldb>java -cp ./lib/hsqldb.jar org.hsqldb.util.DatabaseManager




This will spawn a new window as shown:




Now open internet browser and type the following URL.

http://localhost:8080/simpleWeb/index.jsf
16




Click on link “Click Me”.




Click on button “Hello”




The Name & Course are empty. Now let’s add some name and courses into the database either via
SQL statements in “DatabaseManager” or by running the App.java. Make sure that your HSQLDB
database server is running. To run App.java inside eclipse right click on “App.java” and then select
“Run As” and then select “Java Application”. After it has finished running go back to your internet
explorer and click on refresh button.
17




That’s all to it.




Please feel free to email any errors to java-interview@hotmail.com. Also stay tuned at
    http://www.lulu.com/java-success for more tutorials and Java/J2EE interview
                                        resources.
18
Tutorial 10 – Maven 2


You may have noticed that there are some code repeats in pom.xml files in
simple and simpleWeb projects. Maven2 child pom.xml files can inherit from
parent pom.xml file. In this tutorial let’s clean up our project structures and the
pom.xml files.


Step 1: Exit out of eclipse and restructure your projects under C:tuitorials as follows:




Create a new folder “simple-tutorial” under “c:tutorials” and move the “simple” & “simpleWeb”
under “simple-tutorial”.


Step 2: Add the parent pom.xml under “c:tutorialssimple-tutorial” as shown below.
The parent pom.xml file will be shared by both the pom.xml files under
“c:tutorialssimple-tutorialsimple” and “c:tutorialssimple-tutorialsimpleWeb”.


c:tutorialssimple-tutorialpom.xml (parent pom.xml)
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
   http://maven.apache.org/maven-v4_0_0.xsd">

   <modelVersion>4.0.0</modelVersion>
   <groupId>com.mytutorial</groupId>
   <artifactId>simple-tutorial</artifactId>
   <packaging>pom</packaging>
         <name>simple tutorials</name>
         <description>simple tutorials</description>
         <version>1.0</version>
         <url>http://www.lulu.com/java-success</url>
         <inceptionYear>2007</inceptionYear>
         <developers>
                  <developer>
                          <name>Arulkumaran</name>
                          <id>ak1</id>
                          <email>java-interview@hotmail.com</email>
                          <organization></organization>
19
                         <roles>
                                 <role>Senior Java Designer/Developer</role>
                        </roles>
                        <timezone>+10</timezone>
                </developer>
        </developers>

        <contributors>
                 <contributor>
                          <name>Sivayini</name>
                          <email></email>
                          <organization></organization>
                          <roles>
                                   <role>Java Developer</role>
                          </roles>
                 </contributor>
        </contributors>

        <modules>
               <module>simple</module>
               <module>simpleWeb</module>
        </modules>

        <build>
           <pluginManagement>
                 <plugins>
                    <plugin>
                          <groupId>org.apache.maven.plugins</groupId>
                          <artifactId>maven-compiler-plugin</artifactId>
                          <version>2.0.2</version>
                          <configuration>
                               <source>1.5</source>
                              <target>1.5</target>
                          </configuration>
                     </plugin>
                     <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-eclipse-plugin</artifactId>
                        <version>2.4</version>
                       <configuration>
                           <downloadSources>false</downloadSources>
                           <wtpversion>1.5</wtpversion>
                       </configuration>
                     </plugin>
                 </plugins>
             </pluginManagement>
        </build>

         <repositories>
                  <repository>
                           <id>maven-repository.dev.java.net</id>
                           <name>Java Dev Net Repository</name>
                           <url>http://download.java.net/maven/2/</url>
                           <releases>
                                    <enabled>true</enabled>
                                    <updatePolicy>never</updatePolicy>
                           </releases>
                           <snapshots>
                                    <enabled>false</enabled>
                           </snapshots>
                  </repository>
         </repositories>
</project>
20

c:tutorialssimple-tutorialsimplepom.xml (child pom.xml)

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
         http://maven.apache.org/maven-v4_0_0.xsd">

        <modelVersion>4.0.0</modelVersion>
        <parent>
                  <groupId>com.mytutorial</groupId>
                  <artifactId>simple-tutorial</artifactId>
                  <version>1.0</version>
        </parent>
        <groupId>com.mytutorial</groupId>
        <artifactId>simple</artifactId>
        <packaging>jar</packaging>
        <version>1.0-SNAPSHOT</version>
        <name>simple</name>
        <url>http://maven.apache.org</url>
        <dependencies>
                  <dependency>
                            <groupId>junit</groupId>
                            <artifactId>junit</artifactId>
                            <version>3.8.1</version>
                            <scope>test</scope>
                  </dependency>

                 <dependency>
                         <groupId>org.hibernate</groupId>
                         <artifactId>hibernate</artifactId>
                         <version>3.2.4.ga</version>
                 </dependency>

                 <dependency>
                         <groupId>hsqldb</groupId>
                         <artifactId>hsqldb</artifactId>
                         <version>1.8.0.7</version>
                 </dependency>

                 <dependency>
                         <groupId>org.springframework</groupId>
                         <artifactId>spring</artifactId>
                         <version>2.0.6</version>
                 </dependency>

         </dependencies>
</project>

As you can see above this pom.xml file extends the parent pom.xml. All the repositories and plugins
are shared from the parent pom.xml file.


c:tutorialssimple-tutorialsimpleWebpom.xml (child pom.xml)
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-
         v4_0_0.xsd">
         <modelVersion>4.0.0</modelVersion>
         <parent>
                 <groupId>com.mytutorial</groupId>
21
        <artifactId>simple-tutorial</artifactId>
        <version>1.0</version>
</parent>

<groupId>com.mytutorial</groupId>
<artifactId>simpleWeb</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>simpleWeb Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
         <dependency>
                  <groupId>com.mytutorial</groupId>
                  <artifactId>simple</artifactId>
                  <version>1.0-SNAPSHOT</version>
                  <type>jar</type>
          </dependency>

        <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>3.8.1</version>
                <scope>test</scope>
        </dependency>

        <dependency>
                <groupId>commons-digester</groupId>
                <artifactId>commons-digester</artifactId>
                <version>1.8</version>
        </dependency>

        <dependency>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
                <version>3.2</version>
        </dependency>

        <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring</artifactId>
                <version>2.0.6</version>
        </dependency>

        <!-- JSF/JSTL/Facelets -->
        <dependency>
                 <groupId>javax.faces</groupId>
                 <artifactId>jsf-api</artifactId>
                 <version>1.2</version>
        </dependency>
        <dependency>
                 <groupId>javax.faces</groupId>
                 <artifactId>jsf-impl</artifactId>
                 <version>1.2_04</version>
        </dependency>
        <dependency>
                 <groupId>com.sun.facelets</groupId>
                 <artifactId>jsf-facelets</artifactId>
                 <version>1.1.11</version>
        </dependency>
        <dependency>
                 <groupId>javax.servlet</groupId>
                 <artifactId>jstl</artifactId>
                 <version>1.1.2</version>
22
                    </dependency>
                    <dependency>
                            <groupId>javax.el</groupId>
                            <artifactId>el-api</artifactId>
                            <version>1.0</version>
                            <scope>provided</scope>
                    </dependency>
                    <dependency>
                            <groupId>com.sun.el</groupId>
                            <artifactId>el-ri</artifactId>
                            <version>1.0</version>
                    </dependency>

         </dependencies>
         <build>

                    <finalName>simpleWeb</finalName>
                    <pluginManagement/>
         </build>
</project>


Step 3: Run mvn commands. This time you can run from “C:tutorialssimple-tutorial” to build both
“simple” & “simpleWeb”. This is possible due to <modules> definition in parent pom.xml file.

<modules>
       <module>simple</module>
       <module>simpleWeb</module>
</modules>

Now run the following command for eclipse:

C:tutorialssimple-tutorial>mvn eclipse:clean eclipse:eclipse
23
STEP: WorkAround

The JSF 1.2 requires eclipse web facet 2.5. You need to open the file
“org.eclipse.wst.common.project.facet.core.xml” under C:tutorialssimple-
tutorialsimpleWeb.settings as shown below from version=2.4 to version=2.5. Every time you use
the eclipse:clean command, you will have to manually fix this up as shown below.




Run the following command:

C:tutorialssimple-tutorial>mvn clean install




Step 4: Open up your eclipse workspace at “C:javaeclipse-tutorial-workspace”. You will get a
screen as follows:
24




Delete the “simple” & “simpleWeb” (select “Do not delete contents” and pres OK ) projects and
import them again.
25
26




Step 5: Publish the war file inside eclipse.
27




After publishing, run the Tomcat Server.


Step 6: Run the HSQLDB server in a command prompt and also open the “DatabaseManager” in
another command prompt.

Make sure that your Database server is running:

C:javahsqldb>java -cp ./lib/hsqldb.jar org.hsqldb.Server




Also preferably run the “DatabaseManeger”

C:javahsqldb>java -cp ./lib/hsqldb.jar org.hsqldb.util.DatabaseManager




This will spawn a new window as shown:
28




Open an internet browser and type the URL

http://localhost:8080/simpleWeb/index.jsf




That’s all to it. Also try deploying outside Tomcat. Stop the Tomcat server inside eclipse.
29

If you already have a “simpleWeb” folder under “C:javaTomcat6.0webapps” delete it first. Then
copy the “simpleWeb.war” into Tomcat’s “C:javaTomcat6.0webapps” folder. Double click on
“tomcat6.exe” to start the server.




Open an internet browser and type the URL

http://localhost:8080/simpleWeb/index.jsf




         You can find some fundamental Questions & Answers relating to Hibernate/Spring under
        “Emerging technologies/framework” section in Java/J2EE Job Interview Companion at
                                 http://www.lulu.com/content/192463




Please feel free to email any errors to java-interview@hotmail.com. Also stay tuned at
    http://www.lulu.com/java-success for more tutorials and Java/J2EE interview
                                        resources.
Ad

More Related Content

What's hot (20)

Tycho - good, bad or ugly ?
Tycho - good, bad or ugly ?Tycho - good, bad or ugly ?
Tycho - good, bad or ugly ?
Max Andersen
 
JavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンJavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオン
haruki ueno
 
How to be effective with JBoss Developer Studio
How to be effective with JBoss Developer StudioHow to be effective with JBoss Developer Studio
How to be effective with JBoss Developer Studio
Max Andersen
 
Enterprise Build And Test In The Cloud
Enterprise Build And Test In The CloudEnterprise Build And Test In The Cloud
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More Power
Arun Gupta
 
Java EE 6 and GlassFish v3: Paving the path for future
Java EE 6 and GlassFish v3: Paving the path for futureJava EE 6 and GlassFish v3: Paving the path for future
Java EE 6 and GlassFish v3: Paving the path for future
Arun Gupta
 
Hibernate, Spring, Eclipse, HSQL Database & Maven tutorial
Hibernate, Spring, Eclipse, HSQL Database & Maven tutorialHibernate, Spring, Eclipse, HSQL Database & Maven tutorial
Hibernate, Spring, Eclipse, HSQL Database & Maven tutorial
Raghavan Mohan
 
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Arun Gupta
 
Spring boot入門ハンズオン第二回
Spring boot入門ハンズオン第二回Spring boot入門ハンズオン第二回
Spring boot入門ハンズオン第二回
haruki ueno
 
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGJava EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Arun Gupta
 
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Jagadish Prasath
 
Java EE 6 = Less Code + More Power (Tutorial) [5th IndicThreads Conference O...
Java EE 6 = Less Code + More Power (Tutorial)  [5th IndicThreads Conference O...Java EE 6 = Less Code + More Power (Tutorial)  [5th IndicThreads Conference O...
Java EE 6 = Less Code + More Power (Tutorial) [5th IndicThreads Conference O...
IndicThreads
 
Apache Maven for AT/QC
Apache Maven for AT/QCApache Maven for AT/QC
Apache Maven for AT/QC
Volodymyr Ostapiv
 
Maven, Eclipse And OSGi Working Together
Maven, Eclipse And OSGi Working TogetherMaven, Eclipse And OSGi Working Together
Maven, Eclipse And OSGi Working Together
Carlos Sanchez
 
Enterprise Maven Repository BOF
Enterprise Maven Repository BOFEnterprise Maven Repository BOF
Enterprise Maven Repository BOF
Max Andersen
 
Enterprise Build And Test In The Cloud
Enterprise Build And Test In The CloudEnterprise Build And Test In The Cloud
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
ICEfaces EE - Enterprise-ready JSF Ajax Framework
ICEfaces EE - Enterprise-ready JSF Ajax FrameworkICEfaces EE - Enterprise-ready JSF Ajax Framework
ICEfaces EE - Enterprise-ready JSF Ajax Framework
ICEsoftTech
 
Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5
Vishwash Gaur
 
Spring boot for buidling microservices
Spring boot for buidling microservicesSpring boot for buidling microservices
Spring boot for buidling microservices
Nilanjan Roy
 
Maven, Eclipse and OSGi Working Together - Carlos Sanchez
Maven, Eclipse and OSGi Working Together - Carlos SanchezMaven, Eclipse and OSGi Working Together - Carlos Sanchez
Maven, Eclipse and OSGi Working Together - Carlos Sanchez
mfrancis
 
Tycho - good, bad or ugly ?
Tycho - good, bad or ugly ?Tycho - good, bad or ugly ?
Tycho - good, bad or ugly ?
Max Andersen
 
JavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンJavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオン
haruki ueno
 
How to be effective with JBoss Developer Studio
How to be effective with JBoss Developer StudioHow to be effective with JBoss Developer Studio
How to be effective with JBoss Developer Studio
Max Andersen
 
Enterprise Build And Test In The Cloud
Enterprise Build And Test In The CloudEnterprise Build And Test In The Cloud
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
Java EE 6 = Less Code + More Power
Java EE 6 = Less Code + More PowerJava EE 6 = Less Code + More Power
Java EE 6 = Less Code + More Power
Arun Gupta
 
Java EE 6 and GlassFish v3: Paving the path for future
Java EE 6 and GlassFish v3: Paving the path for futureJava EE 6 and GlassFish v3: Paving the path for future
Java EE 6 and GlassFish v3: Paving the path for future
Arun Gupta
 
Hibernate, Spring, Eclipse, HSQL Database & Maven tutorial
Hibernate, Spring, Eclipse, HSQL Database & Maven tutorialHibernate, Spring, Eclipse, HSQL Database & Maven tutorial
Hibernate, Spring, Eclipse, HSQL Database & Maven tutorial
Raghavan Mohan
 
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010Deep Dive Hands-on in Java EE 6 - Oredev 2010
Deep Dive Hands-on in Java EE 6 - Oredev 2010
Arun Gupta
 
Spring boot入門ハンズオン第二回
Spring boot入門ハンズオン第二回Spring boot入門ハンズオン第二回
Spring boot入門ハンズオン第二回
haruki ueno
 
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUGJava EE 6 & GlassFish = Less Code + More Power at CEJUG
Java EE 6 & GlassFish = Less Code + More Power at CEJUG
Arun Gupta
 
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Java EE 6 - Deep Dive - Indic Threads, Pune - 2010
Jagadish Prasath
 
Java EE 6 = Less Code + More Power (Tutorial) [5th IndicThreads Conference O...
Java EE 6 = Less Code + More Power (Tutorial)  [5th IndicThreads Conference O...Java EE 6 = Less Code + More Power (Tutorial)  [5th IndicThreads Conference O...
Java EE 6 = Less Code + More Power (Tutorial) [5th IndicThreads Conference O...
IndicThreads
 
Maven, Eclipse And OSGi Working Together
Maven, Eclipse And OSGi Working TogetherMaven, Eclipse And OSGi Working Together
Maven, Eclipse And OSGi Working Together
Carlos Sanchez
 
Enterprise Maven Repository BOF
Enterprise Maven Repository BOFEnterprise Maven Repository BOF
Enterprise Maven Repository BOF
Max Andersen
 
Enterprise Build And Test In The Cloud
Enterprise Build And Test In The CloudEnterprise Build And Test In The Cloud
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
ICEfaces EE - Enterprise-ready JSF Ajax Framework
ICEfaces EE - Enterprise-ready JSF Ajax FrameworkICEfaces EE - Enterprise-ready JSF Ajax Framework
ICEfaces EE - Enterprise-ready JSF Ajax Framework
ICEsoftTech
 
Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5Simple module Development in Joomla! 2.5
Simple module Development in Joomla! 2.5
Vishwash Gaur
 
Spring boot for buidling microservices
Spring boot for buidling microservicesSpring boot for buidling microservices
Spring boot for buidling microservices
Nilanjan Roy
 
Maven, Eclipse and OSGi Working Together - Carlos Sanchez
Maven, Eclipse and OSGi Working Together - Carlos SanchezMaven, Eclipse and OSGi Working Together - Carlos Sanchez
Maven, Eclipse and OSGi Working Together - Carlos Sanchez
mfrancis
 

Similar to Jsf, facelets, spring, hibernate, maven2 (20)

Spring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorialsSpring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorials
Raghavan Mohan
 
Pom configuration java xml
Pom configuration java xmlPom configuration java xml
Pom configuration java xml
akmini
 
Apache Maven basics
Apache Maven basicsApache Maven basics
Apache Maven basics
Volodymyr Ostapiv
 
Introduction To Maven2
Introduction To Maven2Introduction To Maven2
Introduction To Maven2
Shuji Watanabe
 
Make use of Sonar for your mobile developments - It's easy and useful!
Make use of Sonar for your mobile developments - It's easy and useful!Make use of Sonar for your mobile developments - It's easy and useful!
Make use of Sonar for your mobile developments - It's easy and useful!
cyrilpicat
 
Soft shake 2013 - make use of sonar on your mobile developments
Soft shake 2013 - make use of sonar on your mobile developmentsSoft shake 2013 - make use of sonar on your mobile developments
Soft shake 2013 - make use of sonar on your mobile developments
rfelden
 
Using Maven2
Using Maven2Using Maven2
Using Maven2
elliando dias
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
Sid Anand
 
Maven
MavenMaven
Maven
javeed_mhd
 
Maven
MavenMaven
Maven
AbdulImrankhan7
 
Ant, Maven and Jenkins
Ant, Maven and JenkinsAnt, Maven and Jenkins
Ant, Maven and Jenkins
Kenu, GwangNam Heo
 
Maven in Mule
Maven in MuleMaven in Mule
Maven in Mule
Anand kalla
 
Gradle: From Extreme to Mainstream
Gradle: From Extreme to MainstreamGradle: From Extreme to Mainstream
Gradle: From Extreme to Mainstream
BTI360
 
Exploring Maven SVN GIT
Exploring Maven SVN GITExploring Maven SVN GIT
Exploring Maven SVN GIT
People Strategists
 
Apache Maven
Apache MavenApache Maven
Apache Maven
venkatraghavang
 
Pom
PomPom
Pom
Sanyam Arora
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
boyw165
 
AOP sec3.pptx
AOP sec3.pptxAOP sec3.pptx
AOP sec3.pptx
NourhanTarek23
 
An Introduction to Maven and Flex
An Introduction to Maven and FlexAn Introduction to Maven and Flex
An Introduction to Maven and Flex
Justin J. Moses
 
Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)
Robert Scholte
 
Spring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorialsSpring Web Service, Spring JMS, Eclipse & Maven tutorials
Spring Web Service, Spring JMS, Eclipse & Maven tutorials
Raghavan Mohan
 
Pom configuration java xml
Pom configuration java xmlPom configuration java xml
Pom configuration java xml
akmini
 
Introduction To Maven2
Introduction To Maven2Introduction To Maven2
Introduction To Maven2
Shuji Watanabe
 
Make use of Sonar for your mobile developments - It's easy and useful!
Make use of Sonar for your mobile developments - It's easy and useful!Make use of Sonar for your mobile developments - It's easy and useful!
Make use of Sonar for your mobile developments - It's easy and useful!
cyrilpicat
 
Soft shake 2013 - make use of sonar on your mobile developments
Soft shake 2013 - make use of sonar on your mobile developmentsSoft shake 2013 - make use of sonar on your mobile developments
Soft shake 2013 - make use of sonar on your mobile developments
rfelden
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
Sid Anand
 
Gradle: From Extreme to Mainstream
Gradle: From Extreme to MainstreamGradle: From Extreme to Mainstream
Gradle: From Extreme to Mainstream
BTI360
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
boyw165
 
An Introduction to Maven and Flex
An Introduction to Maven and FlexAn Introduction to Maven and Flex
An Introduction to Maven and Flex
Justin J. Moses
 
Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)
Robert Scholte
 
Ad

More from Raghavan Mohan (12)

Accelerate with BIRT and Actuate11
Accelerate with BIRT and Actuate11Accelerate with BIRT and Actuate11
Accelerate with BIRT and Actuate11
Raghavan Mohan
 
Who is BIRT
Who is BIRTWho is BIRT
Who is BIRT
Raghavan Mohan
 
Introduction to BIRT
Introduction to BIRTIntroduction to BIRT
Introduction to BIRT
Raghavan Mohan
 
Sachin Tendulkar Resume
Sachin Tendulkar ResumeSachin Tendulkar Resume
Sachin Tendulkar Resume
Raghavan Mohan
 
Manmohan Singh Resume
Manmohan Singh ResumeManmohan Singh Resume
Manmohan Singh Resume
Raghavan Mohan
 
Senator Barrack Obama Resume
Senator Barrack Obama ResumeSenator Barrack Obama Resume
Senator Barrack Obama Resume
Raghavan Mohan
 
Java/J2EE CV Guide
Java/J2EE CV GuideJava/J2EE CV Guide
Java/J2EE CV Guide
Raghavan Mohan
 
Java/J2EE Companion
Java/J2EE CompanionJava/J2EE Companion
Java/J2EE Companion
Raghavan Mohan
 
Fast Track to Ajax.
Fast Track to Ajax.Fast Track to Ajax.
Fast Track to Ajax.
Raghavan Mohan
 
23617968 digit-fast-track-jan-2009-php
23617968 digit-fast-track-jan-2009-php23617968 digit-fast-track-jan-2009-php
23617968 digit-fast-track-jan-2009-php
Raghavan Mohan
 
Quality - Douglas Crockford
Quality - Douglas CrockfordQuality - Douglas Crockford
Quality - Douglas Crockford
Raghavan Mohan
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
Raghavan Mohan
 
Accelerate with BIRT and Actuate11
Accelerate with BIRT and Actuate11Accelerate with BIRT and Actuate11
Accelerate with BIRT and Actuate11
Raghavan Mohan
 
Sachin Tendulkar Resume
Sachin Tendulkar ResumeSachin Tendulkar Resume
Sachin Tendulkar Resume
Raghavan Mohan
 
Senator Barrack Obama Resume
Senator Barrack Obama ResumeSenator Barrack Obama Resume
Senator Barrack Obama Resume
Raghavan Mohan
 
23617968 digit-fast-track-jan-2009-php
23617968 digit-fast-track-jan-2009-php23617968 digit-fast-track-jan-2009-php
23617968 digit-fast-track-jan-2009-php
Raghavan Mohan
 
Quality - Douglas Crockford
Quality - Douglas CrockfordQuality - Douglas Crockford
Quality - Douglas Crockford
Raghavan Mohan
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
Raghavan Mohan
 
Ad

Recently uploaded (20)

2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025
BookNet Canada
 
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveDesigning Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep Dive
ScyllaDB
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 

Jsf, facelets, spring, hibernate, maven2

  • 1. 1 The author has made every effort in the preparation of this book to ensure the accuracy of the information. However, information in this book is sold without warranty either expressed or implied. The author will not be held liable for any damages caused or alleged to be caused either directly or indirectly by this book. JSF, Facelets, Spring, Hibernate, Maven2 & Eclipse Putting it All together by K. Arulkumaran & A. Sivayini Website: http://www.lulu.com/java-success Feedback email: [email protected]
  • 2. 2 Table Of Contents Notations ..................................................................................................................... 3 Tutorial 9 – JSF, Facelets, Spring, Hibernate & Maven 2 ............................... 4 Tutorial 10 – Maven 2 ............................................................................................. 18
  • 3. 3 Notations Command prompt: Eclipse: File Explorer or Windows Explorer: Internet Explorer:
  • 4. 4 Tutorial 9 – JSF, Facelets, Spring, Hibernate & Maven 2 This tutorial will put together tutorials 1-8. It will also incorporate dependencies between the simpleWeb (c:tutorialsjsimpleWeb) and simple (c:tutorialsjsimple) projects as it would be in a real application. Step 1: Firstly create a dependency between simpleWeb and simple. In fact simpleWeb depends on simple for business service functions and data access and storage. So we need to define this in our pom.xml file under simpleWeb (c:tutorialsjsimpleWeb). <dependency> <groupId>com.mytutorial</groupId> <artifactId>simple</artifactId> <version>1.0-SNAPSHOT</version> <type>jar</type> </dependency> c:tutorialssimpleWebpom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven- v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mytutorial</groupId> <artifactId>simpleWeb</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>simpleWeb Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>com.mytutorial</groupId> <artifactId>simple</artifactId> <version>1.0-SNAPSHOT</version> <type>jar</type> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>commons-digester</groupId> <artifactId>commons-digester</artifactId> <version>1.8</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.2</version> </dependency>
  • 5. 5 <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.0.6</version> </dependency> <!-- JSF/JSTL/Facelets --> <dependency> <groupId>javax.faces</groupId> <artifactId>jsf-api</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>javax.faces</groupId> <artifactId>jsf-impl</artifactId> <version>1.2_04</version> </dependency> <dependency> <groupId>com.sun.facelets</groupId> <artifactId>jsf-facelets</artifactId> <version>1.1.11</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>javax.el</groupId> <artifactId>el-api</artifactId> <version>1.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.sun.el</groupId> <artifactId>el-ri</artifactId> <version>1.0</version> </dependency> </dependencies> <build> <finalName>simpleWeb</finalName> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <version>2.4</version> <configuration> <downloadSources>false</downloadSources> <wtpversion>1.5</wtpversion> </configuration> </plugin> </plugins>
  • 6. 6 </pluginManagement> </build> <repositories> <repository> <id>maven-repository.dev.java.net</id> <name>Java Dev Net Repository</name> <url>http://download.java.net/maven/2/</url> <releases> <enabled>true</enabled> <updatePolicy>never</updatePolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> </project> Step 2: Exit out of eclipse and run the following maven command in a command prompt: C:tutorialssimpleWeb>mvn eclipse:clean eclipse:eclipse STEP: WorkAround The JSF 1.2 requires eclipse web facet 2.5. You need to open the file “org.eclipse.wst.common.project.facet.core.xml” under C:tutorialssimpleWeb.settings as shown below from version=2.4 to version=2.5. Every time you use the eclipse:clean command, you will have to manually fix this up as shown below. Step 3: Get back into eclipse and refresh the simpleWeb project by highlighting it and pressing “F5”. Now right click and select “Properties”.
  • 7. 7 Since simpleWeb depends on simple maven2 has transitively brought all it dependencies into the simpleWeb’s build path. In order to build a war file inside eclipse (pom.xml file is useful for building war file and deploying externally) you need to define the J2EE module dependencies inside eclipse by right clicking on simpleWeb and then selecting “Properties” and then “J2EE module depndencies”. We need most jar files except for the el-api-1.0.jar & servlet-api-2.3.jar. Make sure that these 2 jars are not ticked because they are available under Tomcat’s lib directory. All the ticked jar files end up in “/WEB-INF/lib” directory when packaged inside Eclipse. When you package it outside eclipse using mvn command “mvn clean package” pom.xml file will be used for packaging these dependency jar files under “/WEB-INF/lib” inside the war file
  • 8. 8 Step 4: Let’s make the following changes for this tutorial App.java in simple project package com.mytutorial; import java.util.ArrayList; import java.util.List; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class App { public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext( "applicationContext- mytutorial.xml"); List<Course> courses = new ArrayList<Course>(10); Course c1 = new Course(); c1.setName("John"); c1.setCourse("Java"); courses.add(c1); Course c2 = new Course(); c2.setName("Peter"); c2.setCourse("Hibernate"); courses.add(c2); //CourseService service = new CourseServiceImpl(); CourseService service = (CourseService) ctx.getBean("courseService"); service.processCourse(courses); List<Course> listCourses = service.getCourses(); //added System.out.println("Retrieved courses and names are " + listCourses); //added } } CourseService.java in simple project package com.mytutorial; import java.util.List; public interface CourseService { public abstract void processCourse(List<Course> courses); public abstract List<Course> getCourses(); //added }
  • 9. 9 CourseServiceImpl.java in simple project package com.mytutorial; import java.util.List; public class CourseServiceImpl implements CourseService { private CourseDao courseDao; public CourseDao getCourseDao() { return courseDao; } public void setCourseDao(CourseDao courseDao) { this.courseDao = courseDao; } //Modified public void processCourse(List<Course> courses) { // CourseDao dao = new CourseDaoImpl(); courseDao.create(courses); } //Added public List<Course> getCourses() { List<Course> list = getCourseDao().findAll(); return list; } } CourseControllerBean.java in simpleWeb project package com.mytutorial; import java.util.List; public class CourseControllerBean { private CourseService courseService; // injected via spring public List<Course> getCourses(){ return getCourseService().getCourses(); } public CourseService getCourseService() { return courseService; } public void setCourseService(CourseService courseService) { this.courseService = courseService; } } greeting.jspx in simpleWeb project <?xml version="1.0" encoding="ISO-8859-1" ?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" version="2.0">
  • 10. 10 <ui:composition> <html> <head> <title>greeting page</title> </head> <body> <f:loadBundle basename="com.mytutorial.messages" var="msg" /> <h3><h:outputText value="#{msg.greeting_text}" />, <h:outputText value="#{personBean.personName}" /> <h:outputText value="#{msg.sign}" /></h3> <h:dataTable id="courses" value="#{courseBean.courses}" var="course" border="1"> <h:column> <f:facet name="header"> <h:outputText value="Name" /> </f:facet> <h:outputText value="#{course.name}" /> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Course" /> </f:facet> <h:outputText value="#{course.course}" /> </h:column> </h:dataTable> </body> </html> </ui:composition> </jsp:root>
  • 11. 11 applicationContext.xml in simpleWeb project <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <bean id="person" class="com.mytutorial.PersonBean" /> <bean id="personBean" class="com.mytutorial.PersonControllerBean" scope="session"> <property name="person" ref="person" /> </bean> <bean id="courseBean" class="com.mytutorial.CourseControllerBean" scope="session"> <property name="courseService" ref="courseService" /> </bean> </beans>
  • 12. 12 finally the web.xml file. web.xml in simpleWeb project: find both spring applicationContext files. <context-param> <param-name>contextConfigLocation</param-name> <param-value> <![CDATA[ /WEB-INF/applicationContext.xml classpath:applicationContext-mytutorial.xml ]]> </param-value> </context-param> The web.xml file should look like: <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>server</param-value> </context-param> <context-param> <param-name>javax.faces.CONFIG_FILES</param-name> <param-value>/WEB-INF/faces-config.xml</param-value> </context-param> <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.jspx</param-value> </context-param> <context-param> <param-name>contextConfigLocation</param-name> <param-value> <![CDATA[ /WEB-INF/applicationContext.xml classpath:applicationContext-mytutorial.xml ]]> </param-value> </context-param>
  • 13. 13 <!-- Special Debug Output for Development --> <context-param> <param-name>facelets.DEVELOPMENT</param-name> <param-value>true</param-value> </context-param> <!-- Optional JSF-RI Parameters to Help Debug --> <context-param> <param-name>com.sun.faces.validateXml</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>com.sun.faces.verifyObjects</param-name> <param-value>true</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> <!-- Faces Servlet --> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- Faces Servlet Mapping --> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> </web-app> Step 5: Now install the “simple” project into maven repository with the new changes by: C:tutorialssimple>mvn clean install This should install the “simple-1.0-SNAPSHOT.jar” under “C:java.m2repositorycommytutorialsimple1.0-SNAPSHOT”. Refresh the simpleWeb project inside eclipse. Now Republish/package the simpleWeb project inside eclipse and start the Tomcat Server.
  • 14. 14 Make sure that your Database server is running: C:javahsqldb>java -cp ./lib/hsqldb.jar org.hsqldb.Server
  • 15. 15 Also preferably run the “DatabaseManeger” C:javahsqldb>java -cp ./lib/hsqldb.jar org.hsqldb.util.DatabaseManager This will spawn a new window as shown: Now open internet browser and type the following URL. http://localhost:8080/simpleWeb/index.jsf
  • 16. 16 Click on link “Click Me”. Click on button “Hello” The Name & Course are empty. Now let’s add some name and courses into the database either via SQL statements in “DatabaseManager” or by running the App.java. Make sure that your HSQLDB database server is running. To run App.java inside eclipse right click on “App.java” and then select “Run As” and then select “Java Application”. After it has finished running go back to your internet explorer and click on refresh button.
  • 17. 17 That’s all to it. Please feel free to email any errors to [email protected]. Also stay tuned at http://www.lulu.com/java-success for more tutorials and Java/J2EE interview resources.
  • 18. 18 Tutorial 10 – Maven 2 You may have noticed that there are some code repeats in pom.xml files in simple and simpleWeb projects. Maven2 child pom.xml files can inherit from parent pom.xml file. In this tutorial let’s clean up our project structures and the pom.xml files. Step 1: Exit out of eclipse and restructure your projects under C:tuitorials as follows: Create a new folder “simple-tutorial” under “c:tutorials” and move the “simple” & “simpleWeb” under “simple-tutorial”. Step 2: Add the parent pom.xml under “c:tutorialssimple-tutorial” as shown below. The parent pom.xml file will be shared by both the pom.xml files under “c:tutorialssimple-tutorialsimple” and “c:tutorialssimple-tutorialsimpleWeb”. c:tutorialssimple-tutorialpom.xml (parent pom.xml) <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.mytutorial</groupId> <artifactId>simple-tutorial</artifactId> <packaging>pom</packaging> <name>simple tutorials</name> <description>simple tutorials</description> <version>1.0</version> <url>http://www.lulu.com/java-success</url> <inceptionYear>2007</inceptionYear> <developers> <developer> <name>Arulkumaran</name> <id>ak1</id> <email>[email protected]</email> <organization></organization>
  • 19. 19 <roles> <role>Senior Java Designer/Developer</role> </roles> <timezone>+10</timezone> </developer> </developers> <contributors> <contributor> <name>Sivayini</name> <email></email> <organization></organization> <roles> <role>Java Developer</role> </roles> </contributor> </contributors> <modules> <module>simple</module> <module>simpleWeb</module> </modules> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <version>2.4</version> <configuration> <downloadSources>false</downloadSources> <wtpversion>1.5</wtpversion> </configuration> </plugin> </plugins> </pluginManagement> </build> <repositories> <repository> <id>maven-repository.dev.java.net</id> <name>Java Dev Net Repository</name> <url>http://download.java.net/maven/2/</url> <releases> <enabled>true</enabled> <updatePolicy>never</updatePolicy> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> </project>
  • 20. 20 c:tutorialssimple-tutorialsimplepom.xml (child pom.xml) <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.mytutorial</groupId> <artifactId>simple-tutorial</artifactId> <version>1.0</version> </parent> <groupId>com.mytutorial</groupId> <artifactId>simple</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>simple</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate</artifactId> <version>3.2.4.ga</version> </dependency> <dependency> <groupId>hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>1.8.0.7</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.0.6</version> </dependency> </dependencies> </project> As you can see above this pom.xml file extends the parent pom.xml. All the repositories and plugins are shared from the parent pom.xml file. c:tutorialssimple-tutorialsimpleWebpom.xml (child pom.xml) <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven- v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.mytutorial</groupId>
  • 21. 21 <artifactId>simple-tutorial</artifactId> <version>1.0</version> </parent> <groupId>com.mytutorial</groupId> <artifactId>simpleWeb</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>simpleWeb Maven Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>com.mytutorial</groupId> <artifactId>simple</artifactId> <version>1.0-SNAPSHOT</version> <type>jar</type> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>commons-digester</groupId> <artifactId>commons-digester</artifactId> <version>1.8</version> </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.2</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.0.6</version> </dependency> <!-- JSF/JSTL/Facelets --> <dependency> <groupId>javax.faces</groupId> <artifactId>jsf-api</artifactId> <version>1.2</version> </dependency> <dependency> <groupId>javax.faces</groupId> <artifactId>jsf-impl</artifactId> <version>1.2_04</version> </dependency> <dependency> <groupId>com.sun.facelets</groupId> <artifactId>jsf-facelets</artifactId> <version>1.1.11</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.1.2</version>
  • 22. 22 </dependency> <dependency> <groupId>javax.el</groupId> <artifactId>el-api</artifactId> <version>1.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.sun.el</groupId> <artifactId>el-ri</artifactId> <version>1.0</version> </dependency> </dependencies> <build> <finalName>simpleWeb</finalName> <pluginManagement/> </build> </project> Step 3: Run mvn commands. This time you can run from “C:tutorialssimple-tutorial” to build both “simple” & “simpleWeb”. This is possible due to <modules> definition in parent pom.xml file. <modules> <module>simple</module> <module>simpleWeb</module> </modules> Now run the following command for eclipse: C:tutorialssimple-tutorial>mvn eclipse:clean eclipse:eclipse
  • 23. 23 STEP: WorkAround The JSF 1.2 requires eclipse web facet 2.5. You need to open the file “org.eclipse.wst.common.project.facet.core.xml” under C:tutorialssimple- tutorialsimpleWeb.settings as shown below from version=2.4 to version=2.5. Every time you use the eclipse:clean command, you will have to manually fix this up as shown below. Run the following command: C:tutorialssimple-tutorial>mvn clean install Step 4: Open up your eclipse workspace at “C:javaeclipse-tutorial-workspace”. You will get a screen as follows:
  • 24. 24 Delete the “simple” & “simpleWeb” (select “Do not delete contents” and pres OK ) projects and import them again.
  • 25. 25
  • 26. 26 Step 5: Publish the war file inside eclipse.
  • 27. 27 After publishing, run the Tomcat Server. Step 6: Run the HSQLDB server in a command prompt and also open the “DatabaseManager” in another command prompt. Make sure that your Database server is running: C:javahsqldb>java -cp ./lib/hsqldb.jar org.hsqldb.Server Also preferably run the “DatabaseManeger” C:javahsqldb>java -cp ./lib/hsqldb.jar org.hsqldb.util.DatabaseManager This will spawn a new window as shown:
  • 28. 28 Open an internet browser and type the URL http://localhost:8080/simpleWeb/index.jsf That’s all to it. Also try deploying outside Tomcat. Stop the Tomcat server inside eclipse.
  • 29. 29 If you already have a “simpleWeb” folder under “C:javaTomcat6.0webapps” delete it first. Then copy the “simpleWeb.war” into Tomcat’s “C:javaTomcat6.0webapps” folder. Double click on “tomcat6.exe” to start the server. Open an internet browser and type the URL http://localhost:8080/simpleWeb/index.jsf You can find some fundamental Questions & Answers relating to Hibernate/Spring under “Emerging technologies/framework” section in Java/J2EE Job Interview Companion at http://www.lulu.com/content/192463 Please feel free to email any errors to [email protected]. Also stay tuned at http://www.lulu.com/java-success for more tutorials and Java/J2EE interview resources.