[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-957) Support transaction interceptor with JavaBeans and custom servlets

Christian Bauer (JIRA) jira-events at lists.jboss.org
Wed Feb 28 08:01:36 EST 2007


Support transaction interceptor with JavaBeans and custom servlets
------------------------------------------------------------------

                 Key: JBSEAM-957
                 URL: http://jira.jboss.com/jira/browse/JBSEAM-957
             Project: JBoss Seam
          Issue Type: Feature Request
          Components: Core
            Reporter: Christian Bauer
            Priority: Minor


I'm using  <web:context-filter url-pattern="/files/*"/> and a custom FileServlet:

This works:

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

            String id = request.getParameter("fileId");

            NodeDAO nodeDAO = (NodeDAO) org.jboss.seam.Component.getInstance("nodeDAO");

            org.jboss.seam.wiki.core.node.File file;
            UserTransaction userTx = null;
            try {
                userTx = Transactions.getUserTransaction();
                userTx.begin();

                file = (id != null && !"".equals(id)) ? nodeDAO.findFile(Long.getLong(id)) : null;

                userTx.commit();
            } catch (Exception ex) {
                try {
                    if (userTx != null) userTx.rollback();
                } catch (Exception rbEx) {
                    rbEx.printStackTrace();
                }
                throw new RuntimeException(ex);
            }
 
This doesn't work because no JTA transaction is active when my JavaBean DAO is called (all methods there are annotated @Transactional):

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

            String id = request.getParameter("fileId");

            NodeDAO nodeDAO = (NodeDAO) org.jboss.seam.Component.getInstance("nodeDAO");

            org.jboss.seam.wiki.core.node.File file = (id != null && !"".equals(id)) ? nodeDAO.findFile(Long.getLong(id)) : null;

The Seam (seamspace) examples use EJB components, so this probably never came up before.



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list