Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Using jasperreport or jfreereport
Using jasperreport or jfreereport [message #70087] Tue, 10 June 2003 21:11 Go to next message
Eclipse UserFriend
Originally posted by: pdrolet.mac.com

Hi,

I am trying to use either one of those library with a plugin. I work on
a MacOSX 10.2.6 and I tried JVM 1.3.1 and 1.4.1. The app simple hung
when trying to instantiate a class from those librariew. There is not
log generated! I have to kill the app eventually.


For Jasperreport, I tried the following:

InputStream reportStream =
this.getClass().getResourceAsStream("Etablissements.xml");

JasperDesign jasperDesign = JasperManager.loadXmlDesign(reportStream);
JasperReport jasperReport= JasperManager.compileReport(jasperDesign);
String[] fields = new String[] { "pkidc", "agence",
"catg","groupe","modfs1","nom_etabl","num_etabl","typelieu "};

HibernateQueryResultDataSource ds = new
HibernateQueryResultDataSource(etabl, fields);

JasperPrint jasperPrint= JasperManager.fillReport(jasperReport,
parameters, ds);

JasperManager.printReportToPdfFile(jasperPrint, "etabl.pdf");

But the code does not go beyond the second line. It freezes there. I
know that it could read the xml file (from studying the debugging
data). It is stuck while trying to load what seems to be
"anonymousElement"...


I can have the samples work ok standalone. So my JVM must be ok.


For jfreereport, I tried the following:
new HelloWorld(); // the example from the distr. of jfreereport

and if freezes too. It seems to be when trying to instantiate or use
java.awt.Color.


But I can run all the samples of jfreereport either from a console or
from Eclipse (as a Java app).


Is-it because those libraries use awt/swing that I am having those
difficulties? I would really like to include one of those tools in my
plugin...


One solution could be to launch separately a class. I tried too but did
not succeed. Here is the code:


IVMInstall vmInstall=null;
IJavaProject myJavaProject = null;
try {
IJavaModel iJVM = JavaCore.create(FmedxPlugin.getWorkspace().getRoot());
myJavaProject = iJVM.getJavaProject("ca.infodata.fmedx");
vmInstall = JavaRuntime.getVMInstall(myJavaProject);
} catch (CoreException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (vmInstall == null) {
vmInstall = JavaRuntime.getDefaultVMInstall();
} else {
System.out.println("vmInstall n'est pas null.");
}
if (vmInstall != null) {
IVMRunner vmRunner = vmInstall.getVMRunner(ILaunchManager.RUN_MODE);
if (vmRunner != null) {
String[] classPath = null;
try {
classPath = JavaRuntime.computeDefaultRuntimeClassPath(myJavaProject);
} catch (CoreException e) { }
if (classPath != null) {
VMRunnerConfiguration vmConfig =
new VMRunnerConfiguration("HelloWorld", classPath);
Launch launch = new Launch(null, ILaunchManager.RUN_MODE, null);
try {
vmRunner.run(vmConfig, launch, null);
} catch (CoreException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
}
}
}

I get the following log:

!SESSION juin 10, 2003 19:54:24.963
--------------------------------------------

java.version=1.4.1_01
java.vendor=Apple Computer, Inc.
BootLoader constants: OS=macosx, ARCH=ppc, WS=carbon, NL=fr_CA
Command-line arguments: -pdelaunch -dev bin -feature
org.eclipse.platform -data /eclipse/runtime-workspace -os macosx -ws
carbon -arch ppc -nl fr_CA -configuration
file:/eclipse/workspace/.metadata/.plugins/org.eclipse.pde.c ore/_eclipse_runtime-workspace/platform.cfg
-install file:/fmedx/

!ENTRY org.eclipse.ui 4 4 juin 10, 2003 19:54:24.965
!MESSAGE Unhandled exception caught in event loop.
!ENTRY org.eclipse.ui 4 0 juin 10, 2003 19:54:24.967
!MESSAGE org/eclipse/debug/core/ILaunch
!STACK 0
java.lang.NoClassDefFoundError: org/eclipse/debug/core/ILaunch
at
ca.infodata.fmedx.editor.ToolBarEditor$4.handleEvent(ToolBar Editor.java:102)


at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :81)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 016)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:2082)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :1795)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1399)
at org.eclipse.ui.internal.Workbench.run(Workbench.java:1382)
at
org.eclipse.core.internal.boot.InternalBootLoader.run(Intern alBootLoader.java:858)


at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)


at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)


at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.core.launcher.Main.basicRun(Main.java:291)
at org.eclipse.core.launcher.Main.run(Main.java:747)
at org.eclipse.core.launcher.Main.main(Main.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)


at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)


at java.lang.reflect.Method.invoke(Method.java:324)
at apple.launcher.LaunchRunner.run(LaunchRunner.java:88)
at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:50)
at
apple.launcher.JavaApplicationLauncher.launch(JavaApplicatio nLauncher.java:52)




It seems that there is a problem with the classpath, but wh? debug/core
in in the platform version of Eclipse (I use this one as the runtime
workbench).


Any ideas? Your help would be very appreciated.

--
Patrice Drolet
Logiciels INFO-DATA inc.
Re: Using jasperreport or jfreereport [message #70542 is a reply to message #70087] Wed, 11 June 2003 04:07 Go to previous messageGo to next message
Eclipse UserFriend
Hi Patrice.

I'm using a similar setup as you are, using JasperReports (have tried
freereports also, but I prefer Jasper). I'm using win32, not sure if that
matters in this case. Works fine anyway.

First of all, JasperReports seems to be using the Thread's context class
loader, so you need to make sure that the right classloader is used by doing
the following:

ClassLoader cl=Thread.currentThread().getContextClassLoader();

Thread.currentThread().setContextClassLoader(AviXEclipseTest Plugin.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.

Good luck, Regards
Emil Einarsson

"Patrice Drolet" <pdrolet@mac.com> skrev i meddelandet
news:Ginko030610211123-0400a40e929659b52ed2b8205b48bbcdd64b@mac.com...
> Hi,
>
> I am trying to use either one of those library with a plugin. I work on
> a MacOSX 10.2.6 and I tried JVM 1.3.1 and 1.4.1. The app simple hung
> when trying to instantiate a class from those librariew. There is not
> log generated! I have to kill the app eventually.
>
>
> For Jasperreport, I tried the following:
>
> InputStream reportStream =
> this.getClass().getResourceAsStream("Etablissements.xml");
>
> JasperDesign jasperDesign = JasperManager.loadXmlDesign(reportStream);
> JasperReport jasperReport= JasperManager.compileReport(jasperDesign);
> String[] fields = new String[] { "pkidc", "agence",
> "catg","groupe","modfs1","nom_etabl","num_etabl","typelieu "};
>
> HibernateQueryResultDataSource ds = new
> HibernateQueryResultDataSource(etabl, fields);
>
> JasperPrint jasperPrint= JasperManager.fillReport(jasperReport,
> parameters, ds);
>
> JasperManager.printReportToPdfFile(jasperPrint, "etabl.pdf");
>
> But the code does not go beyond the second line. It freezes there. I
> know that it could read the xml file (from studying the debugging
> data). It is stuck while trying to load what seems to be
> "anonymousElement"...
>
>
> I can have the samples work ok standalone. So my JVM must be ok.
>
>
> For jfreereport, I tried the following:
> new HelloWorld(); // the example from the distr. of jfreereport
>
> and if freezes too. It seems to be when trying to instantiate or use
> java.awt.Color.
>
>
> But I can run all the samples of jfreereport either from a console or
> from Eclipse (as a Java app).
>
>
> Is-it because those libraries use awt/swing that I am having those
> difficulties? I would really like to include one of those tools in my
> plugin...
>
>
> One solution could be to launch separately a class. I tried too but did
> not succeed. Here is the code:
>
>
> IVMInstall vmInstall=null;
> IJavaProject myJavaProject = null;
> try {
> IJavaModel iJVM = JavaCore.create(FmedxPlugin.getWorkspace().getRoot());
> myJavaProject = iJVM.getJavaProject("ca.infodata.fmedx");
> vmInstall = JavaRuntime.getVMInstall(myJavaProject);
> } catch (CoreException e1) {
> // TODO Auto-generated catch block
> e1.printStackTrace();
> }
> if (vmInstall == null) {
> vmInstall = JavaRuntime.getDefaultVMInstall();
> } else {
> System.out.println("vmInstall n'est pas null.");
> }
> if (vmInstall != null) {
> IVMRunner vmRunner = vmInstall.getVMRunner(ILaunchManager.RUN_MODE);
> if (vmRunner != null) {
> String[] classPath = null;
> try {
> classPath = JavaRuntime.computeDefaultRuntimeClassPath(myJavaProject);
> } catch (CoreException e) { }
> if (classPath != null) {
> VMRunnerConfiguration vmConfig =
> new VMRunnerConfiguration("HelloWorld", classPath);
> Launch launch = new Launch(null, ILaunchManager.RUN_MODE, null);
> try {
> vmRunner.run(vmConfig, launch, null);
> } catch (CoreException e2) {
> // TODO Auto-generated catch block
> e2.printStackTrace();
> }
> }
> }
> }
>
> I get the following log:
>
> !SESSION juin 10, 2003 19:54:24.963
> --------------------------------------------
>
> java.version=1.4.1_01
> java.vendor=Apple Computer, Inc.
> BootLoader constants: OS=macosx, ARCH=ppc, WS=carbon, NL=fr_CA
> Command-line arguments: -pdelaunch -dev bin -feature
> org.eclipse.platform -data /eclipse/runtime-workspace -os macosx -ws
> carbon -arch ppc -nl fr_CA -configuration
>
file:/eclipse/workspace/.metadata/.plugins/org.eclipse.pde.c ore/_eclipse_run
time-workspace/platform.cfg
> -install file:/fmedx/
>
> !ENTRY org.eclipse.ui 4 4 juin 10, 2003 19:54:24.965
> !MESSAGE Unhandled exception caught in event loop.
> !ENTRY org.eclipse.ui 4 0 juin 10, 2003 19:54:24.967
> !MESSAGE org/eclipse/debug/core/ILaunch
> !STACK 0
> java.lang.NoClassDefFoundError: org/eclipse/debug/core/ILaunch
> at
>
ca.infodata.fmedx.editor.ToolBarEditor$4.handleEvent(ToolBar Editor.java:102)
>
>
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :81)
> at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1 016)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:2082)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :1795)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1399)
> at org.eclipse.ui.internal.Workbench.run(Workbench.java:1382)
> at
>
org.eclipse.core.internal.boot.InternalBootLoader.run(Intern alBootLoader.jav
a:858)
>
>
> at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39
)
>
>
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl
..java:25)
>
>
> at java.lang.reflect.Method.invoke(Method.java:324)
> at org.eclipse.core.launcher.Main.basicRun(Main.java:291)
> at org.eclipse.core.launcher.Main.run(Main.java:747)
> at org.eclipse.core.launcher.Main.main(Main.java:583)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39
)
>
>
> at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl
..java:25)
>
>
> at java.lang.reflect.Method.invoke(Method.java:324)
> at apple.launcher.LaunchRunner.run(LaunchRunner.java:88)
> at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:50)
> at
>
apple.launcher.JavaApplicationLauncher.launch(JavaApplicatio nLauncher.java:5
2)
>
>
>
>
> It seems that there is a problem with the classpath, but wh? debug/core
> in in the platform version of Eclipse (I use this one as the runtime
> workbench).
>
>
> Any ideas? Your help would be very appreciated.
>
> --
> Patrice Drolet
> Logiciels INFO-DATA inc.
>
Re: Using jasperreport or jfreereport [message #73068 is a reply to message #70542] Fri, 13 June 2003 00:12 Go to previous message
Eclipse UserFriend
Originally posted by: pdrolet.mac.com

> I'm using a similar setup as you are, using JasperReports (have tried
> freereports also, but I prefer Jasper). I'm using win32, not sure if
> that matters in this case. Works fine anyway.
>
> First of all, JasperReports seems to be using the Thread's context
> class loader, so you need to make sure that the right classloader is
> used by doing the following:
>
> ClassLoader cl=Thread.currentThread().getContextClassLoader();
>
> Thread.currentThread().setContextClassLoader(AviXEclipseTest Plugin.get
> Instan 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.
>

Thanks for your suggestions.

I tried those solutions but did not get any report. I tried both jasper
and jFree. 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...


With jFreereport, here is what I get when the plugin tries to
instantiate JFreeReport (of a simple HelloWorld example).


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.

I am using JRE 1.4.1 on MacOSX 10.2.6. Eclipse 3.0 M1 (same problem
with version 2.1.1). I use hibernate 2.0 with JDBC to access a Firebird
database.



Patrice
Previous Topic:debugging servlets, classfile line numbers
Next Topic:[ANN] new synchronize view
Goto Forum:
  


Current Time: Mon May 12 03:06:50 EDT 2025

Powered by FUDForum. Page generated in 0.29399 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top