在 Web.xml 我有:
<resource-ref>
<res-ref-name>java:/comp/env/tm/TimerManager</res-ref-name>
<res-type>commonj.timers.TimerManager</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Unshareable</res-sharing-scope>
</resource-ref>
在我的java代码中:
TimerManager tm = (TimerManager) ic.lookup("tm/TimerManager");
tm.schedule(new CleanupListener(), 0, 10*1000); // CleanupListener class is my TimerListener
因此,当我运行代码时,计时器成功启动,但在代码崩溃后立即出现以下异常:
javax.naming.ConfigurationException:NamingManager.getURLContext 找不到此方案的工厂:java
我不知道为什么。当我用这个更改查找时:TimerManager tm = (TimerManager) ic.lookup("java:/comp/env/tm/TimerManager");
这是最糟糕的,计时器永远不会启动,我确实有以下异常:
db.common.util.ServiceLocatorException: javax.naming.ConfigurationException: NamingManager.getURLContext 找不到该方案的工厂: 爪哇
请帮忙,非常重要。谢谢