業務都合でJava EE7にキャッチアップ。
大昔J2EEはやったし、Sunが悔い改めてEoDを掲げたEJB3?のハンズオンセミナーに参加したことはあるが、一定の距離を置いていた。SpringとかHibernateやってればどうにかなるだろうと思っていたが、書籍をざっと見ると知らないことが多々あることに気づく…。
そうなるとやってみるしかない!
環境は、Win7上で、NetBeansに全てを委ねるという堕落した感じ。DBはMySQLがたまたま入っているという理由で選択。
GlassFishの管理コンソール上で、jdbcのConnection Pools設定で早速試練がw
HTTP Status 500 - Internal Server Error
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.1.1 logs.
これはGlassFishの既知の問題らしく、以下の方法で対処が可能とのこと。
C:\Program Files\glassfish-4.1.1\bin> asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --restype javax.sql.DataSource mySqlPool
JDBC connection pool mySqlPool created successfully.
Command create-jdbc-connection-pool executed successfully.
C:\Program Files\glassfish-4.1.1\bin>
各種プロパティを上記のコマンドで設定する方法が良くわからなかったので、コマンド実行後にGlassFishの管理GUIでプロパティを追加した
PortNumber 3306
Password *******
User root
serverName localhost
DatabaseName MySQL