= トラブルとその解消 = == プロダクションモードでエラー(--%prod) == {{{ play run --%prod }}} などとしてプロダクションモードで動作させると、エラーが発生する。 [[https://play.lighthouseapp.com/projects/57987-play-framework/tickets/1082]] つまり、Application/index.scala.htmlからwelcomeタグを削除しろとのこと。 Javaではうまく行くのに、なぜScalaではダメなのか不明。 == サンプルがうまく動かない == 例えば、modules/scala-0.9.1/samples-and-tests/zencontactをまるごと別のディレクトリにコピーして動作させようとしても「action not found」等のエラーが出て動作しない。 このとき、tmpディレクトリを見てみると、scalaソースが一切コンパイルされていないことがわかる。 これは、先の「もともとの位置」でしか動作しないようにconfigされているためと思われる。このサンプルの動作にはscala-0.9.1が必要であるが、この指定はconf/application.confの中の「module.scala=../..」の部分であるようだ。つまり、zoncontactの上の上のパスがscala-0.9.1でなければならない。 これを解消するには、(おそらく)module.scala=を書き換えるか、次のようにmodulesディレクトリに必要モジュールの情報を記述する。 * modulesディレクトリを作成する。 * そこにscala-0.9.1というファイルを作成する。 * その中に「c:\....\play-*\modules\scala-0.9.1」などとモジュールへの絶対パスを記述する。 == 複数のデータベースを扱いたい == 2011/6/30現在のリリースバージョンでは公式には不可能。もしかしたら抜け道があるかもしれないが、単一のDBを扱う方法しか提供されていない。-->自前でjava.sql.Connectionを管理すれば可能。 ただし、gitのマニュアルには以下のような記述があり、既に複数データベースを扱う方法がコミット済であると思われる。 {{{ Support for multiple databases You can configure Play to use multiple (separate) databases. The default database is configured by configuration parameters in conf/application.conf whose keys start with ‘db.’ (e.g: db.url). To configure an additional database, add an underscore and a suffix to the ‘db’ part of the key, like this: db_other.url=jdbc:mysql://localhost/test db_other.driver=com.mysql.jdbc.Driver db_other.user=root db_other.pass= This database configuration is now called ‘other’ in Play. For example, configure JPA for this ‘other’ configuration like this: db_other.jpa.dialect= You can then access this configuration from your application’s Java code like this: Connection conn = DB.getDBConfig("other").getConnection() DB.getDBConfig(configName) returns an Object with all the methods you usually find as statics methods in the play.db.DB class. }}} しかし、これもいかにもとってつけたような方法である。これは設定ファイルに書きこむ方法であるので、実行時にデータベースを指定することができない。