Page 1 of 1

Error while exporting

PostPosted:Tue Mar 08, 2022 3:12 pm
by taranu.andrei
Hello,

When i try to export from the application, I get this error:
Screenshot_3.png
Screenshot_3.png (10.32 KiB) Viewed 1980 times
I searched in catalina.log and found this:
InkedScreenshot_2_LI.jpg
InkedScreenshot_2_LI.jpg (991.54 KiB) Viewed 1976 times
Code: Select all
2022-03-08 16:15:55,058 [http-bio-0.0.0.0-8080-exec-2] ERROR com.openkm.util.impexp.RepositoryExporter- Local address contains control or whitespace
javax.mail.internet.AddressException: Local address contains control or whitespace in string ``00000002514331e9-e36e-4401-8ea7-cbe6fffa656c@DOMAIN/o=DOMAIN/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=firstiname.lastname''

I'm using OpenKM 6.3 CE, MySQL.

I understood, after some research, that Openkm CE, is not accepting some characters.
How can I identify the file with problem? Where should i look? in databse i found nothing.

I've tryed that, but didnt work for me. SQL syntax difference. Also, in catalina.log, it looks like a string, not an UUID.
Code: Select all
select concat(,'[',NBS_NAME,']') from OKM_NODE_BASE WHERE NBS_UUID='doc uuid here';
Please help.
Thank you.

Re: Error while exporting

PostPosted:Sat Mar 12, 2022 10:15 am
by jllort
First do a backup of your database and then try to execute the next script:

// The next script will help on identify emails with problems:
Code: Select all
import com.openkm.core.DatabaseException;
import com.openkm.dao.bean.NodeMail;
import com.openkm.dao.HibernateUtil;
import javax.mail.internet.*;
import org.hibernate.*;
import java.util.*;

String qs = "from NodeMail nm";
Session session = null;

try {
    session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();
 
    Query q = session.createQuery(qs);
 
    for (NodeMail nm : q.list()) {
        try {
            new InternetAddress(nm.getFrom());
            for (String address : nm.getTo()) {
                new InternetAddress(address);
            }
            for (String address : nm.getReply()) {
                new InternetAddress(address);
            }
            for (String address : nm.getCc()) {
                new InternetAddress(address);
            }
            for (String address : nm.getBcc()) {
                new InternetAddress(address);
            }
        } catch (AddressException e) {
            print("Error con : " + nm.getUuid() + "<br>");
        }
    }
 
    HibernateUtil.commit(session.getTransaction());
} catch (HibernateException e) {
    HibernateUtil.rollback(session.getTransaction());
    throw new DatabaseException(e.getMessage(), e);
} finally {
    HibernateUtil.close(session);
}

// The next script will try to solve problems on them
Code: Select all
import com.openkm.core.DatabaseException;
import com.openkm.dao.bean.NodeMail;
import com.openkm.dao.HibernateUtil;
import javax.mail.internet.*;
import org.hibernate.*;
import java.util.*;

String qs = "from NodeMail nm";
Session session = null;

try {
    session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();
 
    Query q = session.createQuery(qs);
    
    for (NodeMail nm : q.list()) {
        try {
            new InternetAddress(nm.getFrom());
            for (String address : nm.getTo()) {
                new InternetAddress(address);
            }
            for (String address : nm.getReply()) {
                new InternetAddress(address);
            }
            for (String address : nm.getCc()) {
                new InternetAddress(address);
            }
            for (String address : nm.getBcc()) {
                new InternetAddress(address);
            }
        } catch (AddressException e) {
            print("Error con : " + nm.getUuid() + "<br>");
            nm.from = nm.from.replaceAll(",", "").trim();

            // to
            Set to = new HashSet();
            for (String address : nm.getTo()) {
                to.add(address.replaceAll(",", "").trim());
            }
            nm.to = to;

            // reply
            Set reply = new HashSet();
            for (String address : nm.getReply()) {
                reply.add(address.replaceAll(",", "").trim());
            }
            nm.reply = reply;

            // Cc
            Set cc = new HashSet();
            for (String address : nm.getCc()) {
                cc.add(address.replaceAll(",", "").trim());
            }
            nm.cc = cc;

            // Bcc
            Set bcc = new HashSet();
            for (String address : nm.getBcc()) {
                bcc.add(address.replaceAll(",", "").trim());
            }
            nm.bcc = bcc;
            session.update(nm);
        }
    }
 
    HibernateUtil.commit(session.getTransaction());
} catch (HibernateException e) {
    HibernateUtil.rollback(session.getTransaction());
    throw new DatabaseException(e.getMessage(), e);
} finally {
    HibernateUtil.close(session);
}

Re: Error while exporting

PostPosted:Mon Mar 14, 2022 2:37 pm
by taranu.andrei
Hello,

Thank you for your reply.

I managed to export all the repository folder and database on the new location, from linux terminal and MySQL.

I tryed your workaround. I have a question. This scripts must be run in app, Administration -> Scripting?
If so, i get errors on both scripts.

First script:
Script error:
Code: Select all
Sourced file: inline evaluation of: ``import com.openkm.core.DatabaseException; import com.openkm.dao.bean.NodeMail; . . . '' : Object constructor : at Line: 19 : in file: inline evaluation of: ``import com.openkm.core.DatabaseException; import com.openkm.dao.bean.NodeMail; . . . '' : new InternetAddress ( nm .getFrom ( ) ) Target exception: java.lang.NullPointerException

Script output:
Code: Select all
Error con : 14b5f24e-3536-4bdb-9d92-bd8bf2b07966<br> Error con : 3daef15d-4a45-4482-baaf-f96d63098cbc<br> Error con : 4f01f57f-aa6f-4167-a978-eecbf0c46151<br> Error con : 692913c8-4d85-4110-8dcf-5decc60340a6<br>

Second script:
Script error:
Code: Select all
Sourced file: inline evaluation of: ``import com.openkm.core.DatabaseException; import com.openkm.dao.bean.NodeMail; . . . '' : Object constructor : at Line: 19 : in file: inline evaluation of: ``import com.openkm.core.DatabaseException; import com.openkm.dao.bean.NodeMail; . . . '' : new InternetAddress ( nm .getFrom ( ) ) Target exception: java.lang.NullPointerException

Script output:
Code: Select all
Error con : 14b5f24e-3536-4bdb-9d92-bd8bf2b07966<br> Error con : 3daef15d-4a45-4482-baaf-f96d63098cbc<br> Error con : 4f01f57f-aa6f-4167-a978-eecbf0c46151<br> Error con : 692913c8-4d85-4110-8dcf-5decc60340a6<br>
Thank you!

Re: Error while exporting

PostPosted:Sat Mar 19, 2022 8:56 am
by jllort
Seems in both script seems you have null value in the from field ( should not be ). I suggest update the null values to "" in the table OKM_NODE_MAIL ( column that keeps EMAIL and the other fields ). Before applying the update I suggest do a backup of the database. When done, try to execute the scripts again.