Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Exception while saving attachment - Unable to create target file

Hi together,

When I try to save an E-Mail attachment I get the following error in my log:

2017-08-09 09:41:54,838 Caesium-1-3 WARN admin LOREM [c.a.j.issue.managers.DefaultAttachmentManager] Got exception while saving attachment in attachment store. Exception: Unable to create target file /var/atlassian/jira/data/attachments/BLUBB/10000/BLUBB-106/10008
2017-08-09 09:41:54,838 Caesium-1-3 DEBUG admin LOREM [c.a.j.issue.managers.DefaultAttachmentManager]
com.atlassian.jira.issue.attachment.AttachmentMoveException: Unable to create target file /var/atlassian/jira/data/attachments/BLUBB/10000/BLUBB-106/10008
at com.atlassian.util.concurrent.Functions$ToGoogleAdapter.apply(
at com.atlassian.util.concurrent.Promises$Of$1.apply(
at com.atlassian.util.concurrent.Promises$2.onSuccess(
at com.atlassian.util.concurrent.Executors$DefaultSubmitter$
at com.atlassian.util.concurrent.LimitedExecutor$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$


Here some of my specs:

* JIRA Software 7.3.6

* runs as docker container

* file for test is a simple TXT with nothing special

* code runs inside a mail handler plugin

* I have tried to create the attachment in mutliple ways:

context.createAttachment(attachmentFile, attachmentName, attachmentContentType, user, createIssueValidationResult.getIssue());

But I always get this error. The user is allowed to create attachments and I can upload them manually with the GUI.


Does anyone have a clue how to tackle this problem?


Thank you in advance!

1 answer

1 accepted

Ok just now something strange happend. I changed the construction of my filepath to create the attachment file to this:

String filepath = PathUtils.joinPaths(attachmentPathManager.getDefaultAttachmentPath(), project, currentProject.getId().toString(), issueKey, attachmentName);

The errors I mentioned before were thrown when the last parameter of this statement was the attachment ID.

With this change I faced another error:

2017-08-10 15:58:59,267 Caesium-1-1 WARN admin IPSUM [c.a.j.issue.managers.DefaultAttachmentManager] Got exception while saving attachment in attach
ment store. Exception: /var/atlassian/jira/data/attachments/BLUBB/10000/BLUBB-139/test.pdf (No such file or directory)
2017-08-10 15:58:59,267 Caesium-1-1 DEBUG admin IPSUM [c.a.j.issue.managers.DefaultAttachmentManager] /var/atlassian/jira/data/attachments/BLUBB/10000/BLUBB-139/test.pdf (No such file or directory)
at Method)
at com.atlassian.jira.issue.managers.DefaultAttachmentManager.putAttachmentFileToAttachmentStore(
at com.atlassian.jira.issue.managers.DefaultAttachmentManager.safelyPutAttachmentFileToAttachmentStore(
at com.atlassian.jira.issue.managers.DefaultAttachmentManager.createAttachmentFromFile(
at com.atlassian.jira.issue.managers.DefaultAttachmentManager.createAttachmentImpl(
at com.atlassian.jira.issue.managers.DefaultAttachmentManager.tryCreateAttachment(
at com.atlassian.jira.issue.managers.DefaultAttachmentManager.createAttachment(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(
at com.sun.proxy.$Proxy564.createAttachment(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(
at com.sun.proxy.$Proxy564.createAttachment(Unknown Source)
at de.test.plugins.jira.custommailhandler.CustomMailHandler.handleMessage(
at com.atlassian.jira.service.ServiceRunner.runService(
at com.atlassian.jira.service.ServiceRunner.runServiceId(
at com.atlassian.jira.service.ServiceRunner.runJob(
at com.atlassian.scheduler.core.JobLauncher.runJob(
at com.atlassian.scheduler.core.JobLauncher.launchAndBuildResponse(
at com.atlassian.scheduler.core.JobLauncher.launch(
at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.launchJob(
at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeClusteredJob(
at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeClusteredJobWithRecoveryGuard(
at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService.executeQueuedJob(
at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService$1.consume(
at com.atlassian.scheduler.caesium.impl.CaesiumSchedulerService$1.consume(
at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeJob(
at com.atlassian.scheduler.caesium.impl.SchedulerQueueWorker.executeNextJob(
2017-08-10 15:58:59,267 Caesium-1-1 WARN admin IPSUM [c.a.j.issue.managers.DefaultAttachmentManager] Cannot remove source attachment file /var/atlassian/jira/data/attachments/BLUBB/10000/BLUBB-139/test.pdf


But it is getting better:

The file was attached to the issue and I can even download and open it correctly. That is some really strange thing that happens here, can anyone give me some details that I may be missing? 



Set this to 'accepted answer' because I got no response at all and it does everything as expected except throwing these missleading errors.

Hi I am also trying to add default attachment when an issue create. But it is showing error (No such file or directory)

Can you please help me with this.


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.attachment.CreateAttachmentParamsBean

def attachmentManager = ComponentAccessor.getAttachmentManager()

def user = ComponentAccessor.getJiraAuthenticationContext()?.loggedInUser

String pathToFile = "/var/atlassian/application-data/jira/"
String fileName = "ISMS_Awareness.ppt"
String pathAndFile = pathToFile+fileName

def bean = new CreateAttachmentParamsBean.Builder()
.file(new File(pathAndFile))
.copySourceFile(true)//you must do this otherwise it deletes the source file from the file system

Is it behaving like it did in my case (showing error but creating the file) or do you experience a different issue?

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you