2 Replies Latest reply on Nov 26, 2014 1:11 AM by jaikiran

    Catching a CMT Rollback exception, don't want to log it in wildfly 8.1

    dmouch

      Hi all,

      in an ear application I'm developing (JPA2, EJB, Struts2), I want to insert possibly many rows (e.g. 1 million) retrieved from another database

      into my own. If the row retrieved from the other database already exists in my own database I don't want to insert it.

       

      To optimize this, we decided to create a unique constraint in my own database, and the logic is I don't check through code if it already exists,

      I just do em.persist(row) in a method with REQUIRES_NEW for each row and if I catch EJBTransactionRolledBackException I just ignore it

      and move on to the next row. This is working fine now, but my problem is that I get the full exception stack trace in Wildfly's console output

      and the server.log. Is there any way I could not log this, since it produces GB's in the server.log file?

       

      16:04:11,539 ERROR [org.jboss.as.ejb3.invocation] (EJB default - 4) JBAS014134: EJB Invocation failed on component RowBean for method public void com.example.RowBean.persistRow(Row): javax.ejb.EJBTransactionRolledbackException: Transaction rolled back

       

      I guess I could change wildfly's log4j in standalone.xml  for logger org.jboss.as.ejb3.invocation but I'm hoping for something less drastic.

       

      JDK is 1.8 if it is of assistance.

        • 1. Re: Catching a CMT Rollback exception, don't want to log it in wildfly 8.1
          jaysensharma

          Hello,

           

              One option to suppress, will be to use the "filter-spec" configuration something like following inside your WildFly profile :

           

          Example:

                                                                                                                                                                                                                                                  

                      <console-handler name="CONSOLE">
                          <filter-spec value="not(any(match(&quot;JBAS014134.*&quot;),match(&quot;JBAS014585.*&quot;)))"/>  
                          <level name="INFO"/>
                          <formatter>
                              <named-formatter name="COLOR-PATTERN"/>
                          </formatter>
                      </console-handler>
          
                      <periodic-rotating-file-handler name="FILE" autoflush="true">
                          <filter-spec value="not(any(match(&quot;JBAS014134.*&quot;),match(&quot;JBAS014585.*&quot;)))"/>  
                          <formatter>
                              <named-formatter name="PATTERN"/>
                          </formatter>
                          <file relative-to="jboss.server.log.dir" path="server.log"/>
                          <suffix value=".yyyy-MM-dd"/>
                          <append value="true"/>
                      </periodic-rotating-file-handler>
          

           

          Notice:

          <filter-spec value="not(any(match(&quot;JBAS014134.*&quot;),match(&quot;JBAS014585.*&quot;)))"/> 
          

           

           

          Above filter configuration in the logging subsystem should cause suppressing the Error messages containing the error code  JBAS014134 and JBAS014585

          • 2. Re: Catching a CMT Rollback exception, don't want to log it in wildfly 8.1
            jaikiran

            FWIW - there's a JIRA request to make EJB exception logging (which is mandated by spec) configurable [WFLY-4125] javax.ejb.NoSuchEJBException should not print a stacktrace on the server console - JBoss Issue Tracker