|
From: <php...@li...> - 2006-03-13 16:43:31
|
Just to say I digg into this problem all day and still find no solution.
What I do not understand is why a thread does not inherit the classpath=20
from the creating thread ?
or maybe the thread is not the problem (if so, please correct me because=20
I am really new to Java threads and javac called from a .java)
regards,
chris
php...@li... wrote:
> Hi,
>
> I am using PHP-Java-bridge like this :
> Report.java : is a java file containning a wrapper to JasperReports=20
> notaly the following imports and method :
> import net.sf.jasperreports.engine.*;
> [...]
> public void setSubReport(String name, String compressed_xml) throws=20
> JRException {
> InputStream stream =3D this.readCompressedXml(compressed_xml=
);
> //compile into a JasperReport object
> JasperReport jasperReport =3D=20
> JasperCompileManager.compileReport(stream);
> //add to subreports map
> _subreports.put(name, jasperReport);
> }
>
> Now in php, I use Report.php :
> $p =3D $GLOBALS['CONF']['SYS']['INCLUDE_PATH']['libraries'].'java/lib/'=
;
> $javapath =3D=20
> $p.'commons-beanutils-1.5.jar;'.$p.'commons-collections-2.1.jar;'.
> =20
> $p.'commons-digester-1.7.jar;'.$p.'commons-logging-1.0.2.jar;'.
> $p.'commons-logging-api-1.0.2.jar;'.$p.'itext-1.3.1.jar;'.
> $p.'jasperreports-1.2.0.jar;'.$p.'jcommon-1.0.0.jar;'.
> =20
> $p.'jfreechart-1.0.1.jar;'.$p.'poi-2.0.jar;'.$p.'xalan.jar;'.$p.'../rep=
ort/Report.jar';=20
>
> java_set_library_path($javapath);
> try {
> $r =3D new Java('Report');
> $r->setSubReport($name, $row['sr_compressed_xml']);
> } catch (JavaException $ex) {
> $trace =3D new java("java.io.ByteArrayOutputStream");
> $ex->printStackTrace(new java("java.io.PrintStream", $trace));
> die("<pre>java stack trace: $trace</pre>");
> }
>
> So now, this print the following error (snippet) :
> Package not found : net.sf.jaspereports.engine line XX in=20
> master12345.java
> (Note: the line JasperCompileManager.compileReport(stream); is the=20
> bottom of the stacktrace).
>
> This means that my Java class perfectly imports the package (because=20
> it can call the JasperCompileManager.compile method) but the java=20
> classes generated on the fly by Jasper (here named master12345) cannot=20
> use the jars set in the javapath.
>
> I digg into the source code and see that a new thread is opened for=20
> the compilation : maybe this is the problem (related to the class=20
> loader in php-java-bridge I think ?).
> Plus, putting the jars into jdk/jre/lib/ext works, so this prove that=20
> it should be a problem with the class loader.
> Note that doing this (jars in lib/ext) is not really an option for a=20
> production environment...
>
> I hope you can help me to find a workaround for my situation;
>
> best regards and keep on the good work,
> chris
>
--=20
=20
_________________________________________________________________________=
______________
Tennaxia, www.tennaxia.com,
Pilotez vos obligations environnementales
_________________________________________________________________________=
______________
Si=E8ge social :
6, rue L=E9onard de Vinci - 53001 Laval Cedex -=20
T=E9l : 02 43 49 75 50 - Fax : 02 43 49 75 77
Agence Paris :
19, rue r=E9aumur - 75003 Paris -=20
T=E9l : 01 42 77 04 19 - Fax : 08 25 19 19 61
Agence Lyon :
Parc du Chater - 63 rue de la garenne - 69340 FRANCHEVILLE -=20
T=E9l : 04 72 39 98 14 - Fax : 04 72 39 93 85
Les informations contenues dans ce message envoy=E9es par TENNAXIA sont c=
onfidentielles et
sont =E9tablies =E0 l'attention exclusive de leurs destinataires. L'acc=E8=
s =E0 ce message
par toute autre personne n'est pas autoris=E9. Si vous n'=EAtes pas le de=
stinataire de ce
message, merci de le d=E9truire et d'en avertir l'exp=E9diteur : toute al=
t=E9ration, copie,
distribution ou toute action prise ou omise sont interdites et peuvent =EA=
tre ill=E9gales.
The information in this message sent by TENNAXIA is confidential and may =
be legally
privileged. It is intended solely for the addressee(s). Access to this me=
ssage by anyone
else is unauthorized. If you are not the intended recipient, please delet=
e it and notify
the sender : any disclosure, copying, distribution or any action taken or=
omitted to be
taken in reliance on it, is prohibited and may be unlawful.
|