Miles to go …

September 4, 2009

TOTD #101: Applying Servlet 3.0/Java EE 6 “web-fragment.xml” to Lift – Deploy on GlassFish v3

Filed under: frameworks, glassfish, javaee, totd — Tags: , , , — arungupta @ 3:00 am

TOTD #100 explained how to deploy Lift framework applications on GlassFish v3. As explained in TOTD #91, Java EE 6 defines how the framework configuration deployment descriptor can be defined in “META-INF/web-fragment.xml” in the JAR file of the framework instead of mixing it with "WEB-INF/web.xml" which is intended for application deployment descriptor aspects.

This Tip Of The Day (TOTD) explains how to leverage ”web-fragment.xml” to deploy a Lift application on a Java EE 6 compliant container. The original "lift-*.jar" files are untouched and instead a new JAR file is included that contains only the framework configuration deployment descriptor.

The generated "web.xml" from TOTD #100 looks like:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!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>
<filter>
 <filter-name>LiftFilter</filter-name>
 <display-name>Lift Filter</display-name>
 <description>The Filter that intercepts lift calls</description>
 <filter-class>net.liftweb.http.LiftFilter</filter-class>
</filter>

<filter-mapping>
 <filter-name>LiftFilter</filter-name>
 <url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>

The deployment descriptor defines a Servlet Filter (LiftFilter) that registers the Lift framework with the Web container. And then it defines a URL mapping to "/*". All of this information is required by the Lift framework for request dispatching. And so that makes this fragment suitable for "web-fragment.xml".

Here are simple steps to make this change:

  1. Remove “src/main/webapp/WEB-INF/web.xml” because no application specific deployment descriptors are required.
  2. Include “lift-web-fragment.jar” in the “WEB-INF/lib” of your application by adding the following fragment in your “pom.xml”:

    <dependencies>
    
    . . .
    
      <!– web-fragment –>
      <dependency>
        <groupId>org.glassfish.extras</groupId>
        <artifactId>lift-web-fragment</artifactId>
        <version>1.0</version>
        <scope>runtime</scope>
      </dependency>
    </dependencies>
    
    . . .
    
    <repositories>
      <repository>
        <id>maven2-repository.dev.java.net</id>
        <name>Java.net Repository for Maven</name>
        <url>http://download.java.net/maven/2/</url>
      </repository>
    </repositories>
    

    This file contains only “META-INF/web-fragment.xml” with the following content:

    <web-fragment>
     <filter>
     <filter-name>LiftFilter</filter-name>
     <display-name>Lift Filter</display-name>
     <description>The Filter that intercepts lift calls</description>
     <filter-class>net.liftweb.http.LiftFilter</filter-class>
     </filter>
    
     <filter-mapping>
     <filter-name>LiftFilter</filter-name>
     <url-pattern>/*</url-pattern>
     </filter-mapping>
    </web-fragment>
    
    
  3. Create the WAR file without “web.xml” by editing “pom.xml” and adding the following fragment:

    <build>
       . . .
      <plugins>
        . . .
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-war-plugin</artifactId>
          <version>2.1-beta-1</version>
          <configuration>
            <failOnMissingWebXml>false</failOnMissingWebXml>
          </configuration>
        </plugin>
      </plugins>
    </build>
    

That’s it, now now you can create a WAR file using “mvn package” and deploy this web application on GlassFish v3 latest promoted build (61 as of today) as explained in TOTD #100.

Technorati: totd glassfish v3 lift scala javaee6 servlet web-fragment

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • email
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot
Related posts:
  1. TOTD #91: Applying Java EE 6 “web-fragment.xml” to Apache Wicket – Deploy on GlassFish v3
  2. TOTD #100: Getting Started with Scala Lift on GlassFish v3
  3. TOTD #93: Getting Started with Java EE 6 using NetBeans 6.8 M1 & GlassFish v3 – A simple Servlet 3.0 + JPA 2.0 app
  4. TOTD #102: Java EE 6 (Servlet 3.0 and EJB 3.1) wizards in Eclipse
  5. TOTD #99: Creating a Java EE 6 application using MySQL, JPA 2.0 and Servlet 3.0 with GlassFish Tools Bundle for Eclipse

9 Comments »

  1. Sir,

    I request to resolve my queries, As suggested I have sent the queries to users ID but there was no reply.
    please sir there is no other hope here in india as there are limited resources and I am not able to afford the costlier trainings in metros.

    –>I now know that how to develop the webservice its client. but when it comes to real deployment of the webservice on the host servers and the point at which we need to provide client with their files of webservice.

    1. what are the further procedures after an webservice is developed on the netbeans tool?

    2. what files need to be supplied to client who requested us to prepare an webservice for him?

    3. currently we are calling the webservice on the localhost, whenever we will deploy the service on the host server,accordingly what changes need to be made or what parameters need to be emphasised in the client files to access the webservice on host server and how (because there is much difference accessing the service at localhost and at remote servers?

    4. If my client is designed in PHP or any other technology, to send the request to the webservice at remote server what parameters and what procedure we need to follow to be able to map both the technology and also serve the purpose?

    5.which platforms to be used, Axis2,Xfire or metro etc ?

    Sir I know the questions are long enough, but you are the only ray of hope. as i am wandering around from days for these questions. surely your previous suggestion of that link helped but I need to know as mentioned in the 5 queries above.

    awaiting response.

    Comment by Dipakkumar Patil — September 4, 2009 @ 7:26 am

  2. v4Baqe vvibjmnajlop, [url=http://buvnqhcekoke.com/]buvnqhcekoke[/url], [link=http://xxxtpuiysinz.com/]xxxtpuiysinz[/link], http://rxrmpujfiljx.com/

    Comment by evprjt — October 29, 2009 @ 11:37 pm

  3. viagra de pobre and viagra ciclismo and como tomar sildenafil and cialis andorra and costo de cialis

    Comment by viagra-de-pobre — November 5, 2009 @ 6:01 am

  4. cheapest phentermine online and recent news on cymbalta and zithromax iv and soma muscle relaxer and viagra sample

    Comment by cheapest-phentermine — November 9, 2009 @ 12:05 am

  5. ajanta kamagra and viagra auf rezept and cialis 20mg fta and cialis sicher kaufen and

    Comment by ajanta-kamagra — November 9, 2009 @ 12:05 am

  6. levitra cena and levitra cialis and levitra dose and viagra tablets and levitra effects

    Comment by levitra-cena — November 9, 2009 @ 12:05 am

  7. adipex d no perscription or canada adipex diet pills or buy brand name adipex without prescription or adipex p how it works or adipex fedex

    Comment by adipex-d-no-perscrip — March 31, 2010 @ 1:12 pm

  8. actos buenos or diazepam 1 mg or zolpidem winthrop 10 mg or venta de viagra sin receta or venta de viagra en madrid

    Comment by actos-buenos — April 9, 2010 @ 11:16 pm

  9. lorazepam vida media or actos de lenguaje or concerta wellbutrin or cipro caffeine or viagra ecuador

    Comment by lorazepam-vida-media — April 9, 2010 @ 11:16 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Powered by WordPress