Home pageFind It!Contact PJAPJA documentation

PJA

 PJA Toolkit forum

This forum is dedicated to PJA Toolkit.
You may read freely the messages it contents. If you want to write a message or answer to a subject, subscribe to it first.

Subjects Recent messages Login Subscribe

Messages of subject PJAImage, pjaf and 1.4.1 jvm

mauricio

Location : Curitiba, Brazil
Member since : Jun 22, 2003
Messages : 2
 Jun 22, 2003 at 1:07 AM
I succeeded to produce a gif image out of a servlet using the simple approach "new PJAImage()", setting properties as required and then drawing only lines on its graphics. I deployed this to an Oracle 9IAs application server, without having to change the JVM parameters.

Now I'm trying to draw some text. I usually test the code before deploying within a second application server of the same type, but with a 1.4.1 JVM instead.

The error message comes out like that:

java.awt.AWTError: No default font : at least one .pjaf font must be loaded.
at com.eteks.awt.PJAGraphics.checkFontLoading(PJAGraphics.java:345)
at com.eteks.awt.PJAGraphics.drawString(PJAGraphics.java:1847)
at com.iservport.stat.GraphBase.drawGraph(GraphBase.java:84)
at com.iservport.stat.GraphBase.drawGraph(GraphBase.java:18)
at com.iservport.stat.XBarGraph.doGet(XBarGraph.java:32)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:721)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
at java.lang.Thread.run(Thread.java:536)

As it worked fine before I added text, I suppose that using directly the PJAImage is enough to deal with the 1.4.1 problem. I ran the PJAFontCapture utility but don't know where to put the resulting Dialog.pjaf file.

What am I doing wrong? Can I really keep my 1.4.1 jvm environment using this approach?

Thanks in advance for any help.

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Jun 22, 2003 at 12:10 PM
> Can I really keep my 1.4.1 jvm environment using this approach?

.pjaf fonts file must be stored either in user directory ("user.dir" system property) or in a directory added to the path of "java.awt.fonts" system property. If you want to, you may change this directory by program :
System.setProperty ("java.awt.fonts", "/home/user/fonts/");

Have a look at the getFontsPath method of com.eteks.awt.PJAGraphicsManager to get more information.
---
Manu (moderator/modérateur)

mauricio

Location : Curitiba, Brazil
Member since : Jun 22, 2003
Messages : 2
 Jun 22, 2003 at 3:59 PM
Thanks, the following code worked just fine:

System.setProperty("java.awt.fonts", "/home/libra/lib");
System.out.println(System.getProperty("java.awt.fonts")); // to see if its ok
g.setFont("Dialog", Font.PLAIN, 9); // I was missing this...
g.drawString("test",50,50);

Thanks for the promptness to reply!

dharm0us

Location : india
Member since : Nov 19, 2003
Messages : 4
 Nov 19, 2003 at 2:39 PM
I am facing the same problem, here is the complete message :
this message comes when I use this code :
(name of the servlet is -> HelloWorldGraphics)

g.setFont(new Font("Dialog",Font.PLAIN,9));
g.drawString("Hello Worldiiiiiiiiiiiiiiiiiiiiiii!", 10, 50);

******************************************************************************
java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
at java.awt.Font.initializeFont(Font.java:303)
at java.awt.Font.<init>(Font.java:339)
at HelloWorldGraphics.doGet(HelloWorldGraphics.java:44)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:499)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at sun.servlet.http.HttpServerHandler.sendResponse(HttpServerHandler.java:165)
at sun.servlet.http.HttpServerHandler.handleConnection(HttpServerHandler.java:121)
at sun.servlet.http.HttpServerHandler.run(HttpServerHandler.java:90)
at java.lang.Thread.run(Thread.java:536)

*******************************************************************************
in case I use directly :
g.drawString("Hello Worldiiiiiiiiiiiiiiiiiiiiiii!", 10, 50);
following message comes :

*************************************************************************
java.awt.AWTError: No default font : at least one .pjaf font must be loaded.
at com.eteks.awt.PJAGraphics.checkFontLoading(PJAGraphics.java:345)
at com.eteks.awt.PJAGraphics.drawString(PJAGraphics.java:1847)
at HelloWorldGraphics.doGet(HelloWorldGraphics.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:499)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
at sun.servlet.http.HttpServerHandler.sendResponse(HttpServerHandler.java:165)
at sun.servlet.http.HttpServerHandler.handleConnection(HttpServerHandler.java:121)
at sun.servlet.http.HttpServerHandler.run(HttpServerHandler.java:90)
at java.lang.Thread.run(Thread.java:536)
*************************************************************************

taking a cue from replies to this posting i tried to run PJAFontCapture.sh
and I got following error :
**************************************************
/PJAFontCapture.sh
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:59)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:58)
at java.awt.Window.<init>(Window.java:186)
at java.awt.Frame.<init>(Frame.java:315)
at java.awt.Frame.<init>(Frame.java:262)
at com.eteks.tools.fontcapture.PJAFontCapture.showCaptureFontDialog(PJAFontCapture.java:176)
at com.eteks.tools.fontcapture.PJAFontCapture.main(PJAFontCapture.java:106)
************************************************************************

please help me out, either by telling what is wrong with the PJAFontCapture.sh
file which looks like :
----
java -classpath $CLASSPATH:../lib/pja.jar:../lib/pjatools.jar com.eteks.tools.fontcapture.PJAFontCapture
----
or by any other means...
regards,
dharm.


> I succeeded to produce a gif image out of a servlet using the simple approach "new PJAImage()", setting properties as required and then drawing only lines on its graphics. I deployed this to an Oracle 9IAs application server, without having to change the JVM parameters.
>
> Now I'm trying to draw some text. I usually test the code before deploying within a second application server of the same type, but with a 1.4.1 JVM instead.
>
> The error message comes out like that:
>
> java.awt.AWTError: No default font : at least one .pjaf font must be loaded.
> at com.eteks.awt.PJAGraphics.checkFontLoading(PJAGraphics.java:345)
> at com.eteks.awt.PJAGraphics.drawString(PJAGraphics.java:1847)
> at com.iservport.stat.GraphBase.drawGraph(GraphBase.java:84)
> at com.iservport.stat.GraphBase.drawGraph(GraphBase.java:18)
> at com.iservport.stat.XBarGraph.doGet(XBarGraph.java:32)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:721)
> at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
> at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
> at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
> at com.evermind[Oracle9iAS (9.0.3.0.0) Containers for J2EE].server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
> at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
> at java.lang.Thread.run(Thread.java:536)
>
> As it worked fine before I added text, I suppose that using directly the PJAImage is enough to deal with the 1.4.1 problem. I ran the PJAFontCapture utility but don't know where to put the resulting Dialog.pjaf file.
>
> What am I doing wrong? Can I really keep my 1.4.1 jvm environment using this approach?
>
> Thanks in advance for any help.
---
--
tolani.

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Nov 19, 2003 at 4:42 PM
You have to run PJAFontCapture on a UNIX machine with a DISPLAY or on Windows, capture the fonts you want and then transfer the .pjaf file(s) to your server in the directory specified by the "java.awt.fonts" System property.
---
Manu (moderator/modérateur)

dharm0us

Location : india
Member since : Nov 19, 2003
Messages : 4
 Nov 19, 2003 at 4:55 PM

I am running it on a LINUX machine that has a DISPLAY, but am not the root.
is that a problem?

> You have to run PJAFontCapture on a UNIX machine with a DISPLAY or on Windows, capture the fonts you want and then transfer the .pjaf file(s) to your server in the directory specified by the "java.awt.fonts" System property.
---
--
tolani.

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Nov 20, 2003 at 12:18 AM
> I am running it on a LINUX machine that has a DISPLAY, but am not the root.
> is that a problem?

I never heard of such problems. Try PJAFontCapture on a Windows machine, I'm sure it will work...

---
Manu (moderator/modérateur)

dharm0us

Location : india
Member since : Nov 19, 2003
Messages : 4
 Nov 22, 2003 at 8:12 AM
> > I am running it on a LINUX machine that has a DISPLAY, but am not the root.
> > is that a problem?
>
> I never heard of such problems. Try PJAFontCapture on a Windows machine, I'm sure it will work...

Leaving this problem apart for a while, I have another problem now. I am running the servletrunner on a LINUX machine(as told earlier), and accessing the servlets through both windows and linux machines. On windows, I am accessing it through IE and Opera and output is perfectly fine, but when I access it through mozilla on a linux machine, it asks me to choose a program to open it with and no program could actually open it. On Netscape it shows some garbage as the output. I guess some MIME header settings are required. Can you tell me which?
---
--
tolani.

Manu

Location : Paris / France
Member since : Apr 29, 2003
Messages : 394
 Nov 22, 2003 at 10:56 AM
> I guess some MIME header settings are required. Can you tell me which?

Using the setContentType method of the HttpServletResponse object to set MIME type header should be enough :
For an image at GIF format : response.setContentType ("image/gif");
For an image at JPEG format : response.setContentType ("image/jpeg");
---
Manu (moderator/modérateur)


Home pageFind It!ContactTop

© Copyrights 1997-2014 eTeks - All rights reserved

PJAPJA documentation