I get a byte array from the server and then convert it to imageView. The problem is that when I used tomkat maven plug everything was fine, but as soon as I started using tomkat version 8, it turned out that

BitmapFactory.decodeByteArray 

started returning null. Error (or rather, null) started to appear after using TomCat 8 and 9 (tried and 7) All code

 // IMAGE MESSAGE if (message.getImageMessage() != null) { MessageViewHolder2 holder = new MessageViewHolder2(); LayoutInflater messageInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); byte [] ar = message.getImageMessage().getByteArray(); Bitmap bmp = BitmapFactory.decodeByteArray(ar , 0, ar.length); if (bmp!=null) { ByteArrayOutputStream out = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.JPEG, 10, out); byte[] byteArray = out.toByteArray(); // MY IMAGE // if (message.getImageMessage().isFromMe()) { // Convert bytes data into a Bitmap convertView = messageInflater.inflate(R.layout.image_my_message_layout, null); holder.messageBody = (ImageView) convertView.findViewById(R.id.imageMessageView); holder.messageBody.setImageBitmap(bmp); //Вычисляем ширину и высоту изображения double width = bmp.getWidth(); double height = bmp.getHeight(); double koef = height / 1000; int newWidht = (int) (width / koef); int newheight = (int) (height / koef); Bitmap bmHalf = Bitmap.createScaledBitmap(bmp, newWidht, newheight, false); holder.messageBody.setImageBitmap(bmHalf); } } 

Code receiving pictures on the server

  public int size =1_000_000; int sizeFoto = 0; public ByteBuffer bbuf = ByteBuffer.allocate(size); @OnMessage public void processUpload(ByteBuffer msg, boolean last, Session session) { sizeFoto +=msg.array().length; if(msg.remaining()!=1) { bbuf.put(msg); } else{ System.err.println("Size : "+sizeFoto); bbuf.put(msg); sendBuf(bbuf); } } 

    0