Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

java.awt.HeadlessException

Posted on 2011-10-17
15
Medium Priority
?
1,099 Views
Last Modified: 2012-05-12
Hello !

I was running a webapp on Weblogic 8 (Java 4) wich makes PDF in a awt Headless environnement (No X Server on the Unix machine) with PJA

I migrate it to Weblogic 11G (Java 6). The thing is that the latest PJA version 2.5 wich seems to emulate an X Server doesn't support Java 1.5 nor Java 6 :
I get a
java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.

i tried to add the -Djava.awt.headless=true option at the jvm startup of my weblogic managed server but my pdf is not generated ...

I think that although there's no X server started, X Libs must be present on the machine. It seems not and i can't install it because i have no right on this (because of deployment considerations, the OS are formatted to be as standardized as possible and X libs are not installed on these servers)

Any idea of how to solve the problem ?
0
Comment
Question by:cobol60
  • 7
  • 5
  • 3
15 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 1600 total points
ID: 36979088
Check to ensure that jvarg you tried to set actually DOES get set
0
 
LVL 1

Author Comment

by:cobol60
ID: 36979579
i'm sorry but i don't understand your comment
0
 
LVL 1

Author Comment

by:cobol60
ID: 36979586
The behaviour is not same with or without this parameter ... With the PDF is generated but without graphics.

And without the PDF is not generated. (Blank page)
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 1600 total points
ID: 36979593
>>i tried to add the -Djava.awt.headless=true option at the jvm startup of my weblogic managed server

You need to confirm that you actually succeeded in that
0
 
LVL 1

Author Comment

by:cobol60
ID: 36979612
I Precise that PDF are generated by an old version of Jasper Reports ... Upgrading it to 4.1.2 didn't change the behaviour.

In response to your question, it seems to be because i haven't got the message :
No X11 DISPLAY variable was set, but this program performed an operation which requires it.

Only the java.awt.HeadlessException.

Is it important that X libraries to be present on the server ? Because i think it is not the case.
0
 
LVL 1

Author Comment

by:cobol60
ID: 36979622
I missed a piece of sentence : since i added this option i haven't got the message :
No X11 DISPLAY variable was set, but this program performed an operation which requires it.

Only the java.awt.HeadlessException.

0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 1600 total points
ID: 36979753
Sorry - i'm getting a bit confused now ;) Could you re-summarize?
0
 
LVL 1

Author Comment

by:cobol60
ID: 36980103
The option -Djava.awt.headless=true is taken. it's sure because the behaviour changes with or without this option.

Without this option i get a 0 byte PDF

With, i get a PDF with some content but without graphics (some texts are generated)

I tried to upgrade jasper from 1.2.3 to 4.1.2 but the gap is too much important and my reports bug everytime.

0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 1600 total points
ID: 36980182
Yes, it could be that you're missing some dependencies, leaving you with partial content. Try turning on debug logging for Jasper to find out what's happening
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 400 total points
ID: 36980569
Yes, I feel your pain - I had the same problem - PJA no longer works after 1.5 and I also had to upgrade
and this issue is supposed to be addressed within JDK, but it is somehow really painful,
don't know why - but that is one of a few problems I could not overcome.
It is everywhere written that you should use
System.setProperty("java.awt.headless", "true"); or at the stratup as you mentioned
but  I could not make it work.

The simplest way is to find some constantly working X-Windows host and point display to that.
Like on Tomcat I pointed
setenv CATALINA_OPTS "-DDISPLAY=someXhost.company.com:0.0"
0
 
LVL 1

Author Comment

by:cobol60
ID: 37002221
I did found the solution ... : the soft used a 3rd party library for which i hadn't the source code.

I found the source code and recode the container that was an applet (that's why it needed PJA or X) to a Panel ... and it did the trick ...
0
 
LVL 47

Expert Comment

by:for_yan
ID: 37002307
Or, so with Panel it worked for you? That's great. Indeed, maybe I was tryingbto od it through Jframe, and maybe that is where
sits the problem.
0
 
LVL 1

Author Comment

by:cobol60
ID: 37002495
Yes i did notice that jframe use x
0
 
LVL 47

Expert Comment

by:for_yan
ID: 37002519
Well, thanks, it is good to know.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 37003491
:)
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Convert websphere application server default chained Certificates from 1024 to 2048 keysize or higher size and also you can change signatureAlgorithm . Please make sure Websphere Application Server fixpack 7.0.0.23 or Above. The following steps a…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month13 days, 5 hours left to enroll

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question