- - PR -
JBOSSのmail-service.xmlについて
1
投稿者 | 投稿内容 | ||||
---|---|---|---|---|---|
|
投稿日時: 2008-05-22 15:40
初投稿です。
初めて投稿します。 mail-service.xmlにて、複数のメールリソース定義をしたいのですが xml、javaソースともにどのように定義すればいいのでしょうか? 現在は・・・ [mail-service.xml] <mbean code="org.jboss.mail.MailService" name="jboss:service=Mail"> <attribute name="JNDIName">java:/Mail</attribute> <attribute name="User">test001</attribute> <attribute name="Password">test001</attribute> <attribute name="Configuration"> <!-- 2003/07/05 mail_test --> <configuration> <!-- Change to your mail server prototocol --> <property name="mail.store.protocol" value="pop3"/> <property name="mail.transport.protocol" value="smtp"/> <!-- Change to the user who will receive mail --> <property name="mail.user" value="nobody"/> <!-- Change to the mail server --> <property name="mail.pop3.host" value="xx.xx.xx.xx"/> <!-- Change to the SMTP gateway server --> <property name="mail.smtp.host" value="xx.xx.xx.xx"/> <!-- Change to the address mail will be from --> <!-- Enable debugging output from the javamail classes --> <property name="mail.debug" value="false"/> </configuration> </attribute> </mbean> [java] final Session session = (Session) ServiceLocator.i.lookup("java:comp/env/mail/MailSession"); となっています。 mail-service.xmlに、以下の設定を加えて、javaソースに以下の 記述を追加したら、 javax.naming.NameNotFoundException: Mail2Session not bound が発生しました。 [mail-service.xml 追加] <mbean code="org.jboss.mail.MailService" name="jboss:service=Mail2"> <attribute name="JNDIName">java:/Mail2</attribute> <attribute name="User">test001</attribute> <attribute name="Password">test001</attribute> <attribute name="Configuration"> <configuration> <!-- Change to your mail server prototocol --> <property name="mail.store.protocol" value="pop3"/> <property name="mail.transport.protocol" value="smtp"/> <!-- Change to the user who will receive mail --> <property name="mail.user" value="nobody"/> <!-- Change to the mail server --> <property name="mail.pop3.host" value="xx.xx.xx.xx"/> <!-- Change to the SMTP gateway server --> <property name="mail.smtp.host" value="xx.xx.xx.xx"/> <!-- Enable debugging output from the javamail classes --> <property name="mail.debug" value="false"/> </configuration> </attribute> [java 追加] final Session session = (Session) ServiceLocator.i.lookup("java:comp/env/mail/Mail2Session"); やはり設定が悪いのでしょうか? 宜しくお願いします。 環境 JDK:1.5.0_13 JBOSS:4.0.2 | ||||
|
投稿日時: 2008-05-22 16:07
設定中に Main2Session にバインドする設定が見あたりませんが、どこかに書いてありますか?
web-console の System > JMX MBeans > jboss > jboss:service=JNDIView > list で JNDI の一覧がでます。 そこに Mail2Session は表示されますか? 仕事で利用するのでしたらサポートサブスクリプションを購入するのもオススメです。 [ メッセージ編集済み 編集者: インギ 編集日時 2008-05-22 16:08 ] | ||||
|
投稿日時: 2008-05-22 17:20
インギ様
final Session session = (Session) ServiceLocator.i.lookup("java:comp/env/mail/Mail2Session"); これを、以下のように修正したら出来ました。 final Session session = (Session) ServiceLocator.i.lookup("java:/Mail2"); 単純に、引数に渡したJNDI名がダメだったようです。 なぜ、最初から定義されていた「java:comp/env/mail/MailSession」で JNDI名が取得できるのが不思議ですが・・・ なんとか解決しました。 ありがとうございます。 | ||||
|
投稿日時: 2008-05-23 13:44
J2EE ではリソース名の衝突やハードコーディングを避けるため、アプリケーション内ではアプリケーションローカルの JNDI 名を指定することが推奨されています。 java:comp/env ... で始まるヤツですね。
"Mail"については以下のように jboss-web.xml あたりに resource-ref で参照が定義されていたのではないでしょうか?
"設定中に Main2Session にバインドする設定が見あたりませんが、どこかに書いてありますか? "とは、同様にMail2Session についても参照が定義されているかどうかを尋ねたものです。 うまく設定されていれば JNDIView から見えるようになるはずですよ。 | ||||
|
投稿日時: 2008-05-30 12:55
インギ様
亀レス申し訳ございません・・・ serverフォルダ以下を「jboss-web.xml」で検索したら 5ファイルほどwarファイルの中に同梱されていました。 しかし、どこにもそのような記述が無かったです。。。 とりあえず、mail-service.xmlに記述して乗り切ろうと思います。 |
1