safaacar / rubycas-server

Automatically exported from code.google.com/p/rubycas-server
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Connecting RubyCAS server thru Oracle DB #103

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Installed Oracle Adapter OCI8
2.
3.

What is the expected output? What do you see instead?
Connecting to Oracle Db instead of MySQL

Please use labels and text to provide additional information.
I havE this working :
-------------------------------------------------------------------
conn = OCI8.new('casserver', '*', '10.xxx.xx.xx:1521/xxxDB')
conn.exec('select 1 from dual ') do |r|
puts r
end
conn.exec('select id from casserver_schema_infos ') do |i|
puts i
end
-------------------------------------------------------------------
But not this one (in the config.yml) :
-------------------------------------------------------------------
database:
adapter: oracle
username: casserver
password: *
host: 10.xxx.xx.xx:1521/xxxDB
# host: 10.xxx.xx.xx:1521
# database: xxxDB
# encoding: utf8
-------------------------------------------------------------------
Tried Separately as well, but doesn't work.
------------------------------------------------------------------
It gives the following Error
Initialized global logger to "/var/log/casserver.log".
env.c:257:in oci8lib.so: ORA-12162: TNS:net service name is incorrectly 
specified (OCIError)
from /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/site_ruby/1.8/oci8.rb:229:in 
`initialize' from 
/opt/rubygems/gems/activerecord-oracle-adapter-1.0.0.9250/lib/active_record/conn
ection_adapters/oracle_adapter.rb:623:in `new'
from 
/opt/rubygems/gems/activerecord-oracle-adapter-1.0.0.9250/lib/active_record/conn
ection_adapters/oracle_adapter.rb:623:in `new_connection'
..  AND SO ON .....

        from /opt/rubygems/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in `checkout'
        from /opt/rubygems/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in `connection'
        from /opt/rubygems/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in `retrieve_connection'
        from /opt/rubygems/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `retrieve_connection'
        from /opt/rubygems/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `connection'
        from /opt/rubygems/gems/activerecord-2.3.8/lib/active_record/base.rb:1295:in `table_exists?'
        from (eval):73:in `create_schema'
        from /opt/rubyCASserverCurrent/lib/casserver.rb:46:in `create'
        from /opt/rubygems/gems/picnic-0.8.1.20100201/lib/../vendor/zuk-camping-2.0.20090429/lib/camping/reloader.rb:98:in `load_apps'
        from /opt/rubygems/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:145:in `inject'
        from /opt/rubygems/gems/picnic-0.8.1.20100201/lib/../vendor/zuk-camping-2.0.20090429/lib/camping/reloader.rb:94:in `each'
        from /opt/rubygems/gems/picnic-0.8.1.20100201/lib/../vendor/zuk-camping-2.0.20090429/lib/camping/reloader.rb:94:in `inject'
        from /opt/rubygems/gems/picnic-0.8.1.20100201/lib/../vendor/zuk-camping-2.0.20090429/lib/camping/reloader.rb:94:in `load_apps'
        from /opt/rubygems/gems/picnic-0.8.1.20100201/lib/../vendor/zuk-camping-2.0.20090429/lib/camping/reloader.rb:164:in `update'
        from /opt/rubygems/gems/picnic-0.8.1.20100201/lib/../vendor/zuk-camping-2.0.20090429/lib/camping/reloader.rb:158:in `map'
        from /opt/rubygems/gems/picnic-0.8.1.20100201/lib/../vendor/zuk-camping-2.0.20090429/lib/camping/reloader.rb:158:in `update'
        from /opt/rubygems/gems/picnic-0.8.1.20100201/lib/../vendor/zuk-camping-2.0.20090429/lib/camping/server.rb:32:in `find_scripts'
        from /opt/rubygems/gems/picnic-0.8.1.20100201/lib/../vendor/zuk-camping-2.0.20090429/lib/camping/server.rb:130:in `reload!'
        from /opt/rubygems/gems/picnic-0.8.1.20100201/lib/picnic/server.rb:20:in `start'
        from /opt/rubygems/gems/picnic-0.8.1.20100201/lib/picnic/cli.rb:162:in `handle_cli_input'
        from /opt/rubyCASserverCurrent/bin/rubycas-server:13

Can Any One please help ?

------------

Original issue reported on code.google.com by nambia...@gmail.com on 10 Jul 2010 at 10:20

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Finally I solved this myself (after three days of elaborate search in the net 
but in vain) !!  But resolved by trial and error !!

Solution :
Only this much is required for connecting to Oracle Database.  But ORACLE_HOME 
is must.
config.yml :- 

database:
  adapter: oracle
  username: casserver
  password: nambiarsu
  database: XXXXDB

-------------------------------------

I copied the tnsnames.ora, sqlnet.ora and listener.ora (this may not be reqd.) 
to my instant client directory.
[root@rubycas_sn init.d]# ll /usr/lib/oracle/11.2/client64/
total 24
drwxr-xr-x 2 root root 4096 Jul 10 10:54 bin
drwxr-xr-x 2 root root 4096 Jul 10 11:24 lib
drwxr-xr-x 3 root root 4096 Jul 11 16:39 network
[root@rubycas_sn init.d]# ll /usr/lib/oracle/11.2/client64/network/admin/
total 24
-rw-r--r-- 1 root root  553 Jul 11 16:52 listener.ora
-rw-r--r-- 1 root root  194 Jul 11 16:52 sqlnet.ora
-rw-r--r-- 1 root root 1382 Jul 11 16:52 tnsnames.ora
---------------------------------
Relevant data of tnsnames.ora is given below:-

XXXXDB =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = xx.xxx.xxx.xx)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = xxxDB)
    )
  )
--------------------------
Then added the following to /etc/profile.d/oracle_libs.

INSTANT_CLIENT="/usr/lib/oracle/11.2/client64"

LD_LIBRARY_PATH=${INSTANT_CLIENT}/lib/:${LD_LIBRARY_PATH}

PATH=${INSTANT_CLIENT}/bin:${INSTANT_CLIENT}:${PATH}

CLASSPATH=${INSTANT_CLIENT}/lib:${INSTANT_CLIENT}/bin:${CLASSPATH}

export TNS_ADMIN=${INSTANT_CLIENT}

export ORACLE_HOME=${INSTANT_CLIENT}
---------------------------------------------
The Environment is listed below:-
TOMCAT_HOME=/home/tomcat/tomcatCurrent
HOSTNAME=rubycas_sn.xx.xxxxx.in
GEM_HOME=/opt/rubygems
TERM=xterm
SHELL=/bin/bash
RUBYCAS_SERVER_PATH=/opt/rubyCASserverCurrent/bin
CATALINA_HOME=/home/tomcat/tomcatCurrent
HISTSIZE=1000
OLDPWD=/usr/lib/oracle/11.2/client64/network/admin
CATALINA_BASE=/home/tomcat/tomcatCurrent
SSH_TTY=/dev/pts/0
USER=root
LD_LIBRARY_PATH=/usr/sapjco:/usr/lib/oracle/11.2/client64/lib/:
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33
;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32
:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=
00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2
=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:
*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
TNS_ADMIN=/usr/lib/oracle/11.2/client64
MAIL=/var/spool/mail/root
PATH=/opt/rubyCASserverCurrent/bin:/opt/rubyCurrent/bin:/opt/rubygems/bin:/usr
/java/latest/bin:/home/tomcat/tomcatCurrent/bin:/usr/lib/oracle/11.2/client64/
bin:/usr/lib/oracle/11.2/client64:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lo
cal/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
INPUTRC=/etc/inputrc
PWD=/etc/init.d
JAVA_HOME=/usr/java/latest
LANG=en_US.UTF-8
RUBY_HOME=/opt/rubyCurrent
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
SHLVL=1
HOME=/root
LOGNAME=root
GEM_PATH=/opt/rubygems
CLASSPATH=.:/home/tomcat/tomcatCurrent/lib:/home/tomcat/tomcatCurrent/shared/c
lasses:/home/tomcat/tomcatCurrent/shared/lib:/home/tomcat/tomcatCurrent/common
/classes:/home/tomcat/tomcatCurrent/common/lib:/usr/lib/oracle/11.2/client64/l
ib:/usr/lib/oracle/11.2/client64/bin::/usr/sapjco/sapjco.jar
LESSOPEN=|/usr/bin/lesspipe.sh %s
CATALINA_TMPDIR=/home/tomcat/tomcatCurrent/temp
ORACLE_HOME=/usr/lib/oracle/11.2/client64
G_BROKEN_FILENAMES=1
_=/bin/env
-------------------------
Ruby version : ruby 1.8.7 (2009-12-24 patchlevel 248) [x86_64-linux], MBARI 
0x6770, Ruby Enterprise Edition 2010.01
Java version : java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)

Original comment by nambia...@gmail.com on 11 Jul 2010 at 12:50

GoogleCodeExporter commented 9 years ago
Glad to hear you got it working. The config shouldn't be any different for 
RubyCAS than for ActiveRecord in general, but yeah, that doesn't make it any 
easier. I've had all kinds of good times in the past trying to get Ruby to talk 
through Oracle's proprietary crap.

Original comment by matt.zuk...@gmail.com on 2 Aug 2010 at 10:03