3 Replies Latest reply on May 8, 2007 2:11 PM by swjackson

    'no-select-before-insert'

    gabrielbianco

      I'm not sure if I should post this here or under "Installation, Configuration & Deployment" but it's related to CMP, so...

      We found out that CMP instance creation is causing a pretty big perfomance loss... The cause is described in the wiki:
      http://wiki.jboss.org/wiki/Wiki.jsp?page=CMPInstanceCreation

      We tried 'no-select-before-insert' and it worked exactly as wiki entry says it would, with only one detail:

      First, DuplicateKeyExceptions no longe occur. Instead we get CreateExceptions. That easy to deal with. But, before we can catch the CreateException, JBoss outputs the original exception (the one it got from the DB driver). Only after that it throws us a CreateException explaining that it was probably caused by a primary key violation...

      We don't want this output at all, as it gives us a huge and hard to read stdout.log...

      The undesired output is something like this:


      14:25:58,875 ERROR [EjbName] Failed to create instance.
      java.sql.SQLException: [DBHOSTNAME]Violation of PRIMARY KEY constraint 'PK__TableName__2136E270'. Cannot insert duplicate key in object 'TableName'.
      at com.inet.tds.e.a(Unknown Source)
      ...
      large stack trace
      ...


      Is it possible to configure JBoss so it won't show certain exceptions?

        • 1. Re: 'no-select-before-insert'
          jivkoto

          The code that generates this log is from class org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand and more specifically in method protected void performInsert(EntityEnterpriseContext ctx) throws CreateException. Here is the snippet that is logging.

          ?..
           catch(SQLException e)
           {
           if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e))
           {
           log.error("Failed to create instance.", e);
           throw new CreateException(
           "Integrity constraint violation. Possibly unique key violation or invalid foreign key value."
           );
           }
           ?.
           }

          log object is org.jboss.logging.Logger instance.
          The only way that I find is not to log log level ERROR, which is too hard. Or just make feature request this logging to be changed from ERROR to WARN level. I am wondering why this is ERROR? Exception is thrown and it will not be left unnoticed, why explicitly logging is needed? If this is because throw new CreateException(??"); hides the original message and stack trace, this could be changed, too.

          Is there anyone with good explanation?

          Best Regards, jivkoto


          • 2. Re: 'no-select-before-insert'
            bartvh

            This error log is indeed very annoying. But to me, the fact that a generic CreateException is thrown is even more problematic. How do I distinguish this from some other failure in the database? I would hope I do not need to interpret the exeception's message to distinguish.

            Shouldn't this code read as:

            catch(SQLException e)
             {
             if(exceptionProcessor != null && exceptionProcessor.isDuplicateKey(e))
             {
             throw new DuplicateKeyException(
             "Integrity constraint violation:" + e.getMessage());
             }
             ...
             }


            • 3. Re: 'no-select-before-insert'
              swjackson

              }catch( Exception e){
              Throwable t = e.getCause();
              Class tclass = t.getClass();
              if( tclass.isAssignableFrom(IllegalArgumentException.class)){
              System.err.println("illegal exception ");
              }
              }