在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找不到此方案的工厂:TimerManager tm = (TimerManager) ic.lookup("java:/comp/env/tm/TimerManager");
请帮帮忙,非常重要。谢谢
发布于 2017-04-14 05:42:01
尝试使用
java:comp/env/tm/TimerManager代替
java:/comp/env/tm/TimerManager如果这不管用的话。请发布完整的部署描述符和绑定文件(web.xml和ibm-web-bnd.xml或ibm-web-bnd.xmi),以确保这些文件中的配置是正确的。
感谢你张贴这些文件。我认为问题在于web.xml 3.0版与ibm-web-bnd.xmi不兼容。尝试使用带有ibm-web-bnd.xml的web.xml Version3.0,或者使用带有ibm-web-bnd.xmi的早期版本的web.xml。
发布于 2017-04-19 00:41:24
下面是web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>testApp</display-name>
<welcome-file-list>
<welcome-file>/WEB-INF/jsp/index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>test</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
</servlet>
<listener>
<listener-class>
or.tc.pack.context.listener.TestWebContextListener
</listener-class>
</listener>
<!-- The master configuration file for this Spring web application -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/context/testway/webApplication-config-local.xml
</param-value>
</context-param>
<!-- Loads the Spring web application context -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/services/eng/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/services/fra/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>480</session-timeout>
</session-config>
<resource-ref id="ResourceRef_1288099140976">
<description>
Business Update queue</description>
<res-ref-name>jms/ZZZZ_ZZ_ZZZZ_BUS_UPD</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Application</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<description>
</description>
<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>
</web-app>下面是ibm-web-bnd.xmi:
<?xml version="1.0" encoding="UTF-8"?>
<webappbnd:WebAppBinding xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:webappbnd="webappbnd.xmi" xmi:id="WebAppBinding_1263831088044">
<webapp href="WEB-INF/web.xml#WebApp_ID"/>
<resRefBindings xmi:id="ResourceRefBinding_1288099140976" jndiName="customs/commercial/tal/jms/ZZZZ_ZZ_ZZZZ_BUS_UPD">
<bindingResourceRef href="WEB-INF/web.xml#ResourceRef_1288099140976"/>
</resRefBindings>
</webappbnd:WebAppBinding>发布于 2018-05-31 08:03:46
您恢复了有效语法。
在web.xml中:
<res-ref-name>tm/TimerManager</res-ref-name>在源代码中:
ic.lookup("java:comp/env/tm/TimerManager")https://stackoverflow.com/questions/43401312
复制相似问题