Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

QueueSender failed to send compressed file via JMS queue : NullPointerException

user11269666May 24 2016 — edited May 24 2016

String fileSource = "C:\\input.txt";

try{

     byte[] buf = new byte[2048]; 

     ByteArrayOutputStream bos = new   ByteArrayOutputStream(1024 * 4);

     ZipOutputStream zos = new ZipOutputStream(bos);    

     BufferedInputStream bis = new BufferedInputStream(new     FileInputStream(fileSource));

    ZipEntry ze = new ZipEntry(fileSource);

    zos.putNextEntry(ze);

    int len;

       while ((len = bis.read(buf)) > 0) {

           zos.write(buf, 0, len);

           }

     bis.close();

     zos.closeEntry();

     zos.close();

    // to send compressed file to onMessage method of the QueueReceiver

    ByteMessage mMessage = new ByteMessage();

     mMessage = mSession.createBytesMessage();

     mMessage.writeBytes(bos.toByteArray());           

     QueueSender.send(mMessage); // this line shows NullPointerException.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jun 21 2016
Added on May 24 2016
0 comments
1,423 views