Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Howto use Websphere datasource on operation advisor

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

1

1 vote



2 answers

Permanent link
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);
        }

0 votes


Permanent link
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.

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Apr 30 '11, 2:39 p.m.

Question was seen: 6,115 times

Last updated: Jan 30 '14, 9:02 a.m.

Confirmation Cancel Confirm