Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tomcat with Oracle

Status
Not open for further replies.

jby1

Programmer
Apr 29, 2003
403
GB
Hi

Has anybody successfully managed to get an application running on Tomcat working with an Oracle database? I have my application working fine with Oracle (inc JDBC realm!), but when I try to bring it up with the machine startup (Solaris) I am not getting a connection to Oracle. If this has been encountered before, I would seriously appreciate some help, as I have been banging a head of my wall for over a day on this one!!

I am using a script in /etc/rc3.d to start Tomcat, under the user nobody.
 
I don't know if it makes any difference, but I should mention that I am accessing Oracle through Oracle client.
 
I have worked out a problem (I will not say the problem yet!). The script we are using to invoke tomcat is run by root at the rc3 level. This script defines the environmet (including, in this case, the environment Oracle requires) then calls the tomcat startup with su, to get the user nobody. The problem is that when you call su, all environment variables prefixed with LD_ are dropped, including the all-important Oracle environment LD_LIBRARY_PATH.

I still have no idea how I am going to work around this though!
 
Try to call su without -

Regards, Dima
 
i have tried su both with and without -

without, the LD_LIBRARY_PATH is dropped

with, I need to set up all of the tomcat environment variable in /etc/profile (or somewhere similar), which I do not want to do. Also, that didn't work either!

I do not think that what I am trying to do here is such an outrageous thing, I really cannot understand why it is proving so difficult!
 
You may use thin driver instead. You may also place setting Oracle environment into startup.sh. Is it so complex? You're trying to integrate 2 independant products and complain of the need to set the environment for both :)

Regards, Dima
 
Can't use thin driver as oci is required.

I am not exactly compaining of the need to set up the environment, but I would like to keep things as tidy as possible. At the moment though I don't care about that, I just want it to work! I will try your suggestion about startup.sh, and see where that takes me!

Cheers
 
I have already tried placing Oracle stuff into catalina.sh, but to no avail :-(
 
Can't believe! Have you set all Oracle-related variables? ORACLE_HOME, NLS_LANG and TNS_ADMIN (optional)? To be honest I didn't use oci driver before, but normally this is an issue when connecting not as Oracle owner. Did you try to connect to Oracle using sql*plus with this environment?

Regards, Dima
 
I have set ORACLE_HOME, LD_LIBRARY_PATH and PATH to include the relevant oracle directories. This was enough for it all to work before I tried running Tomcat on the machine startup. I have also successfully connected to plsql using the environment I set up. And I have managed to echo those environment variable successfully at the point just prior to that actual tomcat startup in catalina.sh.

I am sure I am missing some simple point here, but after nearly two days looking at this my vision is becoming a little hazy!

Thanks for you help though!
 
You wrote that you could not connect to Oracle. Any errors in logs? Maybe some permission issues? Is your ORACLE_HOME can be read by nobody?

Regards, Dima
 
I am able to connect to oracle through sqlplus with nobody. my oracle home can be read by nobody. the only logs i can see errors in are the tomcat logs. all they are saying, when i try to insert data, is that my conection object is null. it says to check my datasourcefactory configuration, although this was perfectly ok before I tried to get tomcat to start up with the machine.
 
Another (posibly dummy) test: try to connect (and then disconnect of course) by sql*plus, called from catalina.sh right before launching java. Did you try to replace oci with thin (to localize the reason)?

Regards, Dima
 
I have succeeded in connecting by sqlplus from inside the catalina.sh script, just before launching java! I will try it with thin though, as I have heard that oci is best avoided!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top