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

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

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

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
Community showcase
Posted in United States

Welcome new members!

Wow, I got swamped and now that I've finally gotten my head back above water, I find we have several new members! Welcome @Darren Keith lowman , @Amanda Babb , @Luis Zapata , @Joli Holmes , and @bh...

31 views 0 2
View post

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