1

Following is my method:

@Async
@Override
public void managerSmsBlackListExportTxt(SmsBlackImportInput input) {
    String blackMobile = input.getSmsBlackPhones();
    String regex = "\r\n";
    String[] blackMobiles = blackMobile.split(regex);

    Set<String> blackMobilesSet = new HashSet<>(Arrays.asList(blackMobiles));
    List<SystemPhoneFailedList> failedList = new ArrayList<>();    
    for (String userTel : blackMobilesSet) { 
        if (! this.checkTelephone(userTel.trim())){
            SystemPhoneFailedList systemPhoneFailedList = new SystemPhoneFailedList();
            ...
            failedList.add(systemPhoneFailedList);
            continue;
        }
        ...
    }

    systemPhoneFailedListBizMapper.insertSystemPhoneFailedListBatch(failedList); // the exception is in this line
}

when I debug it, I found the exception comes from(SqlSessionTemplate):

enter image description here

and the exception is: org.apache.ibatis.exceptions.PersistenceException:

Error updating database.  Cause: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.

Cause: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.

enter image description here

If I delete @Async,this method will be OK and the data will insert into MySQL successfully.

简志远
  • 11
  • 2

0 Answers0