[Beginners Corner] - How to close a pooled connection in JBoss
by rohit.macherla
Hi,
I am using JBoss 4.2.2.GA on a HP Unix platform. For the sake of delegating connection management to the application server, I have started using connection pooling.
The code I used was :
| InitialContext jndiCntx = new InitialContext();
| DataSource ds = (DataSource) jndiCntx.lookup("java:/testapi");
| Connection con = (Connection)ds.getConnection();
|
But with this, I was unable to invoke any Oracle Stored Procedures that takes in an Oracle Object. I have resolved this issue by fetching the connection as :
| InitialContext jndiCntx = new InitialContext();
| WrapperDataSource ds = (WrapperDataSource) jndiCntx.lookup
| ("java:/clarityapi");
| org.jboss.resource.adapter.jdbc.WrappedConnection wrappedCon = (WrappedConnection) ds.getConnection();
| java.sql.Connection connection = wrappedCon.getUnderlyingConnection();
|
Using this, I am able to send in any Oracle Objects by using StructDescriptor's and ArrayDescriptor's wherever necessary. Also, necessary validations were put in to check if the 'wrappedCon' is 'closed' and if so I was retrying for a maximum of 4 times to check for stale connections.
However, the problem comes in when I am trying to close the connection. If i close it using :
connection.close();
there is no problem. But in the next invocations of the :
ds.getConnection()
I receive the following exception :
anonymous wrote :
| [CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.ada
| pter.jdbc.WrappedConnection@1c1ec0e
|
and the subsequent connections i receive have the following status :
wrappedCon.isClosed : false
wrappedCon.getUnderlyingConnection.isClosed() : true .
So, the WrappedConnection object is not closed, but the underlying java.sql.Connection is closed.
This "Closing a connection for you..." may be only a debug statement given for my benefit but even if I disable it, the fact is that the connection is getting closed when I wanted it to be just put back into the connection pool.
The same scenario exists when I do :
wrappedCon.close(); instead of connection.close();
Please suggest me a valid way to close these wrapped connections. I was under the impression that these close() methods would place it back into the connection pool, but probably with this output I think the JBoss connection pooling needs to be handled differently in my code.
Thanks in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4201672#4201672
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4201672
17 years, 6 months
[JBoss Portal] - Problem after Start
by jzafrilla
Environment:
jboss-portal-2.7.0.B1-bundled.zip
jbossas423
maven2
Ubuntu
Problem:
I run this:
mvn install cargo:start -Plocal-portal -DJBOSS_ZIP_HOME=jboss-portal-2.7.0.B1-bundled.zip -DJBOSS_HOME_DIR=jboss-portal-2.7.0.B1-bundled/jboss-portal-2.7.0.B1
All is ok, but when the server is started, it happend this:
[INFO] [talledLocalContainer] 10:35:50,478 INFO [Server] JBoss (MX MicroKernel) [4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=200807181417)] Started in 39s:337ms
| [INFO] [talledLocalContainer] 10:35:52,597 WARN [ServiceObjectFactory] Unable to narrow port selection for
| [INFO] [talledLocalContainer] UnifiedPortComponentRef
| [INFO] [talledLocalContainer] serviceEndpointInterface=org.jboss.portal.wsrp.core.WSRP_v1_ServiceDescription_PortType
| [INFO] [talledLocalContainer] portQName=null
| [INFO] [talledLocalContainer] enableMTOM=false
| [INFO] [talledLocalContainer] portComponentLink=null
| [INFO] [talledLocalContainer] callProperties=[]
| [INFO] [talledLocalContainer] stubProperties=[]
| [INFO] [talledLocalContainer] configName=null
| [INFO] [talledLocalContainer] configFile=null
| [INFO] [talledLocalContainer] 10:35:53,463 WARN [ServiceObjectFactory] Unable to narrow port selection for
| [INFO] [talledLocalContainer] UnifiedPortComponentRef
| [INFO] [talledLocalContainer] serviceEndpointInterface=org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType
| [INFO] [talledLocalContainer] portQName=null
| [INFO] [talledLocalContainer] enableMTOM=false
| [INFO] [talledLocalContainer] portComponentLink=null
| [INFO] [talledLocalContainer] callProperties=[]
| [INFO] [talledLocalContainer] stubProperties=[]
| [INFO] [talledLocalContainer] configName=null
| [INFO] [talledLocalContainer] configFile=null
| [INFO] [talledLocalContainer] JBoss 4.2.3 started on port [8080]
| [INFO] Press Ctrl-C to stop the container...
| [INFO] [talledLocalContainer] 10:35:54,158 WARN [ServiceObjectFactory] Unable to narrow port selection for
| [INFO] [talledLocalContainer] UnifiedPortComponentRef
| [INFO] [talledLocalContainer] serviceEndpointInterface=org.jboss.portal.wsrp.core.WSRP_v1_PortletManagement_PortType
| [INFO] [talledLocalContainer] portQName=null
| [INFO] [talledLocalContainer] enableMTOM=false
| [INFO] [talledLocalContainer] portComponentLink=null
| [INFO] [talledLocalContainer] callProperties=[]
| [INFO] [talledLocalContainer] stubProperties=[]
| [INFO] [talledLocalContainer] configName=null
| [INFO] [talledLocalContainer] configFile=null
| [INFO] [talledLocalContainer] 10:35:54,816 WARN [ServiceObjectFactory] Unable to narrow port selection for
| [INFO] [talledLocalContainer] UnifiedPortComponentRef
| [INFO] [talledLocalContainer] serviceEndpointInterface=org.jboss.portal.wsrp.core.WSRP_v1_Registration_PortType
| [INFO] [talledLocalContainer] portQName=null
| [INFO] [talledLocalContainer] enableMTOM=false
| [INFO] [talledLocalContainer] portComponentLink=null
| [INFO] [talledLocalContainer] callProperties=[]
| [INFO] [talledLocalContainer] stubProperties=[]
| [INFO] [talledLocalContainer] configName=null
| [INFO] [talledLocalContainer] configFile=null
| [INFO] [talledLocalContainer] 10:36:09,747 ERROR [STDERR] 14-ene-2009 10:36:09 com.sun.facelets.compiler.TagLibraryConfig loadImplicit
|
and i get an OutOfMemoryException
[INFO] [talledLocalContainer] 10:42:43,464 ERROR [STDERR] Exception in thread "ScannerThread"
[INFO] [talledLocalContainer] 10:42:43,464 ERROR [STDERR] java.lang.OutOfMemoryError: PermGen space
[INFO] [talledLocalContainer] 10:46:11,297 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_58] - Abort of action id 7f000101:91e1:496db1d1:344 invoked while multiple threads active within it.
[INFO] [talledLocalContainer] 10:46:11,297 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.CheckedAction_2] - CheckedAction::check - atomic action 7f000101:91e1:496db1d1:344 aborting with 1 threads active!
[INFO] [talledLocalContainer] 10:46:16,230 ERROR [STDERR] Exception in thread "Thread-4"
[INFO] [talledLocalContainer] 10:46:16,231 ERROR [STDERR] java.lang.OutOfMemoryError: PermGen space
Thank you very much and sorry for my english.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4201666#4201666
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4201666
17 years, 6 months
[Persistence, JBoss/CMP, Hibernate, Database] - Re: How to use Subqueries in a finder-Method???
by sachin1506
Hello sir
i am using declared sql as i have to run subquery
my declared-sql query is like this :-
|
| <query>
| <query-method>
| <method-name>findByMaxContactInfoId</method-name>
| <method-params/>
| </query-method>
| <declared-sql>
| <select>
| <field-name> CONTACTINFOID</field-name>
| <alias>o</alias>
| </select>
| <from>,RACONTACTINFO</from>
| <where> o.contactInfoId IN
| <select>
| <additional-columns>MAX(CONTACTINFOID) </additional-columns>
| <alias>g</alias>
| </select>
| <from>, RACONTACTINFO </from>
| </where>
| </declared-sql>
| </query>
| /code]
| i am using JBOSS 4.0.0 jdk 1.4
| But showing following exception
|
|
| | org.jboss.deployment.DeploymentException: The field-name element of declared-sql select is only allowed for ejbSelect queries
| |
|
| how can i resolve this ??
| even jboss 3.2.6 shows the same exception
|
| my original query is like this
|
| | SELECT OBJECT(o) FROM RaContactInfo AS o WHERE o.contactInfoId IN (SELECT MAX(p.contactInfoId) FROM RaContactInfo AS p
| |
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4201657#4201657
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4201657
17 years, 6 months