Question

I am trying to create a video by combining a set of images available online using Xuggle. I implemented it as a service using JSP and Java. I'm using the tomcat server. When I deploy it in my local server which runs in windows, it works fine. But when i deploy it to the linux server im getting the following error.

org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11.XToolkit
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:500)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

I guess it's the headless problem which occurs in environments without a display. Can someone tell me how to solve this problem ? I found online that PJA toolkit can solve this problem. but how do i use this in linux? if anyone has followed this approach can you please give me step by step instructions on how to use this in linux.

Was it helpful?

Solution

I managed to solve this problem. When no X11 Display is available on a UNIX machine (also called headless environment) or when GDI resources are low on Windows, it is impossible to compute off-screen images with java.awt.Graphics methods under a JDK version < 1.4, even if your program doesn't need to display these images. Typically, this situation happens for servlets returning dynamically generated images like pies, charts or web counters. If your JDK version is <1.4 upgrade it, because in JDK 1.4 onwards this problem is solved. And then you need to enable the headless mode. This is how it is done: If you are in Linux, enter export CATALINA_OPTS="-DJava.awt.headless=true to the /etc/profile file.

Hope this would help someone else who comes across the same problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top