Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1599851 - [GSS](6.4.z) URL.getContent() returns VirtualFile instead of ImageProducer
Summary: [GSS](6.4.z) URL.getContent() returns VirtualFile instead of ImageProducer
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: VFS
Version: 6.4.20
Hardware: Unspecified
OS: Unspecified
Target Milestone: CR1
: EAP 6.4.21
Assignee: jboss-set
QA Contact: Peter Mackay
Depends On:
Blocks: eap6421-payload 1602959 1606334
TreeView+ depends on / blocked
Reported: 2018-07-10 18:17 UTC by Brad Maxwell
Modified: 2018-09-04 20:27 UTC (History)
4 users (show)

Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed:
Type: Bug

Attachments (Terms of Use)
JBAS-9399.war (deleted)
2018-07-10 18:19 UTC, Brad Maxwell
no flags Details

System ID Priority Status Summary Last Updated
Red Hat One Jira Issue Tracker JBAS-9399 Major Open URL.getContent() returns VirtualFile instead of ImageProducer in JBoss AS 6.0.0.FINAL 2019-03-20 14:06:23 UTC
Red Hat One Jira Issue Tracker JBEAP-15028 Major Verified [GSS](7.1.z) URL.getContent() returns VirtualFile instead of ImageProducer 2019-03-20 14:06:23 UTC

Description Brad Maxwell 2018-07-10 18:17:14 UTC
Here are an example class and a jsp to reproduce the problem:
import java.awt.Image;
import java.beans.SimpleBeanInfo;
public class LoadImageTest extends SimpleBeanInfo {
	public Image image;

	public LoadImageTest(){
		image = loadImage2("icon.png");
	public static void main(String[] args) {
		LoadImageTest test = new LoadImageTest();
		System.out.println("Is image null? " + (test.image == null));
	// Note: This method was pulled out of the JDK src file for
	// This allows for easier debugging, you can actually see the local variables.
	public java.awt.Image loadImage2(final String resourceName) {
		try {
			final Class c = getClass();
			java.awt.image.ImageProducer ip = (java.awt.image.ImageProducer)
			new {
				public Object run() { url;
					if ((url = c.getResource(resourceName)) == null) {
						return null;
					} else {
						try {
							return url.getContent();
						} catch ( ioe) {
							return null;
			if (ip == null)
			return null;
			java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
			return tk.createImage(ip);
		} catch (Exception ex) {
			// will end up here because the PrivilegedAction returns something that cannot be cast
			// to an ImageProducer when this is run in JBoss AS 6.0.0.FINAL. In JBoss the returned
			// object will be a VirtualFile instead of an ImageProducer.
			return null;
<%@page import=""%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
out.print("Testing<br />");
LoadImageTest test = new LoadImageTest();
out.print("Is test.image null? " + (test.image == null) + "<br />");

Comment 1 Brad Maxwell 2018-07-10 18:17:42 UTC

Read the content directly such as with 

import java.awt.Image;
import javax.imageio.ImageIO;
import java.beans.SimpleBeanInfo;

            URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName);
            InputStream is = null;
            try {
               is = url.openStream();
            } catch(Exception e) {
               return null;
            } finally {
               try { is.close(); } catch(Exception e) { } 

Comment 2 Brad Maxwell 2018-07-10 18:19:49 UTC
Created attachment 1457891 [details]

Note You need to log in before you can comment on or make changes to this bug.