I am trying to load an image from a url and crop it. I created a method and uploaded it to the hosted services in the business logic section. My java code looks similar to this.

public void uploadProfilePhoto(int x, int y, int w, int h, String filePath) {
    try {
        BufferedImage originanlImg = URL(filePath));
        BufferedImage croppedImg = originanlImg.getSubimage(x, y, w, h);
    } catch (IOException e) {

However, it is crashing on the line. I am getting this error when I test it in the console:

“code”: 0,
“message”: “java.lang.NoClassDefFoundError: Could not initialize class javax.imageio.ImageIOServiceException”

Any advice?

Hi Phil,

It is either the call to creates a thread (which is not allowed yet in custom code) or one of the dependent classes is missing in the jar you deployed.


Try changing the catch clause to catch Throwable and see what it catches.


I have the same error Could not initialize class javax.imageio.ImageIO
What should i add else to project?

My call to was creating a thread so I had to remove my code and crop my images using a javascript plugin, instead. Hope that helps.

Can you link to this plugin?

This is the plugin I used. It lets you convert the cropped image to base64. Which you can then upload as a file.

As i understood we can not mix lang in custom code. So i have some java logic and can not add js implementation to crop images :frowning:

That is correct. In the current implementation of custom business logic languages cannot be mixed.