This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JForum and the fly likes Setting the 'forum.link' property, and exceptions from transactional mail Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » JForum
Bookmark "Setting the Watch "Setting the New topic
Author

Setting the 'forum.link' property, and exceptions from transactional mail

robert crowther
Ranch Hand

Joined: Oct 19, 2013
Posts: 41
    
  10
Not sure this is a 'bug'. How about calling it a 'chaotic slump'?

The forum is generally working. But (especially on deployment), email returns,

java.lang.StringIndexOutOfBoundsException: String index out of range: -1

This is an evil error to trace, because it may occur only on deployment, the cause is deep in class, relies on configuration, and is located in utility code. It took me 2 hours.

There is nothing amiss in the mail software or configuration (you may know this already). The issue is in ViewCommon.getForumLink(), as used as a utility by the mail code.



If forum.link property in SystemGlobals is set,



then the property is returned 'null' (not the empty string). This will work for relative addressing, all kinds of JForum activity, but not for email path construction code.

The cleanest solution did not seem to be extra code, nor setting the property to '/'. For example, this property sets the domain name in emails (make it "/" and there will be no domain name). So, even if templating uses relative URLs, even if the action results in different deployment configurations, I'd use the full domain, without a trailing '/',




and email authentication now works.
robert crowther
Ranch Hand

Joined: Oct 19, 2013
Posts: 41
    
  10
I think saw some earlier posts on problems with email which may have been related to this...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Setting the 'forum.link' property, and exceptions from transactional mail
 
Similar Threads
Proble in sending email thru java program
Jforum SSO - restrict direct forum access => redirect to login page if not loged in please help!!!
easiest way to send an email from a java program?
StaleStateException on session.flush()
Advice is not working in JOIDS