手元に環境があったので、ちょっと古いのですが、JBoss5.0.1 + Seam 2.1.1でSeamアプリを作成する方法について確認をしてみました。Mac OS X で動作させています。
次のような環境を用意しています。workspace/seam-genはプロジェクトを置くための作業用ディレクトリです。
/Users/user001/Desktop/workspace/seam-gen /Users/user001/applications/jboss-5.0.1.GA /Users/user001/applications/jboss-seam-2.1.1.GA
seam setup を次のようにすると、対話的に値を指定できます。これで、seam-gen/build.propertiesファイルが生成されます。
$ cd ~/applications/jboss-seam-2.1.1.GA/ $ chmod 755 seam $ JAVA_HOME=/Library/Java/Home ./seam setup SEAM_HOME: . Using seam-gen sources from: ./seam-gen Buildfile: ./seam-gen/build.xml init: setup: [echo] Welcome to seam-gen :-) [input] Enter your Java project workspace (the directory that contains your Seam projects) [C:/Projects] [C:/Projects] /Users/user001/Desktop/workspace/seam-gen [input] Enter your JBoss AS home directory [C:/Program Files/jboss-4.2.3.GA] [C:/Program Files/jboss-4.2.3.GA] /Users/user001/applications/jboss-5.0.1.GA [input] Enter the project name [myproject] [myproject] sampleproject [echo] Accepted project name as: sampleproject [input] Do you want to use ICEfaces instead of RichFaces [n] (y, [n]) [input] skipping input as property icefaces.home.new has already been set. [input] Select a RichFaces skin [classic] (blueSky, [classic], deepMarine, DEFAULT, emeraldTown, japanCherry, ruby, wine) japanCherry [input] Is this project deployed as an EAR (with EJB components) or a WAR (with no EJB support) [ear] ([ear], war) [input] Enter the Java package name for your session beans [com.mydomain.sampleproject] [com.mydomain.sampleproject] com.example.sampleproject.session [input] Enter the Java package name for your entity beans [com.example.sampleproject.session] [com.example.sampleproject.session] com.example.sampleproject.entity [input] Enter the Java package name for your test cases [com.example.sampleproject.session.test] [com.example.sampleproject.session.test] com.example.sampleproject.test [input] What kind of database are you using? [hsql] ([hsql], mysql, oracle, postgres, mssql, db2, sybase, enterprisedb, h2) [input] Enter the Hibernate dialect for your database [org.hibernate.dialect.HSQLDialect] [org.hibernate.dialect.HSQLDialect] [input] Enter the filesystem path to the JDBC driver jar [/Users/user001/Applications/jboss-seam-2.1.1.GA/lib/hsqldb.jar] [/Users/user001/Applications/jboss-seam-2.1.1.GA/lib/hsqldb.jar] [input] Enter JDBC driver class for your database [org.hsqldb.jdbcDriver] [org.hsqldb.jdbcDriver] [input] Enter the JDBC URL for your database [jdbc:hsqldb:.] [jdbc:hsqldb:.] [input] Enter database username [sa] [sa] [input] Enter database password [] [] [input] Enter the database schema name (it is OK to leave this blank) [] [] [input] Enter the database catalog name (it is OK to leave this blank) [] [] [input] Are you working with tables that already exist in the database? [n] (y, [n]) [input] Do you want to drop and recreate the database tables and data in import.sql each time you deploy? [n] (y, [n]) [propertyfile] Creating new property file: /Users/user001/Applications/jboss-seam-2.1.1.GA/seam-gen/build.properties [echo] Installing JDBC driver jar to JBoss AS [copy] Copying 1 file to /Users/user001/applications/jboss-5.0.1.GA/server/default/lib [echo] Type './seam create-project' to create the new project BUILD SUCCESSFUL Total time: 1 minute 3 seconds
できあがるファイルは「/Users/user001/Applications/jboss-seam-2.1.1.GA/seam-gen/build.properties」ではなく、「/Users/user001/applications/jboss-seam-2.1.1.GA/seam-gen/build.properties」です。なぜApplicationsと表示されるのかは謎。
#Generated by seam setup #Tue Jun 19 09:34:53 JST 2012 hibernate.connection.password= workspace.home=/Users/user001/Desktop/workspace/seam-gen model.package=com.example.sampleproject.entity driver.jar=/Users/user001/Applications/jboss-seam-2.1.1.GA/lib/hsqldb.jar action.package=com.example.sampleproject.session test.package=com.example.sampleproject.test database.type=hsql richfaces.skin=japanCherry hibernate.default_catalog.null= hibernate.default_schema.null= database.drop=n project.name=sampleproject hibernate.connection.username=sa hibernate.connection.driver_class=org.hsqldb.jdbcDriver hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider project.type=ear icefaces.home= database.exists=n jboss.home=/Users/user001/applications/jboss-5.0.1.GA hibernate.dialect=org.hibernate.dialect.HSQLDialect hibernate.connection.url=jdbc\:hsqldb\:. icefaces=n
seamの設定が終わったら、次のようにしてプロジェクトを生成します。
$ JAVA_HOME=/Library/Java/Home ./seam create-project
無事生成されると、それでもう準備OKです。/Users/user001/Desktop/workspace/seam-gen/SeamGenSample/ に必要なファイルができあがっているはずです。Eclipseへインポートすることもできますし、NetBeansへインポートすることもできます。
略 create-project: [echo] A new Seam project named 'sampleproject' was created in the /Users/user001/Desktop/workspace/seam-gen directory [echo] Type './seam explode' and go to http://localhost:8080/sampleproject [echo] Eclipse Users: Import the project using File > Import... > Existing Projects into Workspace, set the root directory to /Users/user001/Desktop/workspace/seam-gen, then select the project named sampleproject [echo] NetBeans Users: Open the project using File > Open project... and select the project folder /Users/user001/Desktop/workspace/seam-gen/sampleproject [echo] IDEA Users: Open the project using File > Open project... and select the file /Users/user001/Desktop/workspace/seam-gen/sampleproject/sampleproject.ipr BUILD SUCCESSFUL Total time: 12 seconds
とりあえず、次のようにしてseam explodeすると、JBossへ展開した形でファイルがデプロイされます。動作確認をするには、JBossを起動してから、http://localhost:8080/sampleproject へWebブラウザからアクセスしてみます。
$ JAVA_HOME=/Library/Java/Home ./seam explode $ /Users/user001/applications/jboss-5.0.1.GA/bin/run.sh
HSQLDBをサーバーモードで動かすのはなぜかうまくいきませんでした。DBの設定周りについて、下記のような感じにすれば良いはずなのですが…
hsql org.hibernate.dialect.HSQLDialect org.hsqldb.jdbcDriver jdbc:hsqldb:hsql://localhost/ sa
また、HSQLDBをサーバモードで起動するためにhsqldb-ds.xmlの修正が必要なので、standaloneモードからserverモードへ変更したのですが…
$ cat ~/applications/jboss-5.0.1.GA/server/default/deploy/hsqldb-ds.xml <?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>DefaultDS</jndi-name> <connection-url>jdbc:hsqldb:hsql://${jboss.bind.address}:1701</connection-url> <!-- <connection-url>jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}localDB</connection-url> --> <driver-class>org.hsqldb.jdbcDriver</driver-class> <user-name>sa</user-name> <password></password> <min-pool-size>0</min-pool-size> <max-pool-size>20</max-pool-size> <idle-timeout-minutes>0</idle-timeout-minutes> <track-statements/> <security-domain>HsqlDbRealm</security-domain> <prepared-statement-cache-size>32</prepared-statement-cache-size> <!-- <depends>jboss:service=Hypersonic,database=localDB</depends> --> <depends>jboss:service=Hypersonic</depends> </local-tx-datasource> <mbean code="org.jboss.jdbc.HypersonicDatabase" name="jboss:service=Hypersonic"> <attribute name="Port">1701</attribute> <attribute name="BindAddress">${jboss.bind.address}</attribute> <attribute name="Silent">true</attribute> <attribute name="Database">default</attribute> <attribute name="Trace">false</attribute> <attribute name="No_system_exit">true</attribute> </mbean> <!-- <mbean code="org.jboss.jdbc.HypersonicDatabase" name="jboss:service=Hypersonic,database=localDB"> <attribute name="Database">localDB</attribute> <attribute name="InProcessMode">true</attribute> </mbean> --> </datasources>
こちらは、DataSourceまわりの設定のところで何か問題が起きていると考えられるので、また別途確認をすることにします。そもそも、いまどきだと、JBoss7を使うのが普通でしょうから、この組み合わせはちょっと古いですよね…