File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Trouble with Headless Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Trouble with Headless" Watch "Trouble with Headless" New topic
Author

Trouble with Headless

Jose Guilherme Vanz
Greenhorn

Joined: Oct 28, 2011
Posts: 5
Hello Everybody!

I use Hudson ( http://hudson-ci.org/ ) for compile, gerenate jars and execute my JUnits tests. Hudson runs in a Tomcat application server, and for execute JUnit test it trigger a Ant's target.
But I'm having problems when my JUnits tests tries open JFrames.
When the test tries open a JFrame using the parameter java.awt.headless=true is throw the following exception:

java.awt.HeadlessException at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159)

If I remove the parameter that I had passed before, the exception thrown is :

java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11GraphicsEnvironment
Could not initialize class sun.awt.X11GraphicsEnvironment

I don't figure out what I'm doing wrong. Someone have a tip?
I was forgetting something, the application is running on Ubuntu Server.

Thank you
[]
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 860

You're trying to run a GUI application in a non-GUI environment.

You should demarcate your business logic from the GUI layer and test that.

As for gui testing, that's more of a selenium type thing, but not sure if it can test awt stuff.

WP
Jose Guilherme Vanz
Greenhorn

Joined: Oct 28, 2011
Posts: 5
William P O'Sullivan wrote:You're trying to run a GUI application in a non-GUI environment.

You should demarcate your business logic from the GUI layer and test that.

As for gui testing, that's more of a selenium type thing, but not sure if it can test awt stuff.

WP


Hi, William
My business logic is not on GUI layer, I'm testing only my GUI layer. ;)

Thanks for tip!
[]'s
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trouble with Headless
 
Similar Threads
JNDI problem
Journal Article - Introduction to Code Coverage
NamingException
JUnit 4 and @RunAs annotation
URL Connection