Unable to load image, please help

174 views
Skip to first unread message

Sednus

unread,
Jan 27, 2011, 9:38:22 AM1/27/11
to Google Web Toolkit
Hi,
Im trying load an image from the server using RPC, the problem is
that it always fails to load the image and throws the following error:
com.google.gwt.user.client.rpc.StatusCodeException: 403 <html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1"/>
<title>Error 403 FORBIDDEN</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /diskmonitor/. Reason:
<pre> FORBIDDEN</pre></p><hr /><i><small>Powered by Jetty://</small></i><br/>
....


Im implementing my classes as the following:


public class ChartImage extends Image {
private UpdatePlotsServiceAsync plotService;

public ChartImage(String hostname) {
super();

/*
* Setup connection to chart generator service.
*/
plotService = (UpdatePlotsServiceAsync)
GWT.create(UpdatePlotsService.class);
ServiceDefTarget endpoint = (ServiceDefTarget)plotService;
String url = GWT.getModuleBaseURL()+"";
System.out.println(url);
endpoint.setServiceEntryPoint(url);

/*
* Setup the callback from the chart generator service.
*/
AsyncCallback<String> callback = new AsyncCallback<String>()
{
/*
* If the call was successful, we will get back the name
of the chart
* that was created and stored on the server.
*/
public void onSuccess(String s) {
String chartName = (String)s;
String imageUrl = GWT.getModuleBaseURL() + chartName;
setUrl(imageUrl);
}

/*
* Something went wrong with the call. Handle the issue
how you'd like.
*/
public void onFailure(Throwable ex) {
System.out.println("Failed to load image");
ex.printStackTrace();
}
};

/*
* Make the call to the chart generator service with the
previously created
* callback.
*/
plotService.getImagesPaths("default", callback);

/*
* Since we've made an asynchronous call, we don't need to do
anything further.
* The callback object will handle the remainder of the work
for us.
*/
}
}



The image is generated in the server side using JFreeChart

public class UpdatePlotsServiceImpl extends RemoteServiceServlet
implements UpdatePlotsService {
@Override
public String getImagesPaths(String hostname) {
String chartName = "";
/*
* Create the data for the pie chart
*/
DefaultPieDataset dataset = new DefaultPieDataset();
//Fake Data
dataset.setValue("Available", 71);
dataset.setValue("Used", 39);

String title = "Data at:"+ info.getHostname()+"-"+
info.getLocation();
JFreeChart chart = ChartFactory.createPieChart(title, dataset,
true, false, false);
File file = new File("chart.png");
//Save the image
try {

ChartUtilities.saveChartAsPNG(file, chart, 800, 600);

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return file.getName();
}

}


Please help

Sednus

unread,
Jan 28, 2011, 8:05:56 AM1/28/11
to Google Web Toolkit
I debugged for some time and realized, that the actual problem is
that my server side code doesnt find the JFreeChart external libraries
when running. I copied the libraries to /war/WEB-INF/lib but the
behaivor still the same.

Sednus

unread,
Jan 28, 2011, 8:34:43 AM1/28/11
to Google Web Toolkit
It throws the following errors and they are thrown when I try to
create an object of the JFreeChart library:

[ERROR] javax.servlet.ServletContext log: Exception while dispatching
incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method
'public abstract java.lang.String
com.naic.client.UpdatePlotsService.getImagesPaths(java.lang.String)'
threw an unexpected exception: java.lang.NoClassDefFoundError:
javax.swing.event.EventListenerList is a restricted class. Please see
the Google App Engine developer's guide for more details.
at
com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:
378)
...
Caused by: java.lang.NoClassDefFoundError:
javax.swing.event.EventListenerList is a restricted class. Please see
the Google App Engine developer's guide for more details.
at
com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:
51)
...
com.google.gwt.user.client.rpc.StatusCodeException: 500 The call
failed on the server; see server log for details
at
com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:
192)

Thomas Broyer

unread,
Jan 28, 2011, 10:11:48 AM1/28/11
to google-we...@googlegroups.com


On Friday, January 28, 2011 2:34:43 PM UTC+1, Sednus wrote:
javax.swing.event.EventListenerList is a restricted class. Please see
the Google  App Engine developer's guide for more details.

If you're building your app on Google App Engine, maybe you should rather use Google's Chart API instead of JFreeChart: http://code.google.com/apis/chart/ 

Sednus

unread,
Jan 28, 2011, 10:54:54 AM1/28/11
to Google Web Toolkit
Thanks a lot. I'll take a look at it.

Sednus

unread,
Jan 29, 2011, 12:40:48 AM1/29/11
to Google Web Toolkit
I checked it out, but my code is meant for an isolated network,
so I need to be able to generate the images on the server-side.
Apparently I am having trouble adding the JFreeChart libraries
properly. Could someone help with a walk-trough on how to?

Thanks a lot anyway it was very useful.

On Jan 28, 11:11 am, Thomas Broyer <t.bro...@gmail.com> wrote:

Thomas Broyer

unread,
Jan 29, 2011, 4:15:45 AM1/29/11
to google-we...@googlegroups.com
If it's meant for an "isolated network", it means you'll not use Google App Engine to host it, right? in this case, why are you enabling it for your project?
In Eclipse: Project -> Properties -> Google -> App Engine: uncheck
Reply all
Reply to author
Forward
0 new messages