Uploaded image for project: 'James Server'
  1. James Server
  2. JAMES-2655

JPA RRT errors against mariaDB

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: master, 3.2.0
    • Fix Version/s: master, 3.3.0
    • Component/s: jpa, RRT
    • Labels:

      Description

      Some complex JPA queries leads to some SQL errors on top of a mariaDB database as reported on the user mailing list by Marc Chamberlin.

      Here is the stack trace:

      org.apache.james.transport.mailets.RecipientRewriteTableProcessor |
      Could not rewrite recipient myname@mydomain.com
      org.apache.james.rrt.api.RecipientRewriteTableException: Error while
      retrieve mappings
              at
      org.apache.james.rrt.jpa.JPARecipientRewriteTable.getMapping(JPARecipientRewriteTable.java:107)
              at
      org.apache.james.rrt.jpa.JPARecipientRewriteTable.mapAddress(JPARecipientRewriteTable.java:79)
              at
      org.apache.james.rrt.lib.AbstractRecipientRewriteTable.getMappings(AbstractRecipientRewriteTable.java:110)
              at
      org.apache.james.rrt.lib.AbstractRecipientRewriteTable.getMappings(AbstractRecipientRewriteTable.java:99)
              at
      org.apache.james.transport.mailets.RecipientRewriteTableProcessor.executeRrtForRecipient(RecipientRewriteTableProcessor.java:164)
              at
      org.apache.james.transport.mailets.RecipientRewriteTableProcessor.lambda$executeRrtFor$1(RecipientRewriteTableProcessor.java:153)
              at
      java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
              at java.util.Collections$2.tryAdvance(Collections.java:4717)
              at java.util.Collections$2.forEachRemaining(Collections.java:4725)
              at
      java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
              at
      java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
              at
      java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
              at
      java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
              at
      java.util.stream.ReferencePipeline.reduce(ReferencePipeline.java:474)
              at
      org.apache.james.transport.mailets.RecipientRewriteTableProcessor.executeRrtFor(RecipientRewriteTableProcessor.java:159)
              at
      org.apache.james.transport.mailets.RecipientRewriteTableProcessor.processMail(RecipientRewriteTableProcessor.java:129)
              at
      org.apache.james.transport.mailets.RecipientRewriteTable.service(RecipientRewriteTable.java:88)
              at
      org.apache.james.mailetcontainer.impl.camel.CamelProcessor.process(CamelProcessor.java:81)
              at
      org.apache.james.mailetcontainer.impl.camel.CamelMailetProcessor$MailetContainerRouteBuilder.handleMailet(CamelMailetProcessor.java:178)
              at
      org.apache.james.mailetcontainer.impl.camel.CamelMailetProcessor$MailetContainerRouteBuilder.lambda$configure$0(CamelMailetProcessor.java:155)
      
      yada yada yada - some walkback messages deleted here....
      
              at
      java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
              at java.lang.Thread.run(Thread.java:748)
      Caused by: <openjpa-3.0.0-r422266:1833209 nonfatal general error>
      org.apache.openjpa.persistence.PersistenceException: Could not set
      parameter at position 2 (values was 'mydomain.com')
      Query - conn:47(M)  - "SELECT t0.DOMAIN_NAME, t0.USER_NAME,
      t0.TARGET_ADDRESS FROM JAMES_RECIPIENT_REWRITE t0 WHERE (t0.USER_NAME
      LIKE ? ESCAPE '\\' AND t0.DOMAIN_NAME LIKE ? ESCAPE '\\') ORDER BY
      t0.DOMAIN_NAME DESC"
      FailedObject: SELECT rrt FROM JamesRecipientRewrite rrt WHERE (rrt.user
      LIKE :user) and (rrt.domain like :domain) ORDER BY rrt.domain DESC
      [java.lang.String]
              at
      org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:5038)
              at
      org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4998)
              at
      org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:134)
      
      yada yada yada - some walkback messages deleted here....
      
              at
      org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:290)
              at
      org.apache.james.rrt.jpa.JPARecipientRewriteTable.getMapping(JPARecipientRewriteTable.java:96)
              ... 81 more
      Caused by: java.sql.SQLException: Could not set parameter at position 2
      (values was 'mydomain.com')
      Query - conn:47(M)  - "SELECT t0.DOMAIN_NAME, t0.USER_NAME,
      t0.TARGET_ADDRESS FROM JAMES_RECIPIENT_REWRITE t0 WHERE (t0.USER_NAME
      LIKE ? ESCAPE '\\' AND t0.DOMAIN_NAME LIKE ? ESCAPE '\\') ORDER BY
      t0.DOMAIN_NAME DESC"
              at
      org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getSqlException(ExceptionMapper.java:271)
              at
      org.mariadb.jdbc.MariaDbPreparedStatementClient.setParameter(MariaDbPreparedStatementClient.java:480)
              at
      org.mariadb.jdbc.BasePrepareStatement.setString(BasePrepareStatement.java:1533)
              at
      org.apache.commons.dbcp.DelegatingPreparedStatement.setString(DelegatingPreparedStatement.java:135)
      

      The mapAddress method uses some unnessessary complex queries. This hurts portability (only tested against derby).

      I propose rewritting this with simple queries.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              btellier Benoit Tellier
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: