[jboss-user] [EJB 3.0] - Problem with stateful session bean and connection
Marcos_APS
do-not-reply at jboss.com
Wed Sep 10 13:08:22 EDT 2008
Hello, everybody!
I have a stateful session bean with the following code:
| @Stateful
| public class PaginadorMateriaisBean extends PesquisaAcervoBase
| implements IPaginadorMateriais
| {
| private Connection fConexao;
| private CallableStatement fProcedimentoArmazenado;
|
| // This is a method defined in the IPaginadorMateriais interface.
| // It is a interface marked with the @Local attribute.
| public ResultadoPesquisa irParaPagina(int numeroPagina)
| {
| if (fProcedimentoArmazenado == null)
| {
| InitialContext contexto = new InitialContext();
| DataSource fonteDados =
| (DataSource) contexto.lookup("java:/BibliotecaDS");
| fConexao = fonteDados.getConnection();
|
| fProcedimentoArmazenado = ...
| }
|
| // uses fConexao and fProcedimentoArmazenado...
| }
|
| @Remove
| public void finalizar()
| {
| if (fProcedimentoArmazenado != null)
| {
| try
| {
| fProcedimentoArmazenado.close();
| }
| catch (SQLException ex)
| {
| }
| fProcedimentoArmazenado = null;
| }
| if (fConexao != null)
| {
| try
| {
| fConexao.close();
| }
| catch (SQLException ex)
| {
| }
| }
| }
| }
|
As you can see, I want to keep a connection between method calls. But I'm getting
the following error when I call the irParaPagina method from a client:
| 13:35:10,000 INFO [CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.jdk5.WrappedConnectionJDK5 at fad969
| java.lang.Throwable: STACKTRACE
| at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:290)
| at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:423)
| at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:849)
| at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
| at br.urca.www.biblioteca.gerenciador.implementacao.PaginadorMateriaisBean.irParaPagina(PaginadorMateriaisBean.java:61)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
| at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
| at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
| at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:206)
| at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:119)
| at $Proxy78.irParaPagina(Unknown Source)
| at br.urca.www.biblioteca.dados.ejb.PesquisaAcervoEJB.irParaPagina(PesquisaAcervoEJB.java:58)
| at br.urca.www.biblioteca.web.Materiais.paginaSelecionada(Materiais.java:250)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
| at java.lang.reflect.Method.invoke(Unknown Source)
| at org.apache.el.parser.AstValue.invoke(AstValue.java:131)
| at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
| at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)
| at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:99)
| at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
| at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:771)
| at javax.faces.component.UICommand.broadcast(UICommand.java:372)
| at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
| at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:755)
| at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
| at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
| at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
| at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
| at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
| at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
| at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
| at java.lang.Thread.run(Unknown Source)
|
So, what's the problem? Am I not allowed to keep a connection alive between a
stateful session bean method calls? What I am doing wrong? How can I fix this
problem?
Thank you.
Marcos
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4175652#4175652
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4175652
More information about the jboss-user
mailing list