ImageCropper problem. {0} Conversion error occured

UI Components for JSF
Post Reply
salman4u
Posts: 78
Joined: 24 Jan 2010, 10:28

26 May 2010, 06:53

Hello,
While using ImageCropper, i always get Conversion error occured. What can be the problem? Thanks in advance :). I am using Glassfish V3, Netbeans 6.8, Mozialla 3.5.6

The showcase runs fine for me.

Edit :- This is bug with Primefaces. if i give simple image which is in my document root, it works fine. But if i give alternatedocroot_1 in my sun-web.xml (accessing images outside my document root) i get this error.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

29 May 2010, 11:50

ImageCropper can crop local images in webroot and external images located with http://. I don't think it is a bug but more like a limitation as it doesn't support glassfish specific stuff like this.

Tatsu
Posts: 3
Joined: 20 Mar 2011, 05:30

11 Dec 2012, 02:58

Hello,

in my opinion there are two reasons who indicates that supporting external docroots is desirable in enterprise context.
1. Mounting big data sources out of web application archive.
2. Using external image context effects that the images can't be inside a web-resource with activated security.

Solution that works for me:

File: ImageCropperRenderer.java
Package: org.primefaces.component.imagecropper

Code: Select all

private BufferedImage getSourceImage(FacesContext context, String imagePath) throws IOException {
        BufferedImage outputImage = null;
        String absolutePath = null;
        boolean isExternal = imagePath.startsWith("http");

        if (isExternal) {
            URL url = new URL(imagePath);

            outputImage = ImageIO.read(url);
        } else {
            ServletContext servletContext = (ServletContext) context.getExternalContext().getContext();

            // support for alternatedocroot (e.g. glassfish)
            if (servletContext.getAttribute("org.apache.catalina.alternateResources") != null) {
                AlternateDocBase matchedAlternateDocBase = AlternateDocBase.findMatch(
                        imagePath, 
                        (ArrayList<AlternateDocBase>) servletContext.getAttribute("org.apache.catalina.alternateResources"));

                if (matchedAlternateDocBase != null) {
                    absolutePath = matchedAlternateDocBase.getBasePath() + imagePath;
                }
            }
            // default
            if (absolutePath == null) {
                absolutePath = servletContext.getRealPath("") + imagePath;
            }
            outputImage = ImageIO.read(new File(absolutePath));

        }

        return outputImage;
    }
@optimus.prime: Would you patch the Code in trunk?

greetings

tatsu

professional
Posts: 37
Joined: 05 Jun 2013, 19:29

25 Jul 2013, 16:33

Optimus or any who could helpe me,

What about if I want to allow the user post an image and keep it in his local machine? I'm talking about a possibility where I don't want to allow the user upload images from his local machine to the server, but keep the images in a specific path in his local machine.
JSF 2.1, Primefaces 3.5.9, Primefaces-extensions-0.7.1, GlassFish Server 3.1.2, Java EE 6 Web, JDK 1.7, Eclipselink-2.3.2 and Netbeans 7.3

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

25 Jul 2013, 16:43

Search the internet... you *cannot* access files on a local machine from the webbrowser...

And please do not create zombies... (bringing dead threads back to 'life')

professional
Posts: 37
Joined: 05 Jun 2013, 19:29

25 Jul 2013, 19:53

kukeltje,

I said "specific path". the user can register a previous path and after that he/she can fetch images from there.

Also, I didn't find a place in this forum which classifies a thread as a zombie or not.
JSF 2.1, Primefaces 3.5.9, Primefaces-extensions-0.7.1, GlassFish Server 3.1.2, Java EE 6 Web, JDK 1.7, Eclipselink-2.3.2 and Netbeans 7.3

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

25 Jul 2013, 20:12

professional wrote:I said "specific path". the user can register a previous path and after that he/she can fetch images from there.
You cannot access it on a browser local machine in ANY path... But maybe I misunderstood you... I'm not a native english speaker
professional wrote:Also, I didn't find a place in this forum which classifies a thread as a zombie or not.
In the forum posting rules it says:
7) Avoid continuing with "I have the same problem" to old threads started by another, create a new thread for your case instead.
And yes, this is maybe not as explicit, but if you follow the forum a little (and you should), you'd remember the zombi thing was mentioned multiple, no many times... It is over three years old. Components are changed so much, versions of browsers, jee servers etc have changed, that in almost every case, the relation is non-existent, But in this specific case... well.... hmmmm....

enez
Posts: 4
Joined: 09 Oct 2016, 18:04

17 Feb 2017, 15:01

Is there still limitation to use http? I have to use https on page but have issue with cropper with mentioned error {0}Conversion error occured. When I use http on app then everything is fine.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 65 guests