JSLEE Discussions
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Oracle Driver problems
Forum Index » Rhino SLEE Discussions
Author Message
mweber


Joined: 27/03/2008 00:52:45
Messages: 11
Offline

Hi,

How can I load oracle driver into slee.

I've found post on this forum that describes how to load driver (data source):

https://developer.opencloud.com/devportal/pages/viewpage.action?pageId=4883089

so, I tried to repeat steps described in that post.

1. define connection pool in rhino-config.xml
2. set CLASSPATH to point to oracle jar file (in start-rhino.bat file for win)
3. in setSbbContext save a reference to the DataSource object that you obtained from JNDI

however, sbb couldn't see this oracle jar file (I thought it should be loaded) so I prepared library (all oracle classes included) and install it on Rhino.
After that SBB is able to see jar, still, if I try to invoke getConnection method on datasource reference I'm always receiving NullPointerException.

Do you have any Idea what could be the reason. Mybe I'm doing something wrong?
bsd

[Avatar]

Joined: 22/03/2008 00:37:15
Messages: 355
Location: Cambridge, UK
Offline

Hi,

From your description, seems that you forgot to define the datasource in the extension deployment descriptor of the sbb.

The Knowledge Base entry you mention didn't describe the complete process (we've change that). Have another look at the KB entry and Chapter 7 - External Databases - in the Deployement and Administration Guide.

The Location JDBC service included in the SIP examples is also a good reference.

Bruno


Bruno Duarte
Technical Consultant
OpenCloud
[Email] [WWW]
mweber


Joined: 27/03/2008 00:52:45
Messages: 11
Offline

Hi,

Actually, I followed steps from that chapter, including extension deployment descriptor (oc-sbb.xml).

Indeed, Location JDBC service is good example how to use external data-source. I have almost the same code; followed everything, still NullPointerException occurs when I try to get connection.

Mario
bsd

[Avatar]

Joined: 22/03/2008 00:37:15
Messages: 355
Location: Cambridge, UK
Offline

Hi Mario,

Can you please post here the relevant parts of the source code and the deployment descriptors?!

Bruno

Bruno Duarte
Technical Consultant
OpenCloud
[Email] [WWW]
mweber


Joined: 27/03/2008 00:52:45
Messages: 11
Offline

Bruno,

thx for your help.

here are the steps:

in Rhino-config.xml following element is added:

<jdbc>
<jndi-name>OracleDB</jndi-name>
<datasource-class>oracle.jdbc.pool.OracleDataSource</datasource-class>
<parameter>
<param-name>URL</param-name>
<param-type>java.lang.String</param-type>
<param-value>jdbc:oracle:thin:@something:1521:something</param-value>
</parameter>
<parameter>
<param-name>databaseName</param-name>
<param-type>java.lang.String</param-type>
<param-value>orka</param-value>
</parameter>
<parameter>
<param-name>user</param-name>
<param-type>java.lang.String</param-type>
<param-value>something</param-value>
</parameter>
<parameter>
<param-name>password</param-name>
<param-type>java.lang.String</param-type>
<param-value>something</param-value>
</parameter>
<parameter>
<param-name>loginTimeout</param-name>
<param-type>java.lang.Integer</param-type>
<param-value>30</param-value>
</parameter>
<connection-pool>
<max-connections>15</max-connections>
<idle-check-interval>0.0</idle-check-interval>
</connection-pool>
</jdbc>

After that in start-rhino.bat I've added path to my oracel driver jar file

set RUNTIME_CLASSPATH=%RUNTIME_CLASSPATH%;lib\ojdbc14.jar

I've created library from this ojdbc14.jar file so the SBB could work with some classes inside this jar. For that I needed to add reference to this library in SBB:

<library-ref>
<description>Oracle lib</description>
<library-name>Oracle Library</library-name>
<library-vendor>Kate Kom</library-vendor>
<library-version>1.0</library-version>
</library-ref>

Before installing service sbb i have installed this library.

To reach data source I've put resource-ref into oc-sbb.xml

<resource-ref>
<res-ref-name>jdbc/OracleDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
<res-jndi-name>jdbc/OracleDB</res-jndi-name>
</resource-ref>

and inside setSbbContext in Service Sbb fetching datasource is done like this:

public void setSbbContext(SbbContext context)
{
super.setSbbContext(context);
try {
Context myEnv = (Context) new InitialContext().lookup("java:comp/env");
ds = (DataSource) myEnv.lookup("jdbc/OracleDB");
} catch (NamingException ne) {
severe("Could not set SBB context", ne);
}
}

After calling setSbbContext everything looks fine (no exception), but when you call following line NullPointerException occurs:

Connection conn = ds.getConnection();

I've tried with ds.getConnection("userName", "password") with the same exception.

If you need I can put whole exception.

bsd

[Avatar]

Joined: 22/03/2008 00:37:15
Messages: 355
Location: Cambridge, UK
Offline

The configuration seems to be OK.

Yes. Please, post the complete exception and if possible set to DEBUG the keys associated with JDBC (resources.jdbc*) and send us the Rhino log.

Bruno Duarte
Technical Consultant
OpenCloud
[Email] [WWW]
mweber


Joined: 27/03/2008 00:52:45
Messages: 11
Offline

resources.jdbc.* set to DEBUG mode. Here is log copied from console:

2008-10-27 14:00:46.656 Fine [trace.JDBCTest_1_0.JDBCTestSbb] <jr-2> [JDBCTest/JDBCTestSbb] *** JDBCTestSbb SBBPostCreate ***
2008-10-27 14:00:46.656 Info [trace.JDBCTest_1_0.JDBCTestSbb] <jr-2> [JDBCTest/JDBCTestSbb] Invite received.
2008-10-27 14:00:46.656 Info [trace.JDBCTest_1_0.JDBCTestSbb] <jr-2> [JDBCTest/JDBCTestSbb] Trying to fetch connection....
2008-10-27 14:00:46.656 Info [trace.JDBCTest_1_0.JDBCTestSbb] <jr-2> [JDBCTest/JDBCTestSbb] ****************Datasource: com.opencloud.ob.RhinoSDK.be@c2b8eb**********************
2008-10-27 14:00:46.656 Info [trace.JDBCTest_1_0.JDBCTestSbb] <jr-2> [JDBCTest/JDBCTestSbb] ****************Datasource loginTimeout: 30****************
2008-10-27 14:00:46.656 DEBUG [resource.jdbc.datasource] <jr-2> getConnection() TransactionId:[101:90]
2008-10-27 14:00:46.656 DEBUG [resource.jdbc.datasource] <jr-2> allocating new connection
2008-10-27 14:00:46.656 WARN [rhino.er.stage.eh] <jr-2> sbb invocation threw exception, causing transaction to be marked for rollback
javax.slee.TransactionRolledbackLocalException: Unchecked exception thrown by sbbDeliverEvent
at com.opencloud.ocbb.container.impl.Util.makeRollbackException(13782:14)
at com.opencloud.deployed.Service_JDBCTest_Kate_Kom_1_0_15.SBB_JDBCTestSbb_Kate_Kom_1_0OCBB_Local.sbbDeliverEvent(SBB_JDBCTestSbb_Kate_Kom_1_0OCBB_Local.java:518)
at com.opencloud.ob.RhinoSDK.Q.a(13782:164)
at com.opencloud.ob.RhinoSDK.Q.a(13782:136)
at com.opencloud.ob.RhinoSDK.Q.d(13782:88)
at com.opencloud.ob.RhinoSDK.qy.run(13782:76)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at com.opencloud.ob.RhinoSDK.dF$a$a$a.run(13782:320)
Caused by: java.lang.NullPointerException
at com.katekom.ocm.jdbc.JDBCTestSbb.onInviteRequest(Unknown Source)
at com.opencloud.rhino.deployed.sbb.Kate_Kom.JDBCTestSbb_1_0.SbbOCBBBean.sbbDeliverEvent(SbbOCBBBean.java:327)
at com.opencloud.deployed.Service_JDBCTest_Kate_Kom_1_0_15.SBB_JDBCTestSbb_Kate_Kom_1_0OCBB_Local.sbbDeliverEvent(SBB_JDBCTestSbb_Kate_Kom_1_0OCBB_Local.java:506)
... 7 more
2008-10-27 14:00:46.688 Fine [trace.JDBCTest_1_0.JDBCTestSbb] <jr-3> [JDBCTest/JDBCTestSbb] *** JDBCTestSbb SBBPostCreate ***

log file is attached.
 Filename rhino.log [Disk] Download
 Description rhino log file
 Filesize 45 Kbytes
 Downloaded:  5 time(s)

stevena


Joined: 27/03/2008 13:43:16
Messages: 274
Location: Cambridge, UK
Offline

Hi Mario,

I have a few comments.

so, I tried to repeat steps described in that post.
...
2. set CLASSPATH to point to oracle jar file (in start-rhino.bat file for win)
...
however, sbb couldn't see this oracle jar file (I thought it should be loaded) so I prepared library (all oracle classes included) and install it on Rhino.


Any classes added to Rhino's boot classpath will be visible to all SLEE components installed into Rhino, so creating a library as well should be both unnecessary and redundant. The only thing I can think of that could be an issue is that in Windows the start-rhino.bat file is generated from a template file. I'm not exactly sure when this occurs but it's possible that regeneration of the batch file stomped on the manual changes you previously made to it. I would suggest making the changes to both the .bat and .template files and try again without the library.

Secondly, the setSbbContext() code you quoted doesn't match with the Rhino log you provided. However I can tell you the following from what information you have provided. I can't see anything obviously wrong in the way you have configured the various config files and deployment descriptors, so that's a good thing. However, considering this log message:
2008-10-27 14:00:46.656 Info [trace.JDBCTest_1_0.JDBCTestSbb] <jr-2> [JDBCTest/JDBCTestSbb] Trying to fetch connection....
2008-10-27 14:00:46.656 Info [trace.JDBCTest_1_0.JDBCTestSbb] <jr-2> [JDBCTest/JDBCTestSbb] ****************Datasource: com.opencloud.ob.RhinoSDK.be@c2b8eb**********************

The datasource object class logged here is a Rhino implementation of the javax.sql.Datasource interface so I have to assume that this piece of code:

is working correctly and returning an appropriate datasource object. (The code you quoted doesn't include the trace messages that appear in the Rhino log, so I am assuming you are doing the same thing in the real code you are using.)

If ds != null then where you think the NPE is:

is not actually where it is occurring because we've already asserted that ds != null, and the NPE originates from your SBB code not somewhere within the getConnection() method:
Caused by: java.lang.NullPointerException
        at com.katekom.ocm.jdbc.JDBCTestSbb.onInviteRequest(Unknown Source)


The only suggestion I can make is that you recompile your SBB code with java debugging included (-g option) so that the exception stack trace includes the line number where the NPE occurs, then you can go back to your code and find exactly where the exception originates.

Regards,
Steve

Steven Adams
Senior Software Engineer
OpenCloud
mweber


Joined: 27/03/2008 00:52:45
Messages: 11
Offline

After enabling java debugging (-g options) finally can see root cause. Method getConnection(String, String) is not supported and always throws UnsupportedOperationException. I changed that to getConnection() without parameters, which are loaded from configuration xml file, but now we have new issue.

The connection class I get from Rhino is a wrapper connection class: com.opencloud.ob.RhinoSDK.ub

2008-10-28 11:30:25.126 Fine [trace.JDBCTest_1_0.JDBCTestSbb] <jr-5> [JDBCTest/JDBCTestSbb] *** JDBCTestSbb SBBPostCreate ***
2008-10-28 11:30:25.126 Info [trace.JDBCTest_1_0.JDBCTestSbb] <jr-5> [JDBCTest/JDBCTestSbb] Invite received.
2008-10-28 11:30:25.126 Info [trace.JDBCTest_1_0.JDBCTestSbb] <jr-5> [JDBCTest/JDBCTestSbb] Trying to fetch connection....
2008-10-28 11:30:25.126 Info [trace.JDBCTest_1_0.JDBCTestSbb] <jr-5> [JDBCTest/JDBCTestSbb] ****************Datasource: com.opencloud.ob.RhinoSDK.be@8d63cf**********************
2008-10-28 11:30:25.126 Info [trace.JDBCTest_1_0.JDBCTestSbb] <jr-5> [JDBCTest/JDBCTestSbb] ****************Datasource loginTimeout: 30****************
2008-10-28 11:30:25.126 DEBUG [resource.jdbc.datasource] <jr-5> getConnection() TransactionId:[101:105]
2008-10-28 11:30:25.126 DEBUG [resource.jdbc.datasource] <jr-5> allocating new connection for user null
2008-10-28 11:30:25.126 DEBUG [resource.jdbc.connectionpool] <jr-5> getConnection(): entry
2008-10-28 11:30:25.142 DEBUG [resource.jdbc.connectionpool] <jr-5> getConnection(): space for a new connection (0 < 15)
2008-10-28 11:30:25.142 DEBUG [resource.jdbc.connectionpool] <jr-5> getConnection(): no pooled connection available, acquiring a new one
2008-10-28 11:30:25.454 DEBUG [resource.jdbc.connectionpool] <jr-5> getConnection(): got a new connection: com.opencloud.ob.RhinoSDK.pK@bdfa0e, adding to inusePool
2008-10-28 11:30:25.454 DEBUG [resource.jdbc.connectionpool] <jr-5> getConnection(): returning com.opencloud.ob.RhinoSDK.ub@1fb06c9
2008-10-28 11:30:25.454 Info [trace.JDBCTest_1_0.JDBCTestSbb] <jr-5> [JDBCTest/JDBCTestSbb] Connection retrieved: class com.opencloud.ob.RhinoSDK.ub

I want to create specific OracleCallableStatement class from the ds.getConnection():

OracleCallableStatement cStmt = (OracleCallableStatement) connection.prepareCall("{call GET_PARAMETERS(?, ?, ?, ?)}");
cStmt.setString(1, userID);
cStmt.setString(2, serviceID);
cStmt.registerOutParameter(3, OracleTypes.ARRAY, "PARAMETERNAMES");
cStmt.registerOutParameter(4, OracleTypes.ARRAY, "PARAMETERVALUES");
cStmt.execute();

Now I am getting following exception:

2008-10-28 11:30:25.548 Severe [trace.JDBCTest_1_0.JDBCTestSbb] <jr-5> [JDBCTest/JDBCTestSbb] Exception occured:
java.lang.ClassCastException: com.opencloud.ob.RhinoSDK.pa cannot be cast to oracle.jdbc.OracleCallableStatement
at com.katekom.ocm.jdbc.JDBCTestSbb.onInviteRequest(JDBCTestSbb.java:90)
at com.opencloud.rhino.deployed.sbb.Kate_Kom.JDBCTestSbb_1_0.SbbOCBBBean.sbbDeliverEvent(SbbOCBBBean.java:327)
at com.opencloud.deployed.Service_JDBCTest_Kate_Kom_1_0_23.SBB_JDBCTestSbb_Kate_Kom_1_0OCBB_Local.sbbDeliverEvent(SBB_JDBCTestSbb_Kate_Kom_1_0OCBB_Local.java:419)
at com.opencloud.ob.RhinoSDK.Q.a(13782:164)
at com.opencloud.ob.RhinoSDK.Q.a(13782:136)
at com.opencloud.ob.RhinoSDK.Q.d(13782:88)
at com.opencloud.ob.RhinoSDK.qy.run(13782:76)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at com.opencloud.ob.RhinoSDK.dF$a$a$a.run(13782:320)

How can I get underlying Oracle connection (the one that is returned from OracleDataSource) so that I can use specific Oracle features?
oliver


Joined: 29/10/2008 09:36:04
Messages: 680
Location: Cambridge, UK
Offline

mweber wrote:How can I get underlying Oracle connection (the one that is returned from OracleDataSource) so that I can use specific Oracle features?

You can't, if the Rhino ConnectionPoolDataSource implementation is used.

However the Rhino CPDS implementation is only used if you specify a plain DataSource class in rhino-config.xml. If the Oracle driver provides an implementation of CPDS itself, you could specify that class instead of a plain DataSource implementation (in <datasource-class>). Then you would be dealing with a connection wrapper class provided by the Oracle driver's CPDS implementation, which I'd assume would let you do nonstandard Oracle things.
[Email]
mweber


Joined: 27/03/2008 00:52:45
Messages: 11
Offline

Hi,

I tried as you said. In Rhiino-config.xml now I have this line:

<datasource-class>oracle.jdbc.pool.OracleConnectionPoolDataSource</datasource-class>

oc-sbb.xml is changed to:
<res-ref-name>jdbc/OracleDB</res-ref-name>
<res-type>oracle.jdbc.pool.OracleConnectionPoolDataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
<res-jndi-name>jdbc/OracleDB</res-jndi-name>

and in code I'm expecting oracle data source:

ds = (OracleConnectionPoolDataSource) myEnv.lookup("jdbc/OracleDB");

If I understand you correctly with that line (above) I should get oracle data source which can return oracle connection?

Well, I tried that and got new exception:

2008-10-29 11:16:46.081 WARN [ocbb.container.SBB_JDBCTestSbb_Kate_Kom_1_0OCBB] <StageWorker/GroupRMI/1> BeanFailureException caught creating initial pooled items
**UNHANDLED** com.opencloud.ocbb.container.exceptions.BeanFailureException: While invoking com.opencloud.rhino.deployed.sbb.Kate_Kom.JDBCTestSbb_1_0.SbbOCBBBean.setOCBBContext()
at com.opencloud.deployed.Service_JDBCTest_Kate_Kom_1_0_24.SBB_JDBCTestSbb_Kate_Kom_1_0OCBB_Bean.ocbbRhinoSetOCBBContext(SBB_JDBCTestSbb_Kate_Kom_1_0OCBB_Bean.java:222)
at com.opencloud.ob.RhinoSDK.aZ.a(13782:106)
at com.opencloud.ob.RhinoSDK.oo.initializeObjectPools(13782:115)
at com.opencloud.ob.RhinoSDK.kT.a(13782:45)
at com.opencloud.ob.RhinoSDK.df.a(13782:97)
at com.opencloud.rhino.node.state.ServiceStateImpl.servicesActivated(13782:12)
at com.opencloud.rhino.node.state.ServiceStateImpl__OCSkel.b(13782:51)
at com.opencloud.rhino.node.state.ServiceStateImpl__OCSkel.invoke(13782:11)
at com.opencloud.ob.RhinoSDK.aY.a(13782:218)
at com.opencloud.ob.RhinoSDK.aY.a(13782:27)
at com.opencloud.ob.RhinoSDK.aY$b.run(13782:288)
at com.opencloud.ob.RhinoSDK.bY$b.a(13782:43)
at com.opencloud.ob.RhinoSDK.iP.a(13782:28)
at com.opencloud.ob.RhinoSDK.tp.f(13782:21)
at com.opencloud.ob.RhinoSDK.oQ$a.run(13782:81)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassCastException: com.opencloud.ob.RhinoSDK.be cannot be cast to oracle.jdbc.pool.OracleConnectionPoolDataSource
at com.katekom.ocm.jdbc.JDBCTestSbb.setSbbContext(JDBCTestSbb.java:43)
at com.opencloud.rhino.deployed.sbb.Kate_Kom.JDBCTestSbb_1_0.SbbOCBBBean.setOCBBContext(SbbOCBBBean.java:26)
at com.opencloud.deployed.Service_JDBCTest_Kate_Kom_1_0_24.SBB_JDBCTestSbb_Kate_Kom_1_0OCBB_Bean.ocbbRhinoSetOCBBContext(SBB_JDBCTestSbb_Kate_Kom_1_0OCBB_Bean.java:219)
... 15 more
2008-10-29 11:16:46.128 WARN [rhino.er.stage.eh] <jr-3> Exception thrown when calculating convergence name
javax.slee.TransactionRolledbackLocalException: Bean failure: While invoking com.opencloud.rhino.deployed.sbb.Kate_Kom.JDBCTestSbb_1_0.SbbOCBBBean.setOCBBContext()
at com.opencloud.ocbb.container.impl.Util.makeRollbackException(13782:14)
at com.opencloud.ob.RhinoSDK.aZ.getPooled(13782:280)
at com.opencloud.deployed.Service_JDBCTest_Kate_Kom_1_0_24.SBB_JDBCTestSbb_Kate_Kom_1_0OCBB_LocalHome.initialEventSelect(SBB_JDBCTestSbb_Kate_Kom_1_0OCBB_LocalHome.java:210)
at com.opencloud.ob.RhinoSDK.Q.a(13782:425)
at com.opencloud.ob.RhinoSDK.Q.w(13782:399)
at com.opencloud.ob.RhinoSDK.Q.s(13782:181)
at com.opencloud.ob.RhinoSDK.Q.d(13782:76)
at com.opencloud.ob.RhinoSDK.qy.run(13782:76)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at com.opencloud.ob.RhinoSDK.dF$a$a$a.run(13782:320)
Caused by: java.lang.ClassCastException: com.opencloud.ob.RhinoSDK.be cannot be cast to oracle.jdbc.pool.OracleConnectionPoolDataSource
at com.katekom.ocm.jdbc.JDBCTestSbb.setSbbContext(JDBCTestSbb.java:43)
at com.opencloud.rhino.deployed.sbb.Kate_Kom.JDBCTestSbb_1_0.SbbOCBBBean.setOCBBContext(SbbOCBBBean.java:26)
at com.opencloud.deployed.Service_JDBCTest_Kate_Kom_1_0_24.SBB_JDBCTestSbb_Kate_Kom_1_0OCBB_Bean.ocbbRhinoSetOCBBContext(SBB_JDBCTestSbb_Kate_Kom_1_0OCBB_Bean.java:219)
at com.opencloud.ob.RhinoSDK.aZ.getPooled(13782:277)
... 9 more

If this will not work, do you have any suggestion regarding oracle connection pool? I could put it in RA?

oliver


Joined: 29/10/2008 09:36:04
Messages: 680
Location: Cambridge, UK
Offline

mweber wrote:Hi,

I tried as you said. In Rhiino-config.xml now I have this line:

<datasource-class>oracle.jdbc.pool.OracleConnectionPoolDataSource</datasource-class>

This is correct.


oc-sbb.xml is changed to:
<res-ref-name>jdbc/OracleDB</res-ref-name>
<res-type>oracle.jdbc.pool.OracleConnectionPoolDataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
<res-jndi-name>jdbc/OracleDB</res-jndi-name>

and in code I'm expecting oracle data source:

ds = (OracleConnectionPoolDataSource) myEnv.lookup("jdbc/OracleDB");


Don't make those additional changes. All that is changing is, internally, an Oracle CPDS will be used instead of a Rhino CPDS. Your SBB still continues to see a DataSource in JNDI.

The DataSource you retrieve from JNDI is not the same object as the DataSource configured in rhino-config.xml. There is a layer of connection pooling and transaction management between the two.
[Email]
 
Forum Index » Rhino SLEE Discussions
Go to:   
Powered by JForum 2.1.8 © JForum Team