title: Servlet giving error java.lang.NoClassDefFoundError
body: <p>I am using the following code in a servlet of my app</p>
  
  <p><code>java.awt.Image awtImg = java.awt.Toolkit.getDefaultToolkit().createImage(str1);</code></p>
  
  <p>When I run the application and call the servlet I get the following error</p>
  
  <pre><code>java.lang.NoClassDefFoundError: Could not initialize class sun.awt.X11.XToolkit
  java.lang.Class.forName0(Native Method)
  java.lang.Class.forName(Class.java:169)
  java.awt.Toolkit$2.run(Toolkit.java:834)
  java.security.AccessController.doPrivileged(Native Method)
  java.awt.Toolkit.getDefaultToolkit(Toolkit.java:826)
  noticeandreports.pdf.appendFiles.PdfFunctionsClass.addSealSpace(PdfFunctionsClass.java:198)
  OJ.NoticesandReports.generate_151_OJNotice.execute(generate_151_OJNotice.java:768)
  org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
  org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
  org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
  org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  </code></pre>
  
  <p>I have hosted the app on a Linux machine with Java version JDK 1.6.20..</p>
  
  <p>What might be causing the issue...</p>
  
  <p><code>noticeandreports.pdf.appendFiles.PdfFunctionsClass</code> is the class where the code is written and <code>OJ.NoticesandReports.generate_151_OJNotice</code> is the servlet that calls the method inside the above class...</p>