-
1. Re: Mail service doesn't work in JBoss 4.0.4RC1
scotto Mar 14, 2006 3:44 AM (in response to herkules)I've got the same problem with JBoss 4.0.4RC1 in the mail service JNDI lookup always returning null.
From the log:16:42:45,312 INFO [MailService] Mail Service bound to mail/Mail
My code:Context jndiContext = new session = (Session) jndiContext.lookup("mail/Mail"); if( session == null ) { logger.error("JNDI lookup returned null session."); }
Program output:16:46:55,156 [main] ERROR EmailUtils : JNDI lookup returned null session.
Any ideas what is going on? -
2. Re: Mail service doesn't work in JBoss 4.0.4RC1
herkules Mar 14, 2006 4:38 AM (in response to herkules)For me it worked to use:
@Resource(mappedName="java:/Mail")
private Session mailSession;
instead of ctx.lookup. But the lookup should work too I suppose. Bug in RC?
Jan -
3. Re: Mail service doesn't work in JBoss 4.0.4RC1
herkules Mar 14, 2006 4:42 AM (in response to herkules)This can also help you: http://jira.jboss.com/jira/browse/JBAS-2938, mail client requires activation.jar.
-
4. Re: Mail service doesn't work in JBoss 4.0.4RC1
scotto Mar 15, 2006 2:32 AM (in response to herkules)OK I found what the problem is (for my case at least):
The code I was using to request the Session object from JNDI was running as a unit test case external to JBoss itself. (ie. as a JBoss client, rather than as a session bean or mbean). When I put this same code inside a session bean the Session object resolved fine!
Is this a bug or a feature? Should client applications be able to request the MailService from JNDI and get an appropriate remote proxy object?
If this is indeed the desired behaviour, would it not be better to throw some kind of NamingException to indicate that a remote interface is not available for the given object name, rather than just returning null?