[Logo] Mentawai Forum - Mentawai Web Framework
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 

Forum Read-Only! Check the new site and forum here!

[ 2.5.3 ] - URGENTE - TransactionFilter não está dando rollback se instanciado no loadFilters()  XML
Forum Index -> Bugs
Author Message
ska2



Joined: 20/09/2012 20:59:36
Messages: 2
Offline

Galera, estou começando a utilizar o mentawai e acredito que descobri um problema.

Peguei a aplicação de referência, que carrega o filtro de transações no método

Code:
 @Override
 public void loadFilters() {
 }
 


no AppManager.java do projeto. Carregando dessa forma, o filtro está sendo chamado para todas as actions, mas não está dando rollback. Montei um projeto de teste provocando uma exceção na ação para mostrar, que segue abaixo.

Olhei na documentação da versão anterior do menta http://old.mentaframework.org/transfilter.jsp?loc=pt e vi que existia uma outra forma de instanciar o filtro. Da forma antiga funcionou corretamente o rollback da transação. Mas, no mesmo exemplo, da forma nova, no loadFilters() não funciona.

Coloco abaixo o código do exemplo e também o stacktrace com debug ativado.

Sobre o debug, nãoi sei se é um erro, mas tive que ativar o debug duas vezes, uma para olhar as mensagens gerais do framework e outra para olhar as mensagens de debug do TransactionFilter, postei esse problema em outro tópico: http://forum.mentaframework.org/posts/list/0/9185.page


Code:
 
 package org.events;
 
 import org.events.action.UsuarioAction;
 import org.mentawai.core.ApplicationManager;
 import org.mentawai.core.Context;
 import org.mentawai.core.Props;
 import org.mentawai.db.ConnectionHandler;
 import org.mentawai.db.DBCPConnectionHandler;
 import org.mentawai.filter.ConnectionFilter;
 import org.mentawai.filter.ExceptionFilter;
 import org.mentawai.filter.MentaContainerFilter;
 import org.mentawai.filter.TransactionFilter;
 import org.mentawai.log.Debug;
 import org.mentawai.transaction.JdbcTransaction;
 
 public class AppManager  extends ApplicationManager {
 	private Props props;
 
 	@Override
 	public void init(Context application) {
 		this.props = getProps();
 
 		setDebugMode(true);
 		Debug.enable(true);
 
 	}
 
 	
 	@Override
 	public ConnectionHandler createConnectionHandler() {
 
 		String driver = props.getString("jdbc.driver");
 		String url = props.getString("jdbc.url");
 		String user = props.getString("jdbc.user");
 		String pass = props.getString("jdbc.pass");
 
 		return new DBCPConnectionHandler(driver, url, user, pass);
 	}
 
 	@Override
 	public void loadFilters() {
 
 		filter(new MentaContainerFilter());
 		
 		// o filtro de transação não funcionou carregando por aqui
 		filter(new TransactionFilter());
 		
 		filter(new ExceptionFilter());
 		on(EXCEPTION, fwd("/error.jsp"));
 		filter(new ConnectionFilter(getConnectionHandler()));
 	}
 
 	@Override
 	public void setupIoC() {
 
 		ioc("transaction", JdbcTransaction.class);
 
 	}
 
 	@Override
 	public void loadActions() {
 		// filtro de transação FUNCIONOU carregando por aqui
 		//addGlobalFilter(new TransactionFilter());
 
 		action("/Usuario", UsuarioAction.class, "listar")
 		.on(SUCCESS, fwd("/WEB-INF/jsp/usuario/listar.jsp"))
 		.on(ERROR, fwd("/WEB-INF/jsp/usuario/listar.jsp"));
 	}
 }
 
 
 



Code:
 package org.events.action;
 
 import java.util.ArrayList;
 
 import org.events.model.Usuario;
 import org.mentawai.core.BaseAction;
 import org.mentawai.log.Debug;
 
 public class UsuarioAction extends BaseAction {
 	
 	public String listar () throws Exception {
 		if (Debug.isEnabled()) Debug.log("TESTE NA AÇÃO...", "Chamando método UsuarioAction.listar...");
 
 		ArrayList<Usuario> usuarios = new ArrayList<Usuario>();
 		
 		String teste = null;
 		
 		// Provocar exceção em tempo de execução para testar o filtro de transações. Conferir no log
 		teste.getBytes();
 
 		output.setValue("usuarios", usuarios);
 
 		return SUCCESS;
 	}
 }
 
 



Versão do log para TransactionFilter carregando no loadFilters()



21/09/2012 21:30:21 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk-amd64/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
21/09/2012 21:30:21 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:events' did not find a matching property.
21/09/2012 21:30:22 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
21/09/2012 21:30:22 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 410 ms
21/09/2012 21:30:22 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
21/09/2012 21:30:22 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
21.21:30:22 [Controller] Initializing ApplicationManager from class: org.events.AppManager

==== [ Mentawai :: MVC WEB Framework ] ==========================================================
- Version : 2.5.3 (20120813)
- ReloadAppManager: false
- DebugMode: true
- AutoView: false
- ApplicationManager: org.events.AppManager
------------------------------------------------------------------------------------
- Server: Apache Tomcat/6.0.35
- ApplicationContext: /events
- Environment: DEV
==================================================================================================

21/09/2012 21:30:22 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
21/09/2012 21:30:22 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
21/09/2012 21:30:22 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/11 config=null
21/09/2012 21:30:22 org.apache.catalina.startup.Catalina start
INFO: Server startup in 301 ms
21.21:30:31 TransactionFilter Beginning transaction...
21.21:30:31 TransactionFilter Transaction was begun! Will invoke action...
21.21:30:31 TESTE NA AÇÃO... Chamando método UsuarioAction.listar...
java.lang.NullPointerException
at org.events.action.UsuarioAction.listar(UsuarioAction.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:315)
at org.mentawai.filter.ConnectionFilter.filter(ConnectionFilter.java:81)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.ExceptionFilter.filter(ExceptionFilter.java:101)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.TransactionFilter.filter(TransactionFilter.java:169)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.MentaContainerFilter.filter(MentaContainerFilter.java:46)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.core.Controller.invokeAction(Controller.java:1147)
at org.mentawai.core.Controller.service(Controller.java:985)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:679)
java.lang.NullPointerException
at org.events.action.UsuarioAction.listar(UsuarioAction.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:315)
at org.mentawai.filter.ConnectionFilter.filter(ConnectionFilter.java:81)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.ExceptionFilter.filter(ExceptionFilter.java:101)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.TransactionFilter.filter(TransactionFilter.java:169)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.MentaContainerFilter.filter(MentaContainerFilter.java:46)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.core.Controller.invokeAction(Controller.java:1147)
at org.mentawai.core.Controller.service(Controller.java:985)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:679)


21.21:30:31 TransactionFilter Result was ok! Will commit the transaction... Result = exception
21.21:30:31 TransactionFilter Transaction was committed!


 



Versão do log para TransactionFilter carregando no loadActions() como filtro global


21/09/2012 21:32:52 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk-amd64/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
21/09/2012 21:32:52 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:events' did not find a matching property.
21/09/2012 21:32:52 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
21/09/2012 21:32:52 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 405 ms
21/09/2012 21:32:52 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
21/09/2012 21:32:52 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
21.21:32:52 [Controller] Initializing ApplicationManager from class: org.events.AppManager

==== [ Mentawai :: MVC WEB Framework ] ==========================================================
- Version : 2.5.3 (20120813)
- ReloadAppManager: false
- DebugMode: true
- AutoView: false
- ApplicationManager: org.events.AppManager
------------------------------------------------------------------------------------
- Server: Apache Tomcat/6.0.35
- ApplicationContext: /events
- Environment: DEV
==================================================================================================

21/09/2012 21:32:52 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
21/09/2012 21:32:52 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
21/09/2012 21:32:52 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/11 config=null
21/09/2012 21:32:52 org.apache.catalina.startup.Catalina start
INFO: Server startup in 314 ms
21.21:32:59 TransactionFilter Beginning transaction...
21.21:32:59 TransactionFilter Transaction was begun! Will invoke action...
21.21:32:59 TESTE NA AÇÃO... Chamando método UsuarioAction.listar...
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:315)
at org.mentawai.filter.TransactionFilter.filter(TransactionFilter.java:169)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.ConnectionFilter.filter(ConnectionFilter.java:81)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.ExceptionFilter.filter(ExceptionFilter.java:101)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.MentaContainerFilter.filter(MentaContainerFilter.java:46)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.core.Controller.invokeAction(Controller.java:1147)
at org.mentawai.core.Controller.service(Controller.java:985)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.NullPointerException
at org.events.action.UsuarioAction.listar(UsuarioAction.java:19)
... 28 more
21.21:32:59 TransactionFilter An exception was thrown while executing action! Will try to rollback... msg = null
21.21:32:59 TransactionFilter Transaction was rolled back!
java.lang.NullPointerException
at org.events.action.UsuarioAction.listar(UsuarioAction.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:315)
at org.mentawai.filter.TransactionFilter.filter(TransactionFilter.java:169)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.ConnectionFilter.filter(ConnectionFilter.java:81)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.ExceptionFilter.filter(ExceptionFilter.java:101)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.MentaContainerFilter.filter(MentaContainerFilter.java:46)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.core.Controller.invokeAction(Controller.java:1147)
at org.mentawai.core.Controller.service(Controller.java:985)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:679)
java.lang.NullPointerException
at org.events.action.UsuarioAction.listar(UsuarioAction.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:315)
at org.mentawai.filter.TransactionFilter.filter(TransactionFilter.java:169)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.ConnectionFilter.filter(ConnectionFilter.java:81)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.ExceptionFilter.filter(ExceptionFilter.java:101)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.filter.MentaContainerFilter.filter(MentaContainerFilter.java:46)
at org.mentawai.core.InvocationChain.invoke(InvocationChain.java:147)
at org.mentawai.core.Controller.invokeAction(Controller.java:1147)
at org.mentawai.core.Controller.service(Controller.java:985)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:679)



 



Lista das bibliotecas que estou utilizando no projeto (somente estas, para ambiente de teste):

  • commons-collections-3.2.1.jar
  • commons-dbcp-1.4.jar
  • commons-pool-1.5.4.jar
  • mentabean-1.2.2.jar
  • menta-container-0.9.9.jar
  • mentawai-2.5.3.jar
    [list]mysql-connector-java-5.1.13.jar

    [/list]

  • Server: Apache Tomcat/6.0.35
  • Java: java-6-openjdk-amd64
  • OS: Ubuntu 12.04.1 LTS
  • MySQL: Ver 14.14 Distrib 5.5.24, for debian-linux-gnu (x86_64) using readline 6.2 (que está no exemplo, mas só foi utilizado para inciar a conexão)
  •  
    Forum Index -> Bugs
    Go to:   
    Powered by JForum 2.1.6 © JForum Team