javajspresin

java.awt.Color error


I have this simple Jsp page:

<%@ page language="java" import="java.awt.Color"%> <%
Color background = Color.white;
%>

Which fails with following error:

java.lang.NoClassDefFoundError
    at _text__jsp._jspService(/text.jsp:3)
    at com.caucho.jsp.JavaPage.service(JavaPage.java:75)
    at com.caucho.jsp.Page.subservice(Page.java:506)
    at com.caucho.server.http.FilterChainPage.doFilter(FilterChainPage.java:182)
    at com.caucho.server.http.Invocation.service(Invocation.java:315)
    at com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:135)
    at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:346)
    at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)
    at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
    at java.lang.Thread.run(Thread.java:534)

I'm running it on Resin 2.1.13.

Any idea what's causing this?


Solution

  • Not sure about the issue. I can run your code successfully in my Tomcat. May be this problem is particular to Resin. Or, as said by Dave, may be a headless issue.

    Your best bet is to convert the image in some POJO and then spit that to the browser, or may be save it somewhere on the disk and then link it in your JSP. If problem persists, try running in headless mode, as Dave pointed out.

    Moreover, its important to understand that JSP is a view technology for the web, and must not do that kind of graphics manipulation.