You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Tellier Benoit (JIRA)" <se...@james.apache.org> on 2019/01/30 04:07:00 UTC

[jira] [Created] (JAMES-2655) JPA RRT errors against mariaDB

Tellier Benoit created JAMES-2655:
-------------------------------------

             Summary: JPA RRT errors against mariaDB
                 Key: JAMES-2655
                 URL: https://issues.apache.org/jira/browse/JAMES-2655
             Project: James Server
          Issue Type: Bug
          Components: jpa, RRT
    Affects Versions: master, 3.2.0
            Reporter: Tellier Benoit


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:

{code:java}
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)
{code}


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

I propose rewritting this with simple queries.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org