10 Replies Latest reply on May 20, 2003 7:50 AM by davidjencks

    OracleExceptionSorter

    kirillburyak

      Where can I find the information on how to use OracleExceptionSorter with JBoss 3.2 to detect and dispose of the stale Oracle connections?

      thanks in advance,

      Kirill

        • 1. Re: OracleExceptionSorter
          davidjencks

          Both 3.2 oracle examples show how to set it up. If it needs to detect more exceptions, please let us know which ones.

          • 2. Re: OracleExceptionSorter
            rudifr

            When I remove the network cable, try to access the database, reconnect the cable and try to access the database again, the connections aren't being rebuild and I get the following exception:

            11:31:17,236 INFO [TxConnectionManager$TxConnectionEventListener] Unregistered handle that was not registered! null for managedConnection: org.jboss.resource.adapter.jdbc.local.LocalManagedConnection@85097d
            11:31:17,256 WARN [JBossManagedConnectionPool] ResourceException cleaning up ManagedConnection:org.jboss.resource.JBossResourceException: Could not cleanup: ; - nested throwable: (java.sql.SQLException: E/A-Exception: Connection reset by peer: socket write error)
            11:31:17,276 INFO [TxConnectionManager$TxConnectionEventListener] Unregistered handle that was not registered! null for managedConnection: org.jboss.resource.adapter.jdbc.local.LocalManagedConnection@85097d
            11:31:17,286 INFO [JBossManagedConnectionPool] Exception destroying ManagedConnection
            org.jboss.resource.JBossResourceException: SQLException; - nested throwable: (java.sql.SQLException: E/A-Exception: Connection reset by peer: socket write error)
            at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.checkException(BaseWrapperManagedConnection.java:445)
            at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.destroy(BaseWrapperManagedConnection.java:229)
            at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.doDestroy(InternalManagedConnectionPool.java:374)
            at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.returnConnection(InternalManagedConnectionPool.java:250)
            at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$OnePool.returnConnection(JBossManagedConnectionPool.java:653)
            at org.jboss.resource.connectionmanager.BaseConnectionManager2.returnManagedConnection(BaseConnectionManager2.java:451)
            at org.jboss.resource.connectionmanager.BaseConnectionManager2$BaseConnectionEventListener.connectionErrorOccurred(BaseConnectionManager2.java:762)
            at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.connectionErrorOccurred(TxConnectionManager.java:629)
            at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.broadcastConnectionError(BaseWrapperManagedConnection.java:309)
            at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.connectionError(BaseWrapperManagedConnection.java:294)
            at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.checkException(BaseWrapperManagedConnection.java:444)
            at org.jboss.resource.adapter.jdbc.local.LocalManagedConnection.begin(LocalManagedConnection.java:153)
            at org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource.start(TxConnectionManager.java:725)
            at org.jboss.tm.TransactionImpl.startResource(TransactionImpl.java:1137)
            at org.jboss.tm.TransactionImpl.enlistResource(TransactionImpl.java:624)
            at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.enlist(TxConnectionManager.java:460)
            at org.jboss.resource.connectionmanager.TxConnectionManager.managedConnectionReconnected(TxConnectionManager.java:358)
            at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:490)
            at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:798)
            at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:102)

            JBoss is 3.2.0 the database is Oracle 9.2.0 and this is my
            Datasource configuration:


            <local-tx-datasource>
            <jndi-name>OracleDS</jndi-name>
            <connection-url>jdbc:oracle:thin:@itpspp1:1521:920</connection-url>
            <!--

            Here are a couple of the possible OCI configurations.
            For more information, see http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/toc.htm

            <connection-url>jdbc:oracle:oci:@youroracle-tns-name</connection-url>
            or
            <connection-url>jdbc:oracle:oci:@(description=(address=(host=youroraclehost)(protocol=tcp)(port=1521))(connect_data=(SERVICE_NAME=yourservicename)))</connection-url>

            Clearly, its better to have TNS set up properly.
            -->
            <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
            <user-name>scott</user-name>
            tiger
            <!--
            <min-pool-size>5</min-pool-size>
            <max-pool-size>10</max-pool-size>
            <blocking-timeout-millis>5000</blocking-timeout-millis>
            <idle-timeout-minutes>15</idle-timeout-minutes>
            -->
            <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
            </local-tx-datasource>



            Is it possible that OracleExceptionSorter should react on "java.sql.SQLException: E/A-Exception: Connection reset by peer: socket write error" or did I miss something in the configuration?

            Any help would be appreciated.

            Rudi.

            • 3. Re: OracleExceptionSorter
              rudifr

              I just ran it in the debugger:
              in OracleExceptionSorter.isExceptionFatal
              error_text = "E/A-EXCEPTION: CONNECTION RESET BY PEER: SOCKET WRITE ERROR"
              This error_text is not being recognized by OracleExceptionSorter.

              But if I modify the error_text to something that is being recognized like e.g. "ORA-00600" the connections still aren't being rebuilt. I get this exception:
              13:30:45,331 INFO [TxConnectionManager$TxConnectionEventListener] Unregistered handle that was not registered! null for managedConnection: org.jboss.resource.adapter.jdbc.local.LocalManagedConnection@781dd4
              13:30:45,331 WARN [JBossManagedConnectionPool] ResourceException cleaning up ManagedConnection:org.jboss.resource.JBossResourceException: Could not cleanup: ; - nested throwable: (java.sql.SQLException: E/A-Exception: Connection reset by peer: socket write error)
              13:31:38,212 INFO [TxConnectionManager$TxConnectionEventListener] Unregistered handle that was not registered! null for managedConnection: org.jboss.resource.adapter.jdbc.local.LocalManagedConnection@781dd4
              13:31:38,212 INFO [JBossManagedConnectionPool] Exception destroying ManagedConnection


              Regards

              Rudi.

              • 4. Re: OracleExceptionSorter
                davidjencks

                The expected behavior is that the dead connection will throw an exception when you try to use it, and this exception will get to your application (or the cmp engine, etc). Your application is responsible for dealing with this gracefully. Jboss/the adapter's job is only to make sure the dead connection is disposed of. So, if you have 100 connections in the pool when you unplug the db, you will get 100 exceptions in your application as these connections are tried and thrown out. Only then will you start getting new, working connections.

                Is this the behavior you are seeing?

                Do you know if the oracle driver/db version is the same as the one the exception sorter was written for? the message you show is a radically diferent format than the ones the sorter knows about.

                • 5. Re: OracleExceptionSorter
                  rudifr

                  Sorry, it was my fault. The OracleExceptionSorter detects "SOCKET" in my exception. So it should work correctly.

                  I didn't realize that I always get an exception when a connection is being returned:
                  10:48:37,295 INFO [TxConnectionManager$TxConnectionEventListener] throwable from unregister connection
                  java.lang.IllegalStateException: Trying to return an unknown connection1! org.jboss.resource.adapter.jdbc.WrappedConnection@1cd1cea
                  at org.jboss.resource.connectionmanager.CachedConnectionManager.unregisterConnection(CachedConnectionManager.java:264)
                  at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.connectionClosed(TxConnectionManager.java:550)
                  at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.closeHandle(BaseWrapperManagedConnection.java:280)
                  at org.jboss.resource.adapter.jdbc.WrappedConnection.close(WrappedConnection.java:127)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:324)
                  at org.jboss.resource.connectionmanager.CachedConnectionManager.closeAll(CachedConnectionManager.java:375)
                  at org.jboss.resource.connectionmanager.CachedConnectionManager.popMetaAwareObject(CachedConnectionManager.java:199)
                  at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:190)
                  at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
                  at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
                  at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
                  at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
                  at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
                  at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
                  at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
                  at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:322)
                  at org.jboss.ejb.Container.invoke(Container.java:674)
                  at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:353)
                  at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:83)
                  at $Proxy37.addMachine(Unknown Source)
                  at com.cortex_brainware.tryejb.datamaintenance.appserver.DatamaintenanceBean.addMachines(DatamaintenanceBean.java:53)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:324)
                  at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:629)
                  at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:186)
                  at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
                  at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
                  at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
                  at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:104)
                  at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:117)
                  at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
                  at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
                  at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:322)
                  at org.jboss.ejb.Container.invoke(Container.java:674)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:324)
                  at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                  at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:549)
                  at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:359)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                  at java.lang.reflect.Method.invoke(Method.java:324)
                  at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
                  at sun.rmi.transport.Transport$1.run(Transport.java:148)
                  at java.security.AccessController.doPrivileged(Native Method)
                  at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
                  at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
                  at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
                  at java.lang.Thread.run(Thread.java:536)
                  10:48:37,315 INFO [CachedConnectionManager] Successfully closed a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@1cd1cea

                  Has anyone an idea where this exception comes from?
                  It happens with JBoss 3.0.7, 3.2.0 and 3.2.1.

                  Any help would be appreciated.
                  Thanks in advance.

                  Rudi.

                  • 6. Re: OracleExceptionSorter
                    davidjencks

                    Does this occur with normal usage or only when a dead connection is encountered? Does it result in an additional exception being propagated to your app, after the exception from trying to use the dead connection?

                    • 7. Re: OracleExceptionSorter
                      rudifr

                      I have a very simple stateless session bean which makes an insert to the database.
                      This occurs always after the call to the session bean is finished and the transaction has been commited by the container. There is no additional exception to the app, neither to the session bean nor to the client.
                      It occurs with normal usage, i.e. I see this exception after every call to the session bean.

                      I tried to debug it, and it seems the WrappedConnection vanishes somewhere in the call stack between CachedConnectionManager.closeAll(Map) line 375 and CachedConnectionManager.unregisterConnection() line 264.
                      In CachedConnectionManager.unregisterConnection() line 260:
                      Map cmToConnectionsMap = key.getCMToConnectionsMap();
                      delivers an empty HashMap. So the IllegalStateException is being thrown.

                      I tried it on different machines with new installations of JBoss and I tried it not only with Oracle 9.2.0 but also with MS Access. The behaviour is always the same.

                      Maybe I'm doing something wrong (I'm a newbie to JBoss), but I have no clue what this could be.

                      regards
                      Rudi.

                      • 8. Re: OracleExceptionSorter
                        mortonpd

                        I too have had this problem with 3.0.7 and 3.2.1 with the exception:
                        17:42:21,745 INFO [TxConnectionManager$TxConnectionEventListener] throwable from unregister connection
                        java.lang.IllegalStateException: Trying to return an unknown connection1! org.jboss.resource.adapter.jdbc.WrappedConnection@9ed5d6
                        at org.jboss.resource.connectionmanager.CachedConnectionManager.unregisterConnection(CachedConnectionManager.java:264)
                        at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.connectionClosed(TxConnectionManager.java:550)
                        at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.closeHandle(BaseWrapperManagedConnection.java:280)
                        at org.jboss.resource.adapter.jdbc.WrappedConnection.close(WrappedConnection.java:127)



                        I am using a simple BMP Entity Bean accessing directly from a remote client, not another bean. The exception occurs when I go to close the connection once I am finished with it (all statements and resultset have been closed prior). When I look at the code in the CachedConnectionManager that throws the exception, when it calls key.getCMToConnectionMap() the key has null and so creates a new one, so of course the next line will always evaluate to true and throw the exception. Am I doing something wrong in order for my entity bean not to have this Collection associated with it before it enters this method?

                        I eventually run out of db connections and need to restart jboss.

                        The database I am running against is db2 7.2.

                        • 9. Re: OracleExceptionSorter
                          mortonpd

                          Sorry this was my fault. I had originally wrote the Entity Beans for WebSphere using one of the tutorials, and they wanted you to establish the db connection in the setEntityContext and close it in the unsetEntity Context methods, where as jboss would like you to open and close them just when you actually use the connection in a method.

                          Now I have removed the calls in the entity context methods it seems to be working fine.

                          • 10. Re: OracleExceptionSorter
                            davidjencks

                            So, most likely I can reproduce this problem by getting a connection in setEntityContext and closing it in unsetEntityContext?

                            Although I don't think much of this coding style, it ought to work. Thanks for the info.