PDA

View Full Version : problem launching jfreereport from eclipse



patmac
06-09-2003, 06:51 PM
Hi,

I am working on an eclipse plugin and would like to incorporate jfreereport because it looks so coool! 8)

So I added all the necessary jars and copied the HelloWorld example in my project and put this line:
HelloWorld app = new HelloWorld();
in an eventlistener.

The problem is that Eclipse hung when this line from HelloWorld is run:
JFreeReport report = new JFreeReport();

There is nothing in the log file but I know that it happens at this line (from the debugger windows). Any ideas?

HelloWorld runs ok as a Java application called from eclipse. I am on MacOSX and use Eclipse 2.1.1 build june 6th, 2003.
I use JVM 1.4.1 for Ecliipse and the workbench that is used to launch my plugin.

Taqua
06-09-2003, 08:08 PM
Hi,

do you have a printer driver installed? The JDK sometimes hangs if there is no printer driver when a default PageFormat object is created.

Have more fun,
said Thomas

patmac
06-09-2003, 09:03 PM
Thanks for this first answer but this is not the cause. Remember, if I run as an application Helloworld, I get the expected result. And the demo works ok.

And I have a printer driver installed.

Any other possible solution?

patmac
06-10-2003, 08:35 PM
Hi agin,

I have tried all sorts of different configurations. Changing to Eclipse 3.0 M1 from 2.1.1. Using JVM 1.3.1 and 1.4.1, calling the creation of the object HelloWorld from different places. Nothing works.
:cry:

it seems to lock when trying to get the color awt.Color. I know that there was a bug a few years ago with this with Java 1.3.1. But as already said, running the sample as a Java app works perfectly. So the bug is between Eclipse and this library. Is-it because this does not use SWT :?: I think this might be the reason, but how to correct the problem? I found nothing really helpfull in the Eclipse newsgroup.

Has somebody succeeded to make jfreereport a useful tool in Eclipse?

Thanks for "any" :? reply!!!

Taqua
06-11-2003, 02:04 PM
Hi,

the e-tools project of sourceforge (http://jeez.sourceforge.net) develop a eclipse plugin for JFreeReport, so I guess they can run it from there.

Does the demo hang if it is run from within eclipse (using the HelloWorld as entry class)?

Have more fun,
said Thomas

patmac
06-11-2003, 03:57 PM
The demo does not run on Mac as it is. There are hard coded Windows ways of doing business and I would have to do a lot of work, I guess, to see it. I looked at the project and did not find exactly how they launch reports. I would have to study it a bit more.

I have got an answer from the eclipse.platform newgroup and I am suggested to check the classloader this way (ex for jasperreport):
------
ClassLoader cl=Thread.currentThread().getContextClassLoader();

Thread.currentThread().setContextClassLoader(AviXEclipseTestPlugin.getInstan
ce().getClass().getClassLoader());

try{
// do some jasperreports stuff
}catch(Throwable ex){
// handle errors
}finally{
Thread.currentThread().setContextClassLoader(cl);
}

If you do any interface stuff, using the JasperViewer somehow, be sure to
wrap it in a runnable which you pass to Display.(a)syncExec() method.
-------
So I will try this method and get you back. Thanks.

Taqua
06-11-2003, 04:12 PM
Hi,

what does not run? We try to support every platform, but due to the lack of Macs we are unable to test the stuff :)

If there is incompatible stuff coded in our library or the demos I will be thankfull for every hint on how to make it better...

What are these Windows ways (as I'm running linux here :))? This could be a hint for making JFreeReport more suitable for Mac users (as said: I'm totally unfamiliar with that platform) ...

Any hint is welcome...

Have more fun,
said Thomas

patmac
06-12-2003, 12:22 AM
jeez... Well, I could not open a model - there was an error message I do not remember. So I imported the source in Eclipse and noticed many errors because there were references to the SWT of Windows. I modified them to make it compatible with Mac, tried to recompile and then the build would not work. Here is an extract of it:

<?xml version="1.0" encoding="UTF-8"?>
<project name="org.sf.jeez.suite" default="init" basedir=".">

<property name="bootclasspath" value=""/>
<property name="ws" value="win32"/>
<property name="os" value="win32"/>
<property name="arch" value="x86"/>
<property name="javacFailOnError" value="false"/>
<property name="javacDebugInfo" value="on"/>
<property name="javacVerbose" value="true"/>

<!--
-->
<property name="jeez.home" value="E:\projects\jeez"/>
<property name="deploy.home" value="${jeez.home}/dist"/>
<property name="libs.home" value="${deploy.home}/libs"/>
<property name="forrest.home" value="D:\tools\forrest"/>
<property name="project.home" value="${basedir}"/>

I tried to adapt but then I had some other more urgent issues to deal with.

patmac
06-12-2003, 11:28 PM
:(

I tried both solution suggested by the guy on the Eclipse forum but none worked. It must be something either with the Mac or with my installation (a conflict between loaded classes needed by my plugin?).

I could do a really simple plugin just to test this last hypothesis...

As said, there is no error message and nothing in the log. Looking at the debug window, the bug happens at the line new jFreeReport() of the HelloWorld example. then is succession the following lines or object are called:
- JFreeReport. <init>() line not avail.
- ReportHeader (Band). <init>() line not avail
- ReportHeader (Element). <init>() line not avail
- ElementStyleSheet. <init>() line not avail
- ElementStyleSheet.class$(String) line not avail
- Class.forName(String) line: 140
- Class.forName0(Strng,boolean.ClassLoader) line not available
- Color. <init>() line: 250
- Toolkit.<init>() line: 1422
- Toolkit.loadLibrairies() line: 1401
- AccessController.doPrivileged(PrivilegedAction) line: not available
- LoadLibraryAction.run() line : 50
- System.loadLibrary(String) line 832
- Runtime.loadLibrary0(Class,String) line 788
- ClassLoader.loadLibrary(Class,String,boolean) line 1389
- ClassLoader.loadLibrary0(Class,File) line 1473
- ClassLoader$NativeLibrary.load(String)line not avail.
ouf!

I am using JRE 1.4.1 on MacOSX 10.2.6. Eclipse 3.0 M1 (same problem with version 2.1.1).

So if somebody has an :idea: let me know!

patmac
06-14-2003, 05:47 PM
Hi,

I probably found the origin of the bug: the loading of the native librairies for the Color class.

I tested this in a working class:

....
import java.awt.Color;
....

Color noir = Color.black; // this causes a bug when trying to load the Color librairy

So it is probably a bug between SWT of Macosx and java.awt.Color. I await the answer of the developers of SWT.

patmac
06-19-2003, 09:53 PM
I was right...

Using SWT (so Eclipse) makes no warranty that any tool written with AWT or Swing will work. On some platform, it might, but not on others...

So this is the problem: on Macosx, SWT does not allow using any AWT call. When a class does so, the JVM freezes... This is what happens when Jreport is launched from within Eclipse.

My question: would it be possible to modifiy jfreereport so that all references to awt is removed? I did not go into the code of JFreeReport, but is the GUI seperated from the logic? If so, we could create classes for SWT while keeping the brain of JFreeReport.

Taqua
06-20-2003, 02:32 AM
Hi,

thats impossible, as we are using Graphics2D to print our reports, use AWT fonts to layout the report and use AWT Colors and Strokes to define the style of the report.

All of our work is based on the AWT...

Have you tried to replace the AWT? If eclipse crashes with your AWT implementation, then try a different one, for instance the PJA. You would loose the ability to display frames (and will have to create your own preview components for the SWT), but all other functionality should be up and running ...

Have more fun,
said Thomas

patmac
06-20-2003, 08:41 AM
Thanks for this answer.

I looked at the pja lib and there are references to the java.awt class everywhere. So I doubt it could work - it will be facing the same issue.

Another option would be to launch the report tool as an external app. This would work but this is a last resort solution.

Thanks for you involvement in the open-source initiative, Taqua!

Taqua
06-20-2003, 02:35 PM
HI,

the PJA replaces the AWT, it implements its own backend classes. The pure java classes should not be the cause of all the trouble, most likely the SWT does not like one of the native AWT peers ... and this problem would never occur in PJA as it is 100% java ...

Have more fun,
said Thomas