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

JIRA doesn't create avatar dir when uploading avatar from plugin

Alexander Muravya Sep 20, 2015

Seems like possible bug in JIRA: I try to create avatar using JIRA API. I dive into JIRA sources and found that JIRA doesn't create directory for storing avatar image. 

I do: 

//code from ru.sputnik.jira.commons.componentapi.avatar.AvatarBuilder.create()
 
return manager.create(
        my, //avatar instance
        avatarFileStream, //valid stream with images
        selection //null (full file)
);

This failes due to:

Caused by: java.lang.NullPointerException
        at javax.imageio.ImageIO.write(Unknown Source)
        at com.atlassian.jira.avatar.AvatarManagerImpl.processImage(AvatarManagerImpl.java:256)
        at com.atlassian.jira.avatar.AvatarManagerImpl.create(AvatarManagerImpl.java:154)
        at ru.sputnik.jira.commons.componentapi.avatar.AvatarBuilder.create(AvatarBuilder.java:52)

But real reason is:

java.io.FileNotFoundException: /opt/jira-data/data/avatars/10606_xxxlarge@2x_/images/void.png (No such file or directory)
        at java.io.RandomAccessFile.open(Native Method)
        at java.io.RandomAccessFile.<init>(Unknown Source)
        at javax.imageio.stream.FileImageOutputStream.<init>(Unknown Source)
        at com.sun.imageio.spi.FileImageOutputStreamSpi.createOutputStreamInstance(Unknown Source)
        at javax.imageio.ImageIO.createImageOutputStream(Unknown Source)
        at javax.imageio.ImageIO.write(Unknown Source)
        at com.atlassian.jira.avatar.AvatarManagerImpl.processImage(AvatarManagerImpl.java:256)

Here is ls -al of avatar directory:

[root@atlas-dev avatars]# ls -al /opt/jira-data/data/avatars/
total 48
drwxr-xr-x 2 root root 4096 Июл  8 12:35 .
drwxr-xr-x 4 root root 4096 Июл  8 12:35 ..
-rw-r--r-- 1 root root 1714 Июл  8 12:35 10400_attachment7886595616537147273jrvtg.png
-rw-r--r-- 1 root root 1055 Июл  8 12:35 10400_medium_attachment7886595616537147273jrvtg.png
-rw-r--r-- 1 root root  788 Июл  8 12:35 10400_small_attachment7886595616537147273jrvtg.png
-rw-r--r-- 1 root root 1722 Июл  8 12:35 10400_xlarge_attachment7886595616537147273jrvtg.png
-rw-r--r-- 1 root root  497 Июл  8 12:35 10400_xsmall_attachment7886595616537147273jrvtg.png
-rw-r--r-- 1 root root 6590 Июл  8 12:35 10400_xxlarge@2x_attachment7886595616537147273jrvtg.png
-rw-r--r-- 1 root root 3525 Июл  8 12:35 10400_xxlarge_attachment7886595616537147273jrvtg.png
-rw-r--r-- 1 root root 4078 Июл  8 12:35 10400_xxxlarge@2x_attachment7886595616537147273jrvtg.png
-rw-r--r-- 1 root root 2683 Июл  8 12:35 10400_xxxlarge_attachment7886595616537147273jrvtg.png

Disclaimer: This is dev instance and I run this from root.

Here is screenshot at fail point:

https://habrastorage.org/files/bcc/0f2/d72/bcc0f2d722054371a722281c0a8a51db.png (I could paste image here, because of HTTP error)

1 answer

1 accepted

0 votes
Answer accepted
Reinhard Moser Sep 20, 2015

Hi Alexander,

  the image will be stored in the subdirectory {{10606_xxxlarge@2x_/images/}} which does not exist. I think this is an error - you would need to change the / character in your image-name so the image can be stored.

 

Cheers

Reinhard

Alexander Muravya Sep 20, 2015

Hi Reinhard, thanx for you help. I modified my code and passed just file name "void.png" in my case. This was helpful.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase

Friday Fun: What's your best vacation planning hack?

Let's face it, work can be challenging but fulfilling, especially when you enjoy the challenges thrown at you.  However for me, nothing compares to going on vacation (or holiday as some of you m...

541 views 26 4
Join discussion

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