Using OracleClient in CentOS 6.x problem record in the ASP.net MVC 4 on Mono

Source: Internet
Author: User
Tags character set oracleconnection wrapper centos oracle database sqlplus

Using OracleClient in CentOS 6.x problem record in the ASP.net MVC 4 on Mono

Objective

Recently, there is a Web project, the business function is not complex, but this customer (a government department) has two hard requirements: 1, the database must use ORACLE;2, the program must run in the Linux or Hp-unix system. Although put. NET program running in Linux has always been my conscious requirements, and before the break to do some preparation (some of our own bottom frame library has been running smoothly in Linux), but the complete porting of a Web project to mono in CentOS 6.x did not.

Installing Oracle for Linux clients

1. Download from Oracle Website:

oracle-instantclient12.1-basic-12.1.0.1.0-1.i386.rpm

oracle-instantclient12.1-sqlplus-12.1.0.1.0-1.i386.rpm

oracle-instantclient12.1-devel-12.1.0.1.0-1.i386.rpm

oracle-instantclient12.1-odbc-12.1.0.1.0-1.i386.rpm

Use #> RPM-IVH ... command to install the RPM files separately. After the installation is complete, there will be an Oracle directory in the/usr/lib directory.

2, configure the Environment information:

Please open the/etc/profile file and append the following to this file:

Export oracle_base=/usr/lib/oracle/12.1 #请注意, here should be filled in for your installation path

Export oracle_home= $ORACLE _base/client #请注意, here should be filled in for your installation path

Export Oracle_sid=ortl #请注意, you should fill in your SID value here

Export ld_library_path= $ORACLE _home/lib: $LD _library_path

Export Nls_lang=american_america. Al32utf8 #请注意, the character set here should be consistent with the character set of your database.

After the edit is saved, run the #> source/etc/profile command to make the profile take effect immediately, or log off the current user and log back on to the Linux system.

3, specify the. ora file:

Create a network directory in the/usr/lib/oracle/12.1/client directory, create an admin directory under it, and then place your Tnsnames.ora file here.

4, set the library path

Into the/ETC/LD.SO.CONF.D directory, create a new file named Oracle-i386.conf with only one line of text:

/usr/lib/oracle/12.1/client/lib

Then reload the configuration file at the terminal using the following command:

#> Ldconfig

5, detect whether the installation is successful

To run the Sqlplus command, you should be able to see information similar to the following if you have no problem with the character:

#> Sqlplus

Sql*plus:release 12.1.0.1.0 Production on Sun Mar 16 01:49:42 2014

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Problem arises

Our web program uses the System.Data.OracleClient below to access the Oracle database, which works under. NET in Windows, but strikes under Mono in CentOS 6.x, The Web server I use in the CentOS system is Jexus version 5.4.0.

The first time you visit the page, the exception message is as follows:

System.DllNotFoundException:libclntsh.so

at (wrapper managed-to-native) system.data.oracleclient.oci.ocicalls/ocinativecalls:ocienvcreate (Intptr& SYSTEM.DATA.ORACLECLIENT.OCI.OCIENVIRONMENTMODE,INTPTR,INTPTR,INTPTR,INTPTR,INT,INTPTR)

At System.Data.OracleClient.Oci.OciCalls.OCIEnvCreate (system.intptr& envhpp, Ocienvironmentmode mode, INTPTR CTXP, IntPtr MALOCFP, IntPtr RALOCFP, IntPtr mfreep, Int32 XTRAMEM_SZ, IntPtr usrmempp) [0x00000] in:0

At System.Data.OracleClient.Oci.OciEnvironmentHandle. ctor (Ocienvironmentmode mode) [0x00000] in:0

At System.Data.OracleClient.Oci.OciGlue.CreateConnection (Oracleconnectioninfo conInfo) [0x00000] in:0

At System.Data.OracleClient.OracleConnectionPoolManager.CreateConnection (oracleconnectioninfo info) [0x00000] in:0

At System.Data.OracleClient.OracleConnectionPool.CreateConnection () [0x00000] in:0

At System.Data.OracleClient.OracleConnectionPool.GetConnection () [0x00000] in:0

At System.Data.OracleClient.OracleConnection.Open () [0x00000] in:0

At System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable DataTable, IDbCommand command, CommandBehavior behavior) [0x00000] in:0

At System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable DataTable) [0x00000] in:0

at (wrapper Remoting-invoke-with-check) System.Data.Common.DbDataAdapter:Fill (System.Data.DataTable)

Refresh the same page again, the exception information has become:

System.NullReferenceException:Object reference not set to a instance of an Object

At System.Data.OracleClient.OracleConnectionPool.GetConnection () [0x00000] in:0

At System.Data.OracleClient.OracleConnection.Open () [0x00000] in:0

At System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable DataTable, IDbCommand command, CommandBehavior behavior) [0x00000] in:0

At System.Data.Common.DbDataAdapter.Fill (System.Data.DataTable DataTable) [0x00000] in:0

at (wrapper Remoting-invoke-with-check) System.Data.Common.DbDataAdapter:Fill (System.Data.DataTable) at Citms.Data.DataAccess.ExecuteProcedure (System.Data.Common.DbConnection connection, System.String procedurename, Parameter[] paramers, System.Collections.Generic.Dictionary ' 2& outparamers) [0x00000] in:0

What kind of rhythm is this? Change to run in MonoDevelop, also reported several such exceptions, and then decisively in the relevant code to set a breakpoint and then enter the debugging run, incredibly, incredibly everything smoothly passed, and again use the debugging run is also normal! I'm going to go, it's just a challenge to my brother's three views, It's too unscientific! There is only one explanation for this: The Magic Shield, the RP Explosion table!

Again through the Jexus to access the system, the exception is still, restart the machine, or not. I began to wonder if it was because Jexus loading libclntsh.so library did not follow the Ld_library_path set path to find, and then ran to the Jexus QQ Group of these issues to inform the inquiry, seemingly no one to speak to me. I'm so embarrassed.

Problem solving

At night is going to download Mono for Apache module, with the dead horse when the mentality of the live horse to download upgraded the latest Jexus 5.5.1, then, those abnormal disappeared, the system perfect running up. Ma ' am, are you trying to say that it's too low-tech (alas, it took me quite a while) ... 囧

Environment description

Incidentally, before updating Jexus, I made a big upgrade of CentOS, which is the system information after the upgrade:

#> cat/proc/version

Linux version 2.6.32-431.5.1.el6.i686 (mockbuild@c6b10.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4 ) (GCC) #1 SMP Tue Feb 21:56:33 UTC 2014

#> Cat/etc/centos-release

CentOS Release 6.5 (Final)

My Mono was not updated and the information is as follows:

#> mono-v

Mono JIT Compiler version 3.0.12 (tarball July 09, 2013 Tuesday 18:49:58 CST)

Copyright (C) 2002-2012 Novell, Inc., Xamarin Inc. and Contributors. Www.mono-project.com

TLS: __thread

Sigsegv:altstack

Notifications:epoll

Architecture:x86

Disabled:none

Misc:softdebug

llvm:supported, not enabled.

Gc:included Boehm (with typed GC and Parallel Mark)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.