JBoss application cannot make XA connection to Oracle 11g - oracle

I've been working on several JBoss applications where I have everything running on my laptop (Windows XP) including an Oracle database (11g Enterprise Edition). Everything works fine on the laptop.
Now I'm setting up a new, faster machine (running Windows 7 Professional) and the non-XA JBoss apps run fine but the apps requiring an XA connection cannot connect to Oracle. I'm pretty sure it is a problem with my new Oracle installation because I can point the apps to an external Oracle server and they work, but they fail to connect when pointing them my local Oracle database.
I've done a lot of google searches and the only information I can find is that I need to run the script $ORACLE_HOME/rdbms/admin/xaview.sql to create some XA views and I need to grant the following permissions to the user:
GRANT SELECT ON sys.dba_pending_transactions TO <user>;
GRANT SELECT ON sys.pending_trans$ TO <user>;
GRANT SELECT ON sys.dba_2pc_pending TO <user>;
GRANT EXECUTE ON sys.dbms_xa TO <user>;
But after doing all that, I still cannot get the apps to connect.
This is the exception I'm getting:
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Io exception:
The Network Adapter could not establish the connection) at
org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAMangedConnectionFactory.java:144) at
org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventLisener(InternalManagedConnectionPool.java:577) at
org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:262) at
org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:500) at
org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:347) at
org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:330) at
org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:402) at
org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:849) at
org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:90) at
org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:46) at
org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
I know this isn't really a programming question, but I was hoping someone had seen this before. Any help would be much appreciated.

I was able to resolve this issue by ensuring that the host name and domain name settings in the LISTENER.ORA file and in the TNSNAMES.ORA file matched. For example, if one had HOST = localhost and the other had HOST = myhost.xyz.com then it would cause problems for XA but not for normal Java JDBC connections. My theory is that some part of the XA stack needed to make an OCI connection that read the TNSNAMES.ORA file but then could not connect because of a mismatch with the Listener configuration. Normal Java JDBC connections don't care about the TNSNAMES.ORA file as they make a direct connection to the listener with their own configuration settings.
I also had to rename some folders from xxx_localhost_yyy to xxx_myhost_yyy to get the Enterprise Manager to work.
To get TOAD to work I had to install the 32 bit client as it will not work with the 64 bit client and I had to configure it's ORACLE_HOME variable in the Windows registry under HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Oracle. Apparently Wow6432Node is a special place in the Windows registry for defining values that only 32 bit applications will see.
Anyway, I'm relieved to have it all working.

Well, can you connect using a sql client to this database ?

Related

Connecting to Oracle PDB via ODBC

I have a LOCAL Oracle 19c database. I am trying to get ADO to connect to it. The first step is to get ODBC working. I have one PDB container called orclpdb, which is what I want to use. I can connect from SQL*Plus...
Y:\INSTALL_UNZIP\bin\sqlplus.exe acs/<Password>#localhost:1521/orclpdb
I go into the 64-bit ODBC Administrator, and had to fight a little bit (adding OCI_LIB32 and TNS_ADMIN paths), but finally got the ODBC Admin tool to connect, but ONLY to the root/system database. My root question is 'How do I get ODBC administrator to connect to a specific container DB?
Within the ODBC Administrator, the TNS Service Name field dropdown only shows ORCL, not orclpdb. Again, I can connect using ORCL, but as system/.
UPDATE: Due to issues such as this, I switched most apps to Devart's Oracle Data Access components to Delphi. They have a DIRECT mode, which does not need SQL*Net or TNS stuff
.
Make sure your TNS_ADMIN/tnsnames.ora file has an entry for the PDB (orclpdb).

Export Database connection to Oracle Developer

I have a database Connection established in odbcad and Microsoft Access (aswell as working in Excel) via ODBC and want to also get it working in Oracle SQL developer.
It is a Windows SQL Server as far as i know and I have tried several Settings, of which None works. I have also installed Driver for ODBC. I would like to Import Settings into SQL developer as applied in MS Access, is there any possibility?
No, SQL Developer is a Java application and uses a JDBC driver.
But if you look at the odbc properties for your connection, those should largely translate to what you need to define a basic connection.
Oracle:
Server name or IP address of the DB, port # for the listener, and the name of the SID or Service, plus a valid username and password is all you need to connect to Oracle.
What error do you get when you try to connect?
Show us what you're trying.
Update:
You're trying to connect to SQL Server but you're getting"
Native SSPI library not loaded
You're trying to use OS Authentication for your connection. For this to work with the jTDS driver, you need to copy a DLL file named ntlmauth.dll (which is for NT authentication) under the jtds-x.x.x-dist\x86\SSO\ or jtds-x.x.x-dist\x64\SSO\, to any directories in the PATH environment.
Please update your question such that's it's clear you're connecting to SQL Server and share the error message so others can find it.
I imagine this question is a duplicate of many previous iterations of the same challenge.

IIS site not connecting to Oracle database

I have a server with IIS that hosts web sites.
Some of those web sites (Silverlight) must connect to an Oracle Database to perform queries via OleDb, but they cannot.
Here are the results of what I tested :
'msdaora' provider is not registered on local machine when I run it in the web site
ORA-01019: unable to allocate memory in the user side (when I try to connect with a test console program without administrator status)
Connection OK (with the same test console program WITH administrator status)
ORA-12154: TNS:could not resolve the connect identifier specified when trying to switch to another method of connection (from OleDb to Oracle.ManagedDataAccess.Client)
I went through countless info about these kind of errors but I couldn't find any working solution.
Here is what I tested :
giving "create global objects" right to the relevant users (no change at all)
installing several Oracle clients one after another. Best result is with 10.2 client 64b (where my test program can connect while having administrator rights). The install is clean (no several Oracle folders nor several Oracle environment variables at the same time)
disabling warnings concerning the administrator elevation (ie no confirmation pop up during elevation) : no change at all
checking RAM usage (plenty of memory under the foot)
Additional infos :
The connection string is
Provider=msdaora;Data Source=HOSTNAME;User Id=USER;Password=PASSWORD
Same connection string used with OleDb and Oracle.ManagedDataAccess.Client.
The tsnames.ora file exists (and works, as show my succesful attempt with the administrator test program)
It's working on an older web server, but there are too much differences for me to find any meaningful one (different Windows, 32/64b, different IIS versions, different Oracle client)
Any idea ?
There are several points:
Microsoft msdaora provider for OLE DB is deprecated for ages. You should prefer the Oracle Provider OraOLEDB.Oracle.
Oracle Client and OLE DB provider and IIS application have to have the same architecture, i.e. all must be either 32 bit or 64 bit, you cannot mix them. (ancient msdaora is not available for 64 bit). However, ODP.NET Managed Driver (Oracle.ManagedDataAccess) works for both 32 bit and 64 bit.
When you use ODP.NET Managed Driver then Provider=MSDAORA is not needed in ConnectionString. I assume such attributes is ignored or you just missed to mention it.
Version of Oracle Client and OLE DB provider must match (even minor version). Due to COM limitation you cannot install more than one OLE DB provider for 32 bit and 64 bit each.
Search pattern for tnsnames.ora file in OLE DB is different to search pattern in ODP.NET Managed Driver. Verify following items:
OLE DB reads your Registry for TNS_ADMIN value, the ODP.NET Managed Driver does not.
ODP.NET Managed Driver uses your .NET config file (i.e. web.config, machine.config) to determine location of tnsnames.ora file, the OLE DB does not.
According documentation ODP.NET Managed Driver does take into account the TNS_ADMIN Environment variable and folder %ORACLE_HOME%\network\admin. However, according to my tests it does anyway.
Regarding connection failure is depending on "Rus as Administrator" check permissions of your Oracle installation folder.

Communication between two databases (Oracle, VirtualBox)

Currently I am trying to understand how can two databases communicate to each other (for instance: get data from one to another).
Detailed description
I have two Oracle databases, one on Windows and latter on Oracle VirtualBox. On Windows DB I have one user (PAI) with single table called TESTME. On VirtualBox, only user (PAI_VB) was created. Now, I want to display the content of the TESTME table from SQL Developer from VB.
I have done
I want to display table TESTME using LINK statement:
CREATE DATABASE LINK LINK_TO_PAI
CONNECT TO PAI IDENTIFIED BY PAI
USING 'DESCRIPTION = (ADDRESS=(PROTOCOL=TCP)(HOST=myIP)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=XE))';
Note: data from 'DESCRIPTION' section were taken from tnsname.ora file on Windows.
Having that, via following query I will manage to display table:
SELECT * FROM PAI.TESTME#LINK_TO_PAI;
Unfortunately, it does not work.
Error from console
ORA-12154: TNS:could not resolve the connect identifier specified
12154. 00000 - "TNS:could not resolve the connect identifier specified"
*Cause: A connection to a database or other service was requested using
a connect identifier, and the connect identifier specified could not
be resolved into a connect descriptor using one of the naming methods
configured. For example, if the type of connect identifier used was a
net service name then the net service name could not be found in a
naming method repository, or the repository could not be
located or reached.
*Action:
- If you are using local naming (TNSNAMES.ORA file):
- Make sure that "TNSNAMES" is listed as one of the values of the
NAMES.DIRECTORY_PATH parameter in the Oracle Net profile
Questions
Could you please propose solution to my problem (I know that in *Action section there is a hint but still I cannot solve it).
Maybe, you could introduce me another way to make communication between two databases possible.
EDIT
I managed to connect from my VB machine to one on Win10 via SQLDeveloper and SQLPlus. Unfortunately, using Oracle LINK I can not access data from database.
SOLVED !!
I managed to solve my issue. The problem laid in LINK. Since following part:
'DESCRIPTION = (ADDRESS=(PROTOCOL=TCP)(HOST=myIP)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=XE))'
was inside tnsnames.ora file i should define my link as follows:
CREATE DATABASE LINK LINK_TO_PAI
CONNECT TO PAI IDENTIFIED BY PAI
USING 'xe';
After that minor change, I was able to freely us LINK in my example. Cheers :)
Here's what you need to have for a working database link:
Network connectivity between the two hosts.
Oracle Listener process running on the host you want to connect to.
Correct TNS entry while creating the link.
Correct username and password to connect to the remote database.
The TNS-12154 error you're getting means the database running on the virtual host can't get to XE's listener using the description you gave it.
Make sure you're using the correct IP address when trying to connect to your Windows host from your virtual machine.
Run tnsping from your virtual environment to see if it can get to the Windows host listener.
tnsping 'DESCRIPTION = (ADDRESS=(PROTOCOL=TCP)(HOST=your_windows_host_ip_from_step_1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XE))'
or just tnsping XE if you have the TNS entry stored as XE in tnsnames.ora file on your virtual machine.
See also: Oracle documentation — Testing Connections.
Once you get OK response from tnsping try connecting to XE with sqlplus (sqlplus PAI/PAI#XE) or via SQL Developer running on the virtual host. If you can connect that way your database link should also work with the same TNS entry.
This is a tricky part of oracle because there are a number of diverent ways to make a connection.
I suggest that you begin to make sure that you have a tnsnames.ora file both on windows and in your virtualbox environment. What os are you running in VirtualBox by the way?
In both tnsnames.ora files both databases should be named. Easiest to make them identical.
Then connect with sql*plus from windows to your database in VirtualBox and from VirtualBox to your database on Windows.
Just to make sure your network and tns config are OK.
If this works recreate your db-link with the servce alias from tnsnames after using. This should work.

Oracle 10g OS Authentication fails in SQL Plus

I have set up an externally identified user for our Oracle 10g (10.2.0.3) database like this:
CREATE USER "OPS$DOMAIN\USER" IDENTIFIED EXTERNALLY;
Now I am trying to connect from a 10.2.0.1 sqlplus client using
connect /#TNS_NAME;
however I get
Invalid username/password.
[Edited]
Here is all the information I can currently give on this issue:
There are two virtualized Windows 2003 Servers, each running their own Oracle 10.2.0.3 database
There are two virtualized Windows XP Clients with the Oracle Client 10.2.0.1
All four machines are on the same virtual host and within the same domain
The same user is used to log in on both clients
Client 1 can use OS authentication to connect to Server 1
Client 1 cannot connect to Server 2 with OS authentication
Client 2 cannot connect to either database server with OS authentication
Both Clients can connect to either database server with schema owner/password
Four months ago, Client 2 could connect to Client 2 with OS authentication. I cannot tell if Client1->Server2 and Client2->Server1 worked, but I am almost certain it did.
Things I have considered:
I double checked the os_authent_prefix, which is "OPS$"
I tried recreating the user, and made sure everything was written in caps (we had problems in the past when we didn't have all caps)
I tried granting the create session privilege (someone suggested that somewhere; didn't help)
What could I be missing / What else could I try?
PS: Database security is not a concern here; I know OS Authentication is kind of insecure.
Since the problem is happening at the client can you please check the below parameter in sqlnet.ora file in the client machine
SQLNET.AUTHENTICATION_SERVICES= (NTS)
Even after that it does not work you can refer this article on os-authentication to check if any step is missing

Resources