1

I have a Weblogic mail session configured on it with (got from weblogic config screen and JNDI tree):

Name: default
JNDI Name: mail/Session
Binding Name: mail.Session
Class: javax.mail.Session
Hash Code: 2112656059
toString Results: javax.mail.Session@7dec92bb

with my only server as target and no security policies configured.

Doing a lookup:

final Properties env = new Properties();

env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://127.0.0.1:7001");

Session session = (Session) context.lookup("mail/Session");

I just get a null reference without any exception. However I'm able to list the JNDI tree remotely and it brings me the right objects:

weblogic
__WL_GlobalJavaApp
_WL_internal_CWI76otjHMIOhcsss1r1f0O7mVbaDE4riYjUFgmDAl9lkzlfET4ZBvPiKD1gPI7x
mail
ejb
javax
java:global
mejbmejb_jarMejb_EO

And inside the mail node, I can find the Session but without a bound object on it:

boundObj= null  
className= null 
fullName= null  
isRel= true 
name= "Session" (id=26) 

I've already tried to provide security access configuring and using Context.SECURITY_PRINCIPAL / Context.SECURITY_CREDENTIALS, besides providing full path (java:/comp/env/mail/Session which throws NameNotFoundException), but nothing has changed.

Does someone has any idea what can be happening?

Any idea would be very helpful...

Thank you all.

Eduardo
  • 11
  • 3
  • I dont know why but this works for me, instead of this : Session session = (Session) context.lookup("mail/Session"); try this : Session session = (Session) context.lookup("mailSession"); – Lrrr Dec 09 '14 at 17:24
  • Or change your JNDI name to mail.Session or mailSession so you avoid having special characters in the lookup – Display Name is missing Dec 09 '14 at 19:17
  • Is your application running on the server, or is it a separate client application? If it's running on the server, you should be able to skip all the env properties and just create "new InitialContext()". I don't think that will solve your problem, but it will simplify your code. – Bill Shannon Dec 09 '14 at 22:47
  • Have you defined a resource reference in your application that's mapped to this mail session resource you've created in the console? If so, you would normally look up such a resource in the "java:comp/env" context. Or are you trying to bypass a resource reference and look up the global resource directly? – Bill Shannon Dec 09 '14 at 22:50
  • @Eduardo, since you haven't responded, I'm assuming you either solved the problem on your own or no longer need to solve this problem. – Bill Shannon Dec 15 '14 at 20:20

0 Answers0