You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by David Beer <da...@gmail.com> on 2014/07/07 22:18:14 UTC

Displaying Images Stored in DB on Openshift

Hi All

I am developing and application that is running on openshift. The
application is still in heavy development, using wicket 6.14 at the moment.
I am running Wildlfy 8.1.0 and testing locally.

The problem I am facing is simply that the images that I am storing are not
being displayed on Openshift but work fine locally. I am retrieving the
image as a byte[] from the database and then displaying the Image.

I have tried using a simple ByteArray Resource like the following:

ThumbnailImageResource imageResource = new ThumbnailImageResource(new
ByteArrayResource("image/jpeg", userAccount.getProfileimage().getFile()),
150);
            Image profileImage = new Image("profileImage", imageResource);
            add(profileImage);

However on Openshift the image does not display. There is no error logged
just no image and the resource link does not seem to work either.

Any thoughts would be most helpful.

Thanks

David

Re: Displaying Images Stored in DB on Openshift

Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Hi,


On Mon, Jul 14, 2014 at 10:38 PM, David Beer <da...@gmail.com> wrote:

> Hi Martin
>
> Thanks for your reply. Attaching a debugger is really easy with OpenShift
> and is what I did. I was able to see that storing the file was in fact
> producing the wrong set of image bytes, hibernate postgresql issue. Once
> fixed I was able to check the file and image properly. All seemed to work
> so randomly I cleared the browser cache and all works well. Is there a way
> to stop the browser caching the images if I wanted to?
>

Lock at NonCachingImage: it generates a random noise so that images are
always reloaded. Also on FF you can play with about:config to disable
caching.

>
> Thanks
>
> David
>
>
> On 14 July 2014 08:41, Martin Grigorov <mg...@apache.org> wrote:
>
> > Hi,
> >
> > Is it possible to attach remote debugger to OpenShift and see what
> happens
> > ?
> > If it is not possible then add some logging statements and see what is
> > returned from the DB (byte[]) and whether Wicket creates a proper
> > BufferedImage, whether it is written down in the resource's
> WriteCallback,
> > etc.
> >
> > Martin Grigorov
> > Wicket Training and Consulting
> > https://twitter.com/mtgrigorov
> >
> >
> > On Sun, Jul 13, 2014 at 11:16 PM, David Beer <da...@gmail.com>
> > wrote:
> >
> > > Hi Guys
> > >
> > > After some more trial and error and research I have got the image to
> > store
> > > properly and write back out a valid image using BufferedImage and
> > ImageIO.
> > > However I am still not able to display the image. I just get the
> picture
> > > symbol and he link looks like <img alt=""
> > > src="./account?12-IResourceListener-profileImage">.
> > >
> > > The code used is as follows:
> > >
> > > BufferedDynamicImageResource bufferedDynamicImageResource = new
> > > BufferedDynamicImageResource("jpeg");
> > > bufferedDynamicImageResource.setImage(image);
> > > Image proImage = new Image("profileImage",
> bufferedDynamicImageResource);
> > > add(proImage);
> > >
> > > Where image is a BufferedImage. The file command outputs the following.
> > >
> > > I am running Wildfly 8.1.0. Any suggestions .
> > >
> > > Thanks
> > >
> > > David
> > >
> > >
> > > On 7 July 2014 21:18, David Beer <da...@gmail.com> wrote:
> > >
> > > > Hi All
> > > >
> > > > I am developing and application that is running on openshift. The
> > > > application is still in heavy development, using wicket 6.14 at the
> > > moment.
> > > > I am running Wildlfy 8.1.0 and testing locally.
> > > >
> > > > The problem I am facing is simply that the images that I am storing
> are
> > > > not being displayed on Openshift but work fine locally. I am
> retrieving
> > > the
> > > > image as a byte[] from the database and then displaying the Image.
> > > >
> > > > I have tried using a simple ByteArray Resource like the following:
> > > >
> > > > ThumbnailImageResource imageResource = new ThumbnailImageResource(new
> > > > ByteArrayResource("image/jpeg",
> > userAccount.getProfileimage().getFile()),
> > > > 150);
> > > >             Image profileImage = new Image("profileImage",
> > > imageResource);
> > > >             add(profileImage);
> > > >
> > > > However on Openshift the image does not display. There is no error
> > logged
> > > > just no image and the resource link does not seem to work either.
> > > >
> > > > Any thoughts would be most helpful.
> > > >
> > > > Thanks
> > > >
> > > > David
> > > >
> > >
> >
>



-- 
Regards - Ernesto Reinaldo Barreiro

Re: Displaying Images Stored in DB on Openshift

Posted by David Beer <da...@gmail.com>.
Hi Martin

Thanks for your reply. Attaching a debugger is really easy with OpenShift
and is what I did. I was able to see that storing the file was in fact
producing the wrong set of image bytes, hibernate postgresql issue. Once
fixed I was able to check the file and image properly. All seemed to work
so randomly I cleared the browser cache and all works well. Is there a way
to stop the browser caching the images if I wanted to?

Thanks

David


On 14 July 2014 08:41, Martin Grigorov <mg...@apache.org> wrote:

> Hi,
>
> Is it possible to attach remote debugger to OpenShift and see what happens
> ?
> If it is not possible then add some logging statements and see what is
> returned from the DB (byte[]) and whether Wicket creates a proper
> BufferedImage, whether it is written down in the resource's WriteCallback,
> etc.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
>
> On Sun, Jul 13, 2014 at 11:16 PM, David Beer <da...@gmail.com>
> wrote:
>
> > Hi Guys
> >
> > After some more trial and error and research I have got the image to
> store
> > properly and write back out a valid image using BufferedImage and
> ImageIO.
> > However I am still not able to display the image. I just get the picture
> > symbol and he link looks like <img alt=""
> > src="./account?12-IResourceListener-profileImage">.
> >
> > The code used is as follows:
> >
> > BufferedDynamicImageResource bufferedDynamicImageResource = new
> > BufferedDynamicImageResource("jpeg");
> > bufferedDynamicImageResource.setImage(image);
> > Image proImage = new Image("profileImage", bufferedDynamicImageResource);
> > add(proImage);
> >
> > Where image is a BufferedImage. The file command outputs the following.
> >
> > I am running Wildfly 8.1.0. Any suggestions .
> >
> > Thanks
> >
> > David
> >
> >
> > On 7 July 2014 21:18, David Beer <da...@gmail.com> wrote:
> >
> > > Hi All
> > >
> > > I am developing and application that is running on openshift. The
> > > application is still in heavy development, using wicket 6.14 at the
> > moment.
> > > I am running Wildlfy 8.1.0 and testing locally.
> > >
> > > The problem I am facing is simply that the images that I am storing are
> > > not being displayed on Openshift but work fine locally. I am retrieving
> > the
> > > image as a byte[] from the database and then displaying the Image.
> > >
> > > I have tried using a simple ByteArray Resource like the following:
> > >
> > > ThumbnailImageResource imageResource = new ThumbnailImageResource(new
> > > ByteArrayResource("image/jpeg",
> userAccount.getProfileimage().getFile()),
> > > 150);
> > >             Image profileImage = new Image("profileImage",
> > imageResource);
> > >             add(profileImage);
> > >
> > > However on Openshift the image does not display. There is no error
> logged
> > > just no image and the resource link does not seem to work either.
> > >
> > > Any thoughts would be most helpful.
> > >
> > > Thanks
> > >
> > > David
> > >
> >
>

Re: Displaying Images Stored in DB on Openshift

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Is it possible to attach remote debugger to OpenShift and see what happens ?
If it is not possible then add some logging statements and see what is
returned from the DB (byte[]) and whether Wicket creates a proper
BufferedImage, whether it is written down in the resource's WriteCallback,
etc.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov


On Sun, Jul 13, 2014 at 11:16 PM, David Beer <da...@gmail.com> wrote:

> Hi Guys
>
> After some more trial and error and research I have got the image to store
> properly and write back out a valid image using BufferedImage and ImageIO.
> However I am still not able to display the image. I just get the picture
> symbol and he link looks like <img alt=""
> src="./account?12-IResourceListener-profileImage">.
>
> The code used is as follows:
>
> BufferedDynamicImageResource bufferedDynamicImageResource = new
> BufferedDynamicImageResource("jpeg");
> bufferedDynamicImageResource.setImage(image);
> Image proImage = new Image("profileImage", bufferedDynamicImageResource);
> add(proImage);
>
> Where image is a BufferedImage. The file command outputs the following.
>
> I am running Wildfly 8.1.0. Any suggestions .
>
> Thanks
>
> David
>
>
> On 7 July 2014 21:18, David Beer <da...@gmail.com> wrote:
>
> > Hi All
> >
> > I am developing and application that is running on openshift. The
> > application is still in heavy development, using wicket 6.14 at the
> moment.
> > I am running Wildlfy 8.1.0 and testing locally.
> >
> > The problem I am facing is simply that the images that I am storing are
> > not being displayed on Openshift but work fine locally. I am retrieving
> the
> > image as a byte[] from the database and then displaying the Image.
> >
> > I have tried using a simple ByteArray Resource like the following:
> >
> > ThumbnailImageResource imageResource = new ThumbnailImageResource(new
> > ByteArrayResource("image/jpeg", userAccount.getProfileimage().getFile()),
> > 150);
> >             Image profileImage = new Image("profileImage",
> imageResource);
> >             add(profileImage);
> >
> > However on Openshift the image does not display. There is no error logged
> > just no image and the resource link does not seem to work either.
> >
> > Any thoughts would be most helpful.
> >
> > Thanks
> >
> > David
> >
>

Re: Displaying Images Stored in DB on Openshift

Posted by David Beer <da...@gmail.com>.
Hi Guys

After some more trial and error and research I have got the image to store
properly and write back out a valid image using BufferedImage and ImageIO.
However I am still not able to display the image. I just get the picture
symbol and he link looks like <img alt=""
src="./account?12-IResourceListener-profileImage">.

The code used is as follows:

BufferedDynamicImageResource bufferedDynamicImageResource = new
BufferedDynamicImageResource("jpeg");
bufferedDynamicImageResource.setImage(image);
Image proImage = new Image("profileImage", bufferedDynamicImageResource);
add(proImage);

Where image is a BufferedImage. The file command outputs the following.

I am running Wildfly 8.1.0. Any suggestions .

Thanks

David


On 7 July 2014 21:18, David Beer <da...@gmail.com> wrote:

> Hi All
>
> I am developing and application that is running on openshift. The
> application is still in heavy development, using wicket 6.14 at the moment.
> I am running Wildlfy 8.1.0 and testing locally.
>
> The problem I am facing is simply that the images that I am storing are
> not being displayed on Openshift but work fine locally. I am retrieving the
> image as a byte[] from the database and then displaying the Image.
>
> I have tried using a simple ByteArray Resource like the following:
>
> ThumbnailImageResource imageResource = new ThumbnailImageResource(new
> ByteArrayResource("image/jpeg", userAccount.getProfileimage().getFile()),
> 150);
>             Image profileImage = new Image("profileImage", imageResource);
>             add(profileImage);
>
> However on Openshift the image does not display. There is no error logged
> just no image and the resource link does not seem to work either.
>
> Any thoughts would be most helpful.
>
> Thanks
>
> David
>