zoukankan      html  css  js  c++  java
  • Building Seam 2.0 Application with NetBeans 6.1(Maven2)

    Building Seam 2.0 Application with NetBeans 6.1(Maven2)


    转载请保留作者信息:

    Author: 88250

    Blog: http:/blog.csdn.net/DL88250

    MSN & Gmail & QQ: DL88250@gmail.com



    Introduction

    This article depicts how to build a simple registration application base on JBoss Seam 2.0(JSF with Facelets, EJB3, JPA) using NetBeans 6.1, and deploys it on Glassfish v2, MySQL 5.1.

    To the demonstration building, I divide the its content into two ways:

    • Using NetBeans built-in project wizard to create a enterprise application, which includes a ejb project and a web project. You can get the details here.

    • Using Maven for NetBeans plugin to create a enterprise application, also it includes a ejb project and a web project. This entry will use this way to build the sample application.


    All of these, will deploy on Glassfish V2 and use MySQL 5.1 community edition. As I mentioned formerly, this demo using Facelets framework for JSF view definition, the most important thing is it setup with NetBeans IDE with Maven2 support and deploys on Glassfish v2. Although you maybe refer to jee-booking example in JBoss Seam tutorial, there are some practical issues you will occur. So, Just follow me! :-)


    Prerequisites

    In this sample application, I use Facelets as JSF view definition framework, it is a very elegant presentation for JSF.

    Seam glimpse

    As we known, Seam is a powerful open source development platform for building rich Internet applications in Java. Seam integrates technologies such as Asynchronous JavaScript and XML (AJAX), JavaServer Faces (JSF), Java Persistence (JPA), Enterprise Java Beans (EJB 3.0) and Business Process Management (BPM) into a unified full-stack solution, complete with sophisticated tooling. The simple chart of architectural design will show you about this:




    The following demonstration will show you a part of features Seam brought.


    Set up SeamMaven application

    In this section, I will mention some important notices of creating seam application using NetBeans IDE with Maven.


    Create Projects

      Open NetBeans IDE, and create a maven application project, named SeamMaven. Changes the packing to pom. Creates three maven application project in SeamMaven root directory, named SeamMaven-ear, SeamMaven-ejb, SeamMaven-war, respectively. And, changes the packing to ear, ejb, war correspondingly.


    pom.xml of SeamMaven

    Modify your pom.xml like this:

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

    <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.mycompany</groupId>

    <artifactId>SeamMaven</artifactId>

    <packaging>pom</packaging>

    <version>1.0-SNAPSHOT</version>

    <name>SeamMaven</name>

    <url>http://maven.apache.org</url>

    <modules>

    <module>SeamMaven-ejb</module>

    <module>SeamMaven-war</module>

    <module>SeamMaven-ear</module>

    </modules>

    <build>

    <plugins>

    <plugin>

    <artifactId>maven-compiler-plugin</artifactId>

    <version>2.0.2</version>

    <configuration>

    <source>1.6</source>

    <target>1.6</target>

    </configuration>

    </plugin>

    </plugins>

    </build>

    <repositories>

    <repository>

    <id>repository.jboss.org</id>

    <name>JBoss Repository</name>

    <url>http://repository.jboss.org/maven2</url>

    </repository>

    <repository>

    <id>maven.search</id>

    <name>Maven Search Org</name>

    <url>http://www.mvnsearch.org/maven2</url>

    </repository>

    <repository>

    <id>maven.java.net</id>

    <name>Java.net Maven2 Repository</name>

    <url>http://download.java.net/maven/2</url>

    </repository>

    </repositories>

    </project>


    pom.xml of SeamMaven-ear

    Modify your pom.xml like this:

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

    <project>

    <parent>

    <artifactId>SeamMaven</artifactId>

    <groupId>com.mycompany</groupId>

    <version>1.0-SNAPSHOT</version>

    </parent>

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mycompany</groupId>

    <artifactId>SeamMaven-ear</artifactId>

    <name>SeamMaven-ear</name>

    <packaging>ear</packaging>

    <version>1.0-SNAPSHOT</version>

    <url>http://maven.apache.org</url>

    <dependencies>

    <!-- JBoss Seam -->

    <dependency>

    <groupId>org.jboss.seam</groupId>

    <artifactId>jboss-seam</artifactId>

    <version>2.0.3.CR1</version>

    <type>ejb</type>

    </dependency>

    <!-- Our EJB module & WAR module -->

    <dependency>

    <groupId>com.mycompany</groupId>

    <artifactId>SeamMaven-ejb</artifactId>

    <version>1.0-SNAPSHOT</version>

    <type>ejb</type>

    </dependency>

    <dependency>

    <groupId>com.mycompany</groupId>

    <artifactId>SeamMaven-war</artifactId>

    <version>1.0-SNAPSHOT</version>

    <type>war</type>

    </dependency>

    </dependencies>

    <build>

    <plugins>

    <!-- Glassfish deployment -->

    <plugin>

    <groupId>org.glassfish.maven.plugin</groupId>

    <artifactId>maven-glassfish-plugin</artifactId>

    <version>2.1</version>

    <executions>

    <execution>

    <goals>

    <goal>deploy</goal>

    </goals>

    </execution>

    </executions>

    <configuration>

    <glassfishDirectory>/home/daniel/Work/glassfish-v2ur2/</glassfishDirectory>

    <user>admin</user>

    <passwordFile>/home/daniel/.asadminpass</passwordFile>

    <autoCreate>true</autoCreate>

    <echo>true</echo>

    <terse>true</terse>

    <debug>false</debug>

    <domain>

    <name>domain1</name>

    <adminPort>4848</adminPort>

    <httpPort>8080</httpPort>

    </domain>

    <components>

    <component>

    <name>${artifactId}</name>

    <artifact>target/${artifactId}-${version}.${packaging}</artifact>

    </component>

    </components>

    </configuration>

    </plugin>

    </plugins>

    </build>

    </project>

      Notice: pay more attention on the contents between <build> and </build>. In the section, I use a maven plugin to deploy application into Glassfish. Optionally, you can use other plugin for deployment, such as exec to invoke Glassfish administration console asadmin.

    pom.xml of SeamMaven-ejb

    Modify your pom.xml like this:

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

    <project>

    <parent>

    <artifactId>SeamMaven</artifactId>

    <groupId>com.mycompany</groupId>

    <version>1.0-SNAPSHOT</version>

    </parent>

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mycompany</groupId>

    <artifactId>SeamMaven-ejb</artifactId>

    <name>SeamMaven-ejb</name>

    <packaging>ejb</packaging>

    <version>1.0-SNAPSHOT</version>

    <url>http://maven.apache.org</url>

    <dependencies>

    <!-- JBoss Seam -->

    <dependency>

    <groupId>org.jboss.seam</groupId>

    <artifactId>jboss-seam</artifactId>

    <version>2.0.3.CR1</version>

    <exclusions>

    <exclusion>

    <artifactId>el-api</artifactId>

    <groupId>javax.el</groupId>

    </exclusion>

    <exclusion>

    <artifactId>jboss-el</artifactId>

    <groupId>org.jboss.el</groupId>

    </exclusion>

    </exclusions>

    </dependency>

    <dependency>

    <groupId>jboss</groupId>

    <artifactId>jboss-common-core</artifactId>

    <version>2.0.4.GA</version>

    <exclusions>

    <exclusion>

    <artifactId>jboss-common-logging-spi</artifactId>

    <groupId>jboss</groupId>

    </exclusion>

    <exclusion>

    <artifactId>webdavlib</artifactId>

    <groupId>apache-slide</groupId>

    </exclusion>

    <exclusion>

    <artifactId>commons-httpclient</artifactId>

    <groupId>apache-httpclient</groupId>

    </exclusion>

    <exclusion>

    <artifactId>xml-apis</artifactId>

    <groupId>apache-xerces</groupId>

    </exclusion>

    <exclusion>

    <artifactId>concurrent</artifactId>

    <groupId>oswego-concurrent</groupId>

    </exclusion>

    </exclusions>

    </dependency>

    <!-- JavaEE -->

    <dependency>

    <groupId>javax.faces</groupId>

    <artifactId>jsf-api</artifactId>

    <version>1.2_08</version>

    </dependency>

    <dependency>

    <groupId>javax.ejb</groupId>

    <artifactId>ejb-api</artifactId>

    <version>3.0</version>

    <scope>provided</scope>

    </dependency>

    <dependency>

    <groupId>javax.persistence</groupId>

    <artifactId>persistence-api</artifactId>

    <version>1.0</version>

    </dependency>

    <!-- Hibernate -->

    <dependency>

    <groupId>org.hibernate</groupId>

    <artifactId>hibernate</artifactId>

    <version>3.2.6.ga</version>

    <exclusions>

    <exclusion>

    <artifactId>dom4j</artifactId>

    <groupId>dom4j</groupId>

    </exclusion>

    <exclusion>

    <artifactId>jta</artifactId>

    <groupId>javax.transaction</groupId>

    </exclusion>

    <exclusion>

    <artifactId>asm-attrs</artifactId>

    <groupId>asm</groupId>

    </exclusion>

    </exclusions>

    </dependency>

    <dependency>

    <groupId>org.hibernate</groupId>

    <artifactId>hibernate-annotations</artifactId>

    <version>3.3.1.GA</version>

    <exclusions>

    <exclusion>

    <artifactId>ejb3-persistence</artifactId>

    <groupId>org.hibernate</groupId>

    </exclusion>

    </exclusions>

    </dependency>

    <dependency>

    <groupId>org.hibernate</groupId>

    <artifactId>hibernate-validator</artifactId>

    <version>3.0.0.GA</version>

    </dependency>

    <dependency>

    <groupId>org.hibernate</groupId>

    <artifactId>hibernate-entitymanager</artifactId>

    <version>3.3.2.GA</version>

    </dependency>

    <dependency>

    <groupId>org.hibernate</groupId>

    <artifactId>hibernate-commons-annotations</artifactId>

    <version>3.3.0.ga</version>

    </dependency>

    <!-- Other the third-party libs -->

    <dependency>

    <groupId>concurrent</groupId>

    <artifactId>concurrent</artifactId>

    <version>1.3.4</version>

    </dependency>

    <dependency>

    <groupId>javassist</groupId>

    <artifactId>javassist</artifactId>

    <version>3.3.GA</version>

    </dependency>

    <dependency>

    <groupId>dom4j</groupId>

    <artifactId>dom4j</artifactId>

    <version>1.6.1</version>

    <exclusions>

    <exclusion>

    <artifactId>xml-apis</artifactId>

    <groupId>xml-apis</groupId>

    </exclusion>

    </exclusions>

    </dependency>

    <dependency>

    <groupId>asm</groupId>

    <artifactId>asm</artifactId>

    <version>1.5.3</version>

    </dependency>

    <dependency>

    <groupId>antlr</groupId>

    <artifactId>antlr</artifactId>

    <version>2.7.6</version>

    </dependency>

    <dependency>

    <groupId>cglib</groupId>

    <artifactId>cglib</artifactId>

    <version>2.1_3</version>

    </dependency>

    <dependency>

    <groupId>commons-logging</groupId>

    <artifactId>commons-logging</artifactId>

    <version>1.1</version>

    <exclusions>

    <exclusion>

    <artifactId>avalon-framework</artifactId>

    <groupId>avalon-framework</groupId>

    </exclusion>

    <exclusion>

    <artifactId>log4j</artifactId>

    <groupId>log4j</groupId>

    </exclusion>

    <exclusion>

    <artifactId>logkit</artifactId>

    <groupId>logkit</groupId>

    </exclusion>

    <exclusion>

    <artifactId>servlet-api</artifactId>

    <groupId>javax.servlet</groupId>

    </exclusion>

    </exclusions>

    </dependency>

    <dependency>

    <groupId>commons-collections</groupId>

    <artifactId>commons-collections</artifactId>

    <version>3.0</version>

    </dependency>

    </dependencies>

    <build>

    <plugins>

    <plugin>

    <groupId>org.apache.maven.plugins</groupId>

    <artifactId>maven-ejb-plugin</artifactId>

    <configuration>

    <ejbVersion>3.0</ejbVersion>

    </configuration>

    </plugin>

    </plugins>

    <finalName>SeamMaven-ejb</finalName>

    </build>

    <properties>

    <netbeans.hint.deploy.server>J2EE</netbeans.hint.deploy.server>

    </properties>

    </project>


    pom.xml of SeamMaven-war

    Modify your pom.xml like this:

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

    <project>

    <parent>

    <artifactId>SeamMaven</artifactId>

    <groupId>com.mycompany</groupId>

    <version>1.0-SNAPSHOT</version>

    </parent>

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.mycompany</groupId>

    <artifactId>SeamMaven-war</artifactId>

    <packaging>war</packaging>

    <name>SeamMaven-war</name>

    <version>1.0-SNAPSHOT</version>

    <url>http://maven.apache.org</url>

    <build>

    <finalName>SeamMaven-war</finalName>

    </build>

    <dependencies>

    <dependency>

    <groupId>com.mycompany</groupId>

    <artifactId>SeamMaven-ejb</artifactId>

    <version>1.0-SNAPSHOT</version>

    <type>ejb</type>

    <exclusions>

    <exclusion>

    <artifactId>antlr</artifactId>

    <groupId>antlr</groupId>

    </exclusion>

    <exclusion>

    <artifactId>asm</artifactId>

    <groupId>asm</groupId>

    </exclusion>

    <exclusion>

    <artifactId>cglib</artifactId>

    <groupId>cglib</groupId>

    </exclusion>

    <exclusion>

    <artifactId>commons-collections</artifactId>

    <groupId>commons-collections</groupId>

    </exclusion>

    <exclusion>

    <artifactId>commons-logging</artifactId>

    <groupId>commons-logging</groupId>

    </exclusion>

    <exclusion>

    <artifactId>concurrent</artifactId>

    <groupId>concurrent</groupId>

    </exclusion>

    <exclusion>

    <artifactId>dom4j</artifactId>

    <groupId>dom4j</groupId>

    </exclusion>

    <exclusion>

    <artifactId>ehcache</artifactId>

    <groupId>net.sf.ehcache</groupId>

    </exclusion>

    <exclusion>

    <artifactId>ejb3-persistence</artifactId>

    <groupId>org.hibernate</groupId>

    </exclusion>

    <exclusion>

    <artifactId>hibernate</artifactId>

    <groupId>org.hibernate</groupId>

    </exclusion>

    <exclusion>

    <artifactId>hibernate-annotations</artifactId>

    <groupId>org.hibernate</groupId>

    </exclusion>

    <exclusion>

    <artifactId>persistence-api</artifactId>

    <groupId>javax.persistence</groupId>

    </exclusion>

    <exclusion>

    <artifactId>jsf-api</artifactId>

    <groupId>javax.faces</groupId>

    </exclusion>

    <exclusion>

    <artifactId>jboss-common-core</artifactId>

    <groupId>jboss</groupId>

    </exclusion>

    <exclusion>

    <artifactId>hibernate-commons-annotations</artifactId>

    <groupId>org.hibernate</groupId>

    </exclusion>

    <exclusion>

    <artifactId>hibernate-entitymanager</artifactId>

    <groupId>org.hibernate</groupId>

    </exclusion>

    <exclusion>

    <artifactId>javassist</artifactId>

    <groupId>javassist</groupId>

    </exclusion>

    <exclusion>

    <artifactId>hibernate-validator</artifactId>

    <groupId>org.hibernate</groupId>

    </exclusion>

    <exclusion>

    <artifactId>jboss-seam</artifactId>

    <groupId>org.jboss.seam</groupId>

    </exclusion>

    </exclusions>

    </dependency>

    <!-- JBoss Seam UI && EL-->

    <dependency>

    <groupId>org.jboss.seam</groupId>

    <artifactId>jboss-seam-ui</artifactId>

    <version>2.0.3.CR1</version>

    <exclusions>

    <exclusion>

    <artifactId>commons-beanutils</artifactId>

    <groupId>commons-beanutils</groupId>

    </exclusion>

    <exclusion>

    <artifactId>dom4j</artifactId>

    <groupId>dom4j</groupId>

    </exclusion>

    <exclusion>

    <artifactId>jboss-seam</artifactId>

    <groupId>org.jboss.seam</groupId>

    </exclusion>

    </exclusions>

    </dependency>

    <dependency>

    <groupId>org.jboss.el</groupId>

    <artifactId>jboss-el</artifactId>

    <version>2.0.1.GA</version>

    <exclusions>

    <exclusion>

    <artifactId>el-api</artifactId>

    <groupId>javax.el</groupId>

    </exclusion>

    </exclusions>

    </dependency>

    <dependency>

    <groupId>org.jboss.seam</groupId>

    <artifactId>jboss-seam</artifactId>

    <version>2.0.3.CR1</version>

    <exclusions>

    <exclusion>

    <artifactId>dom4j</artifactId>

    <groupId>dom4j</groupId>

    </exclusion>

    <exclusion>

    <artifactId>javassist</artifactId>

    <groupId>javassist</groupId>

    </exclusion>

    </exclusions>

    </dependency>

    <!-- Facelets -->

    <dependency>

    <groupId>com.sun.facelets</groupId>

    <artifactId>jsf-facelets</artifactId>

    <version>1.1.9</version>

    </dependency>

    <!-- JSF Implementation -->

    <!--

    <dependency>

    <groupId>javax.faces</groupId>

    <artifactId>jsf-impl</artifactId>

    <version>1.2_08</version>

    </dependency>

    -->

    </dependencies>

    <properties>

    <netbeans.hint.deploy.server>J2EE</netbeans.hint.deploy.server>

    </properties>

    </project>


    Application related configurations and sources

    These JavaEE application related configuration files, like ejb-jar.xml, persistence.xml, web.xml faces-config.xml and JBoss Seam application related configuration files, like components.xml, pages.xml and project code sources you can find here.


    The End....

    In this article, I introduce the basic configurations of an JBoss Seam 2 application, how to build it with NetBeans IDE and maven, and deploy it on Glassfish V2. If you will create your own seam application, the important is the various of configuration files and library dependencies. I think, we should pay more attention on them, and configure them carefully.

    Here, you can download the whole sample application and the PDF document of this article.

    References

  • 相关阅读:
    el自定义函数库
    DOM4J
    【转载】SqlServer日期时间函数
    【原创】C#认识/理解/运用 StreamReader,StreamWriter,StringReader,StreamWriter
    【原创】C#认识/理解/运用 FileStream
    【原创】C#操作XML(带命名空间)
    【原创】ASP.NET MVC3使用html编辑器(kindeditor)
    【原创】ASP.NET MVC3 从零开始一步步构建Web
    【转载】MVC使用jqGrid
    【原创】C#使用HttpWebRequest,HttpWebResponse
  • 原文地址:https://www.cnblogs.com/lanzhi/p/6470005.html
Copyright © 2011-2022 走看看