0

In the Web.xml I have:

<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>

In the java code I have:

    TimerManager tm = (TimerManager) ic.lookup("tm/TimerManager");
tm.schedule(new CleanupListener(), 0, 10*1000); // CleanupListener class is my TimerListener

So when I run the code, the Timer kick in successfully but right after the code crash with the following exception:

javax.naming.ConfigurationException: NamingManager.getURLContext cannot find the factory for this scheme: java

I have no idea why. when I change the lookup with this: TimerManager tm = (TimerManager) ic.lookup("java:/comp/env/tm/TimerManager"); This is even worst, the Timer never kick in and I do have this following exception: db.common.util.ServiceLocatorException: javax.naming.ConfigurationException: NamingManager.getURLContext cannot find the factory for this scheme: java

Please help, very important. Thanks

user3648235
  • 169
  • 4
  • 13

3 Answers3

0

Try using

java:comp/env/tm/TimerManager

in place of

java:/comp/env/tm/TimerManager

If that doesn't help. please post your full deployment descriptor and bindings file (web.xml and either ibm-web-bnd.xml or ibm-web-bnd.xmi) to ensure that the configuration within this files is correct.

Thanks for posting the files. I think the problem is that web.xml version 3.0 is not compatible with ibm-web-bnd.xmi. Try either using web.xml version 3.0 with ibm-web-bnd.xml, or otherwise use an earlier version web.xml with ibm-web-bnd.xmi.

njr
  • 3,399
  • 9
  • 7
  • Unsuccessful. I did post a copy of the web.xml and the ibm-web-bnd.xmi files. Thanks for your input and please let me know what you think. – user3648235 Apr 18 '17 at 17:12
  • No sorry the web.xml is version 2.4. That's my bad, I just change to 3.0 just to see desperately if it would change anything. The original file web.xml is version 2.4. Thanks for letting me know if you have any other hint. CHeers! – user3648235 Apr 19 '17 at 19:01
0

Here is the 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>

Here is the 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>
user3648235
  • 169
  • 4
  • 13
0

You reverted valid syntax.

Within web.xml:

<res-ref-name>tm/TimerManager</res-ref-name>

Within source code:

ic.lookup("java:comp/env/tm/TimerManager")
Simon Logic
  • 330
  • 4
  • 10