It's all about the answers!

Ask a question

Howto use Websphere datasource on operation advisor


1
1
Paco Rosselló (1112) | asked Apr 30 '11, 2:39 p.m.
Hi,
I try to use java.sql.Connection to connect to db2 database in an operation advisor . I have defined on Websphere one Datasource and it works fine in web context, but when I try to use in operation advisor I get this exception :
00000012 SystemErr R javax.naming.NoInitialContextException: Failed to create InitialContext using factory specified in hashtable {java.naming.provider.url=corbaloc:rir:/NameServiceServerRoot, java.naming.factory.url.pkgs=com.ibm.ws.naming:com.ibm.ws.runtime:com.ibm.iscportal.jndi}

Does anyone knows how to acces to a Datasource defined in Websphere from an operation advisor? Is it possible?

I also tried to make a direct connection to db2 using Class.forName() but then I got java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver.

Is there any way to make available db2 jars to my advisor?

Thanks

Bests regards.

Paco Rossell

2 answers



permanent link
Nils Müller-Sheffer (1136) | answered Sep 07 '12, 4:46 a.m.
Hi Paco,

have you ever solved this? I am facing the exact same problem.

I even need to make it work in a generic way on both Tomcat and WebSphere.

I think the (somewhat hacky) solution is to temporarily change the ContextClassLoader to the classloader that loads the jazzbridgeservlet oder (equinox) bridgeservlet, because only the Web Container classloader will have those JNDI contexts.

Still, I am struggeling and could not yet make it work. Would be grateful for any pointers / example config.

ClassLoader origCL = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(BridgeServlet.class.getClassLoader());
            initDataSource();
        } finally {
            Thread.currentThread().setContextClassLoader(origCL);
        }

permanent link
Jose Miguel Ordax Cassa (2.4k4126100) | answered Jan 30 '14, 9:02 a.m.
I posted a solution that worked for me in this other thread: https://jazz.net/forum/questions/119205/accessing-to-java-ee-datasource-from-an-extension?page=1&focusedAnswerId=140516#140516

Hope it helps,

     Chemi.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.