You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Eugeny N Dzhurinsky <bo...@redwerk.com> on 2008/08/08 13:25:40 UTC

JDK 1.5, 1.6 and FreeBSD

Hello, all!

I found a very strange issue - having the broker, producer and consumer
running on JDK 1.6 Blob messages aren't processed at all - in the directory
with blobs I can see partial files with blobs and nothing happens - looks like
the producer can't finish the uploading of a message for some reason.

When starting the broker at JDK 1.5 and producer/consumer at JDK 1.6 nothing
happens as well - the same behavior is being observed.

However when starting broker under JDK 1.6 and producer/consumer at JDK 1.5 I
can see such weird exception:

java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at sun.net.www.http.ChunkedOutputStream.write(ChunkedOutputStream.java:161)
        at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:2492)
        at org.apache.activemq.blob.DefaultBlobUploadStrategy.uploadStream(DefaultBlobUploadStrategy.java:63)
        at org.apache.activemq.blob.BlobUploader.upload(BlobUploader.java:53)
        at org.apache.activemq.command.ActiveMQBlobMessage.onSend(ActiveMQBlobMessage.java:163)
        at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1622)
        at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:227)
        at org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:300
)

If all of broker, consumer and producer are started using JDK 1.5 - there are
no such issues, blobs are uploaded just fine.

Is it something related to JDK 1.6, or port of JDK 1.6 for FreeBSD, or
ActiveMQ itself? May be you may need some additional information from me to
recognize the cause of the issue?

Thank you in advance!

-- 
Eugene N Dzhurinsky

Re: JDK 1.5, 1.6 and FreeBSD

Posted by Eugeny N Dzhurinsky <bo...@redwerk.com>.
Allright, I was able to resolve the issue - looks like setChunkedStreamingMode
in JDK 1.6 is either broken, or Jetty can't understand it well.

I had created the custom uploading strategy, which is using Commons HttpClient
3.1, and things are working fine. Just in case if somebody will find this
useful - I've attached a class I had created.

Thank you all for your patience :)

================================================================================
package org.apache.activemq.blob;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import javax.jms.JMSException;

import org.apache.activemq.blob.BlobTransferPolicy;
import org.apache.activemq.blob.BlobUploadStrategy;
import org.apache.activemq.blob.DefaultBlobUploadStrategy;
import org.apache.activemq.command.ActiveMQBlobMessage;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.PutMethod;

/**
 * Handles the uploading strategy using HttpClient
 */
public class HCBlobUploadStrategy extends DefaultBlobUploadStrategy implements
        BlobUploadStrategy {

    private final HttpClient client;

    public HCBlobUploadStrategy(BlobTransferPolicy transferPolicy) {
        super(transferPolicy);
        client = new HttpClient();
    }

    /**
     * @see org.apache.activemq.blob.BlobUploadStrategy#uploadFile(org.apache.activemq.command.ActiveMQBlobMessage, java.io.File)
     */
    public URL uploadFile(ActiveMQBlobMessage msg, File file)
            throws JMSException, IOException {
        InputStream stream = new FileInputStream(file);
        URL url = null;
        try {
            url = uploadStream(msg, stream);
        } finally {
            stream.close();
        }
        return url;
    }

    /**
     * @see org.apache.activemq.blob.BlobUploadStrategy#uploadStream(org.apache.activemq.command.ActiveMQBlobMessage, java.io.InputStream)
     */
    public URL uploadStream(ActiveMQBlobMessage msg, InputStream stream)
            throws JMSException, IOException {
        final URL fileURL = createUploadURL(msg);
        PutMethod put = null;
        try {
            put = new PutMethod(fileURL.toString());
            put.setContentChunked(true);
            put.setRequestEntity(new InputStreamRequestEntity(stream));
            client.executeMethod(put);
        } finally {
            if (put != null)
                put.releaseConnection();
        }
        return fileURL;
    }

}
================================================================================

-- 
Eugene N Dzhurinsky

Re: JDK 1.5, 1.6 and FreeBSD

Posted by Eugeny N Dzhurinsky <bo...@redwerk.com>.
On Fri, Aug 08, 2008 at 02:25:40PM +0300, Eugeny N Dzhurinsky wrote:
> Hello, all!
> 
> I found a very strange issue - having the broker, producer and consumer
> running on JDK 1.6 Blob messages aren't processed at all - in the directory
> with blobs I can see partial files with blobs and nothing happens - looks like
> the producer can't finish the uploading of a message for some reason.
> 
> When starting the broker at JDK 1.5 and producer/consumer at JDK 1.6 nothing
> happens as well - the same behavior is being observed.
> 
> However when starting broker under JDK 1.6 and producer/consumer at JDK 1.5 I
> can see such weird exception:
> 
> java.lang.ArrayIndexOutOfBoundsException
>         at java.lang.System.arraycopy(Native Method)
>         at sun.net.www.http.ChunkedOutputStream.write(ChunkedOutputStream.java:161)
>         at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:2492)
>         at org.apache.activemq.blob.DefaultBlobUploadStrategy.uploadStream(DefaultBlobUploadStrategy.java:63)
>         at org.apache.activemq.blob.BlobUploader.upload(BlobUploader.java:53)
>         at org.apache.activemq.command.ActiveMQBlobMessage.onSend(ActiveMQBlobMessage.java:163)
>         at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1622)
>         at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:227)
>         at org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:300
> )
> 
> If all of broker, consumer and producer are started using JDK 1.5 - there are
> no such issues, blobs are uploaded just fine.
> 
> Is it something related to JDK 1.6, or port of JDK 1.6 for FreeBSD, or
> ActiveMQ itself? May be you may need some additional information from me to
> recognize the cause of the issue?

Hello! I also found this doesn't work on Windows with JDK 1.6 as well, the
stack trace looks like below:

2008-08-11 11:13:37.253::WARN:  handle failed
java.lang.IndexOutOfBoundsException
    at java.nio.Buffer.checkIndex(Buffer.java:514)
    at java.nio.DirectByteBuffer.get(DirectByteBuffer.java:209)
    at org.mortbay.io.nio.NIOBuffer.peek(NIOBuffer.java:86)
    at org.mortbay.io.AbstractBuffer.peek(AbstractBuffer.java:306)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:655)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
    at 
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
    at 
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
2008-08-11 11:13:37.253::WARN:  EXCEPTION
java.lang.IllegalArgumentException
    at java.nio.Buffer.position(Buffer.java:218)
    at org.mortbay.io.nio.NIOBuffer.poke(NIOBuffer.java:147)
    at org.mortbay.io.AbstractBuffer.put(AbstractBuffer.java:396)
    at org.mortbay.jetty.HttpParser.reset(HttpParser.java:843)
    at org.mortbay.jetty.HttpConnection.destroy(HttpConnection.java:131)
    at 
org.mortbay.jetty.AbstractConnector.connectionClosed(AbstractConnector.java:955)
    at 
org.mortbay.jetty.nio.SelectChannelConnector.access$100(SelectChannelConnector.java:64)
    at 
org.mortbay.jetty.nio.SelectChannelConnector$1.endPointClosed(SelectChannelConnector.java:92)
    at 
org.mortbay.io.nio.SelectChannelEndPoint.doUpdateKey(SelectChannelEndPoint.java:382)
    at 
org.mortbay.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:342)
    at org.mortbay.io.nio.SelectorManager.doSelect(SelectorManager.java:167)
    at 
org.mortbay.jetty.nio.SelectChannelConnector.accept(SelectChannelConnector.java:124)
    at 
org.mortbay.jetty.AbstractConnector$Acceptor.run(AbstractConnector.java:707)
    at 
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
2008-08-11 11:13:38.253::WARN:  EXCEPTION

Should I address this issue to the developers mailing list or may be open an
issue in the JIRA/whatever used to track issues for ActiveMQ? Or may be this
issue is related to Jetty - not ActiveMQ at all?

Thank you in advance!

-- 
Eugene N Dzhurinsky