Creating 2 managed connections using different ConnectionReq
andrej Feb 24, 2003 3:51 PMHi all!
I want to use a JCA to handle connections to an ERP system, so I can't definitely know, where the ERP server is located and security information may differ every time the connection is established. So I use some properties files to define information I need to set up connection. Everything works ok with the first connection (managed connection is created, stored to pool, I can get it from pool):
16:26:33,091 INFO [STDOUT] [Reference Bean log] -> info: Set session context
16:26:33,211 INFO [STDOUT] [Reference Bean log] -> info: Creating...
16:26:33,211 INFO [STDOUT] [Reference Bean log] -> info: Creating initial context...
16:26:33,211 INFO [STDOUT] [Reference Bean log] -> info: Creating initial context done
16:26:33,211 INFO [STDOUT] [Reference Bean log] -> info: lookupFactory: Looking up connection factory...
16:26:33,221 INFO [STDOUT] [Reference Bean log] -> info: result of lookup is: com.om.onec.cci.ConnectionFactoryImpl@911
540
16:26:33,221 INFO [STDOUT] [Reference Bean log] -> info: lookupFactory: Looking up connection factory done
16:26:33,682 INFO [STDOUT] [ManagedConnectionFactory] -> createManagedConnection()...
16:26:33,712 INFO [STDOUT] *==============================
16:26:33,712 INFO [STDOUT] * Initialization Information:
16:26:33,712 INFO [STDOUT] *
16:26:33,712 INFO [STDOUT] * Using server on: 127.0.0.1
16:26:33,722 INFO [STDOUT] * NT domain: HOMELAN
16:26:33,722 INFO [STDOUT] * User name: Nio
16:26:33,722 INFO [STDOUT] * User password: ******** (hidden for security purposes)
16:26:33,722 INFO [STDOUT] *==============================
16:26:33,722 INFO [STDOUT] * Database information:
16:26:33,722 INFO [STDOUT] *
16:26:33,722 INFO [STDOUT] * Database user: InternetUserName
16:26:33,722 INFO [STDOUT] * Database password: ******** (hidden for security purposes)
16:26:33,722 INFO [STDOUT] * Path to database: h:\demodbb
16:26:33,722 INFO [STDOUT] *==============================
16:26:33,732 INFO [STDOUT] [ManagedConnectionImpl] -> setting up 1C object...
16:26:41,132 INFO [STDOUT] [ManagedConnectionImpl] -> 1C object succesfully created...
16:26:41,393 INFO [STDOUT] /D"h:\demodbb" /NInternetUserName /P111
16:26:41,393 INFO [STDOUT] RMTrade=com.linar.jintegra.Variant@93bca2
16:26:41,403 INFO [STDOUT] [ManagedConnectionImpl] -> 1C Initialization...
16:26:53,921 INFO [STDOUT] [ManagedConnectionImpl] -> 1C has been initialized...
16:26:53,981 INFO [STDOUT] [ManagedConnectionImpl] -> adding connection listener...
16:26:53,981 INFO [STDOUT] [ManagedConnectionImpl] -> getConnection()...
16:26:53,981 INFO [STDOUT] [ManagedConnectionImpl] -> adding object: com.om.onec.cci.ConnectionImpl@3da850
16:26:53,991 INFO [STDOUT] [ManagedConnectionImpl] -> object succesfully added...
16:26:53,991 INFO [STDOUT] [Reference Bean log] -> info: Retrieving connection done
Next stage, I want to use this created connection as an source of information and I need another connection on other server to store information i got using first connection. So I need to use both of connections, to get information from first connection and to put information to another one. But I CAN'T do that! When I'm trying to transfer another parameters, I get an exception:
16:35:29,742 INFO [STDOUT] [ManagedConnectionFactory] Search for matching connections in the set of 1
16:35:29,752 INFO [STDOUT] [ManagedConnectionImpl] -> adding object: com.om.onec.cci.ConnectionImpl@275a34
16:35:29,752 INFO [STDOUT] [ManagedConnectionImpl] -> object succesfully added...
16:35:29,752 INFO [STDOUT] [Reference Bean log] -> info: Remove actions...
16:35:29,752 INFO [STDOUT] [Reference Bean log] -> info: Cleaning objects in current thread...
16:35:29,762 INFO [STDOUT] [Reference Bean log] -> info: ...done
16:35:29,762 INFO [STDOUT] [Reference Bean log] -> info: Closing connection...
16:35:29,762 INFO [1CConnector] [ManagedConnection] -> cleanup()
16:35:29,762 INFO [1CConnector] [ManagedConnection] -> cleanup()
16:35:29,762 INFO [STDOUT] [Reference Bean log] -> info: Closing connection done
16:35:29,762 INFO [STDOUT] [Reference Bean log] -> info: Removed
16:36:18,452 INFO [STDOUT] [Reference Bean log] -> info: Set session context
16:36:18,452 INFO [STDOUT] [Reference Bean log] -> info: Creating...
16:36:18,452 INFO [STDOUT] [Reference Bean log] -> info: Creating initial context...
16:36:18,472 INFO [STDOUT] [Reference Bean log] -> info: Creating initial context done
16:36:18,482 INFO [STDOUT] [Reference Bean log] -> info: lookupFactory: Looking up connection factory...
16:36:18,482 INFO [STDOUT] [Reference Bean log] -> info: result of lookup is: com.om.onec.cci.ConnectionFactoryImpl@911
540
16:36:18,482 INFO [STDOUT] [Reference Bean log] -> info: lookupFactory: Looking up connection factory done
16:36:18,482 INFO [STDOUT] [ManagedConnectionFactory] Search for matching connections in the set of 1
16:36:18,482 ERROR [STDERR] javax.resource.ResourceException: Error in use of ManagedConnectionPool: matchManagedConnect
ion failed with subject: null and ConnectionRequestInfo: com.om.onec.spi.ConnectionRequestInfoMap@1b6334e9
16:36:18,492 ERROR [STDERR] at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(Inte
rnalManagedConnectionPool.java:98)
16:36:18,492 ERROR [STDERR] at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnectio
n(JBossManagedConnectionPool.java:323)
16:36:18,492 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(Base
ConnectionManager2.java:467)
16:36:18,492 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseCo
nnectionManager2.java:532)
16:36:18,492 ERROR [STDERR] at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.al
locateConnection(BaseConnectionManager2.java:814)
16:36:18,492 ERROR [STDERR] at com.om.onec.cci.ConnectionFactoryImpl.getConnection(ConnectionFactoryImpl.java:89)
16:36:18,492 ERROR [STDERR] at Session.remote.reference.ReferenceBean.getConnection(ReferenceBean.java:91)
16:36:18,492 ERROR [STDERR] at Session.remote.reference.ReferenceBean.ejbCreate(ReferenceBean.java:186)
16:36:18,492 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:36:18,502 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
16:36:18,502 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
16:36:18,502 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
16:36:18,502 ERROR [STDERR] at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.createSession(StatefulSes
sionFilePersistenceManager.java:162)
16:36:18,502 ERROR [STDERR] at org.jboss.ejb.StatefulSessionContainer.createHome(StatefulSessionContainer.java:441)
16:36:18,502 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:36:18,502 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
16:36:18,502 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
16:36:18,502 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
16:36:18,502 ERROR [STDERR] at org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invokeHome(StatefulSessio
nContainer.java:756)
16:36:18,522 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:105)
16:36:18,522 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedCon
nectionInterceptor.java:215)
16:36:18,522 ERROR [STDERR] at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invokeHome(StatefulSessionIn
stanceInterceptor.java:128)
16:36:18,522 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:111
)
16:36:18,522 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:151)
16:36:18,522 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
16:36:18,522 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:129)
16:36:18,522 ERROR [STDERR] at org.jboss.ejb.StatefulSessionContainer.invokeHome(StatefulSessionContainer.java:368)
16:36:18,532 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:730)
16:36:18,733 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
16:36:18,733 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
16:36:18,733 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:36:18,733 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
16:36:18,753 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
16:36:18,753 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
16:36:18,753 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
16:36:18,753 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Unknown Source)
16:36:18,753 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
16:36:18,763 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Unknown Source)
16:36:18,763 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
16:36:18,763 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
16:36:18,793 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
16:36:18,793 INFO [STDOUT] [Reference Bean log] -> info: Unable to connect to adapter. System will fail to continue.
16:36:18,793 ERROR [STDERR] java.lang.NullPointerException
16:36:18,793 ERROR [STDERR] at Session.remote.reference.ReferenceBean.ejbCreate(ReferenceBean.java:198)
16:36:18,803 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:36:18,803 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
16:36:18,803 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
16:36:18,803 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
16:36:18,803 ERROR [STDERR] at org.jboss.ejb.plugins.StatefulSessionFilePersistenceManager.createSession(StatefulSes
sionFilePersistenceManager.java:162)
16:36:18,813 ERROR [STDERR] at org.jboss.ejb.StatefulSessionContainer.createHome(StatefulSessionContainer.java:441)
16:36:18,813 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:36:18,823 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
16:36:18,823 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
16:36:18,823 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
16:36:18,843 ERROR [STDERR] at org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invokeHome(StatefulSessio
nContainer.java:756)
16:36:18,843 ERROR [STDERR] at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:105)
16:36:18,843 ERROR [STDERR] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedCon
nectionInterceptor.java:215)
16:36:18,843 ERROR [STDERR] at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invokeHome(StatefulSessionIn
stanceInterceptor.java:128)
16:36:18,843 ERROR [STDERR] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:111
)
16:36:18,843 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:151)
16:36:18,843 ERROR [STDERR] at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
16:36:18,843 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:129)
16:36:18,853 ERROR [STDERR] at org.jboss.ejb.StatefulSessionContainer.invokeHome(StatefulSessionContainer.java:368)
16:36:18,853 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:730)
16:36:18,853 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)
16:36:18,853 ERROR [STDERR] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:382)
16:36:18,853 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:36:18,853 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
16:36:18,853 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
16:36:18,853 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
16:36:18,853 ERROR [STDERR] at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
16:36:18,853 ERROR [STDERR] at sun.rmi.transport.Transport$1.run(Unknown Source)
16:36:18,853 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
16:36:18,863 ERROR [STDERR] at sun.rmi.transport.Transport.serviceCall(Unknown Source)
16:36:18,863 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
16:36:18,863 ERROR [STDERR] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
16:36:18,863 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
I looked throw the source code of InternalManagedConnectionPool.java (getConnection method) and found out JBoss can't handle connections with different connection information. It takes first connection from pool (number of connections are defined in deployment descriptor). If there is no connections, it creates one, or another case transferres it (retreived connection) to a matchManagedConnection method of ManagedConnectionFactory. So last log displays, when my matchManagedConnection returnes null, I get such an exception. Why is it so?