开发者

I can't get the sessionmail on the WAS

开发者 https://www.devze.com 2023-03-27 15:17 出处:网络
I\'m using a Websphere application server 7.0 : And I try to get the session mail which is implement on the WAS in Ressources/Mail/Mail sessions.

I'm using a Websphere application server 7.0 :

And I try to get the session mail which is implement on the WAS in Ressources/Mail/Mail sessions.

Here's my code :

InitialContext ctx;
    try {
        Context env = (Context) new InitialContext().lookup("java:comp/env");
        Session sess = (Session) env.lookup("mail/GmailSessionName");
    } catch (NamingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace(); 
    }

The error I get is :

javax.naming.NameNotFoundException: Name mail not found in context "java:comp/env".

Someone can help me ?

Shou开发者_如何转开发ld I put something in web.xml to link java and was?


Try this:

InitialContext ctx = new InitialContext();
Session sess = (Session) ctx.lookup("java:app/mail/GmailSessionName");

or

InitialContext ctx = new InitialContext();
Session sess = (Session) ctx.lookup("java:global/mail/GmailSessionName");


Try

InitialContext ctx = new InitialContext();
Session sess = (Session) ctx.lookup("mail/GmailSessionName");

Also, see this simple JSP you can deploy to test looking up objects by various names. (It uses the default InitialContext(), but you can edit it to do otherwise if you want.


java:comp/env is the local name space.

The actual services reside in the Global name space.

As part of your deployment you map the elements in the local name space to their corresponding values in the global name space for all this to work.

The elements in the local name space are defined in the code, and are present in the DDs.

Each of these values in the DD is bound during the deployment activity.

Hope this give you a good idea to get started in trouble shooting this.

HTH

Manglu

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号