我编写了一个包含邮件生成部分的库。这个邮件生成部分使用了Velocity。邮件生成器类如下--
public class mailBuilder {
public void initialize() throws Exception
{
Properties props = new Properties();
log.info("About to set the ClassPath for Velocity specific tasks");
props.setProperty(VelocityEngine.RESOURCE_LOADER, "classpath");
props.setProperty("classpath." + VelocityEngine.RESOURCE_LOADER + ".class", ClasspathResourceLoader.class.getName());
try
{
log.info("Just before");
Velocity.init(props);
log.info("Just after");
}
catch ( Exception e )
{
log.error( "Caught Execption on velocityEngine init", e );
throw new Exception( "Caught Execption on velocityEngine init", e );
}
log.info("Completed initializing Velocity Engine");
}
public String returnMailstring() throws Exception {
initialize();
....
....
}
}
现在当我从eclipse运行和测试这个库时,结果与预期相符,一切看起来都很好。 我有一个Web应用程序,它从UI接收请求,并使用ExecutorService(newSingleThreadExecutor)在后台静默地逐个服务这些用户请求。
我注意到我的对上述库的调用在邮件构建部分特别是Velocity.init(props)处被挂起。没有异常抛出,但线程似乎在VelocityEngine初始化时挂起。我已经在线上进行了搜索,但没有找到解决问题的方法。 希望能得到关于如何解决这个问题的任何帮助。
谢谢, p1ng