Satish,
How are you creating the mail session? Jboss (and other appservers)
allow you to configure Javamail sessions and export the session config
via a JNDI name. In your application, you should use JNDI to retrieve
this information. So here is what you do. Find the file
<jboss_home>/server/default/deploy/mail-service.xml and check the
settings define in it, in particular these ones (I'm pretty sure the
defaults are useless) :
<!-- Change to the mail server -->
<property name="mail.pop3.host" value="localhost"/>
<!-- Change to the SMTP gateway server -->
<property name="mail.smtp.host" value="localhost"/>
<!-- Change to the address mail will be from -->
<property name="mail.from" value="[EMAIL PROTECTED]"/>
Now when you start Jboss, the mail session config will be exported to
JNDI name "java:/Mail". Now to get the session you do something like
this in your code:
String serviceName = "java:/Mail";
InitialContext initialContext = new InitialContext();
// Lookup app server mail service name for session properties
Session session = (Session) initialContext.lookup(serviceName);
The rest is easy !
Hope this helps
Steve
> -----Original Message-----
> From: Satish [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, July 09, 2003 5:15 AM
> To: 'James Users List'
> Subject: Access to default session denied
>
>
> Hi,
>
> I am using JBoss application server and running a JSP + EJB
> application on that. In my application, after a new user
> registers, an email should be sent to the user with the
> password. I used Java Mail API and tried to send that email
> through JAMES SMTP.
>
> This works fine for the first time, but from second instance
> onwards, I'm getting the following error:
>
> java.lang.SecurityException: Access to default session denied
>
> And if I restart JBoss server, it once agains works fine -
> but only the first time.
>
> What could be the reason? Any clue?
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]