Seam3も新しくなっているので使ってみました。Eclipse + JBoss Tools で手軽に開発できると思ったら、Seam3はまだサポートされていないようで、Forgeを使ってプロジェクトを作るのが簡単なようです。
JBoss Forge については、https://docs.jboss.org/author/display/FORGE/Installationが参考になります。
まず、JBoss Forge をここからダウンロードします。ダウンロードの仕方がちょっとわかりにくいですが、画面右下の Artifact Information タブを開いて、Downloadボタンをクリックするとファイルをダウンロードできます。ここでは、forge-distribution-1.0.3-20120403.192659-4.zip をダウンロードしました。
次のようなforge.shを作成してforgeを起動します。ディレクトリ構成はJBossをインストールしたときと同じです。
#!/bin/sh export JAVA_HOME="$HOME/applications/jdk1.6.0_31" export FORGE_HOME="$HOME/applications/forge-distribution-1.0.3-SNAPSHOT" export JBOSS_HOME="$HOME/applications/jboss-as-7.1.1.Final" export PATH=$PATH:$FORGE_HOME/bin export MAVEN_HOME="$HOME/applications/apache-maven-3.0.4" export PATH=$FORGE_HOME/bin:$JAVA_HOME/bin:$MAVEN_HOME/bin:JBOSS_HOME/bin:$PATH $FORGE_HOME/bin/forge
下記手順を参考にすると、Seam3 の簡単なアプリを作成することができました。
・Generating a basic Java EE web-application – Forge – Project Documentation Editor
具体的にはforgeを起動して、次のような感じで入力
#プロジェクト作成 new-project --named simpleSeam3 --topLevelPackage org.sssg.soft.sample.seam3.simple #scaffoldセットアップ scaffold setup ? No scaffold type was selected, use default [JavaServer Faces]? [Y/n] Y ? Scaffold provider [faces] is not installed. Install it? [Y/n] Y ? Facet [forge.maven.WebResourceFacet] requires packaging type(s) [war], but is currently [jar]. Update packaging? (Note: this could deactivate other plugins in your project.) [Y/n] Y ***SUCCESS*** Installed [forge.maven.WebResourceFacet] successfully. Warning: The encoding 'UTF-8' is not supported by the Java runtime. ***SUCCESS*** Installed [forge.spec.jpa] successfully. : 略 : ? Create scaffold in which sub-directory of web-root? (e.g. http://localhost:8080/simpleSeam3/DIR) [/] Warning: The encoding 'UTF-8' is not supported by the Java runtime. : #永続化設定 persistence setup --provider HIBERNATE --container JBOSS_AS7 ***INFO*** Setting transaction-type="JTA" ***INFO*** Using example data source [java:jboss/datasources/ExampleDS] Warning: The encoding 'UTF-8' is not supported by the Java runtime. ? The JPA provider [HIBERNATE], also supplies extended APIs. Install these as well? [y/N] y Install which version of [org.hibernate:hibernate-entitymanager:::]? : 略 : ? Choose an option by typing the number of the selection [*-default] [0] ***SUCCESS*** Persistence (JPA) is installed. : 略 : #エンティティ作成 entity --named SimpleEntity #エンティティへフィールド追加 field string --named name #確認 ls #エンティティからCRUD作成 scaffold from-entity # build
persistence setup では、provider と container は TAB でオプションを選べるようです。
プロジェクトができたら、Eclipse側で、既存mavenプロジェクトとしてインポートして、JBoss AS 7 で run とします。http://localhost:8080/simpleSeam3/faces/index.xhtml とか、http://localhost:8080/simpleSeam3/faces/simpleEntity/search.xhtml にアクセスすると、基本的なCRUDができるようになっていました。
CDIのjboss-as-helloworld から持ってきた HelloService.java や HelloWorldServlet.java も普通に動きました。jboss-as-helloworldを参考にして、これらのファイルを配備し、http://localhost:8080/simpleSeam3/HelloWorld へアクセスすると表示されました。
スクラッチからの作成例が下記にあるようですが、こちらは試していません。
・quickstart/forge-from-scratch at master · jbossas/quickstart · GitHub
ForgeにはJBoss AS 7 用プラグインがあるようで、次のようにインストールできます。as7 setupで設定ができます。
$ forge install-plugin jboss-as-7 as7 setup
deployなどのコマンドもあります。
as7 deploy as7 redeploy as7 undeploy