【发布时间】:2011-12-29 14:06:32
【问题描述】:
我编写了一个包含邮件构建部分的库。这个邮件构建部分使用了 Velocity。 mailbuilder类如下--
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
【问题讨论】:
标签: java initialization velocity