HTTP-500错误,求解决
在TOMCAT下运行JSP页面时出现的问题,请教
HTTP Status 500 -
--------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Could not initialize class sun.font.FontManager
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.image_jsp._jspService(image_jsp.java:96)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NoClassDefFoundError: Could not initialize class sun.font.FontManager
sun.java2d.SunGraphicsEnvironment.addDirFonts(Unknown Source)
sun.java2d.SunGraphicsEnvironment.registerFontsInDir(Unknown Source)
sun.java2d.SunGraphicsEnvironment.access$200(Unknown Source)
sun.java2d.SunGraphicsEnvironment$2.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
sun.java2d.SunGraphicsEnvironment. <init> (Unknown Source)
sun.awt.Win32GraphicsEnvironment. <init> (Unknown Source)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(Unknown Source)
java.awt.image.BufferedImage.createGraphics(Unknown Source)
java.awt.image.BufferedImage.getGraphics(Unknown Source)
org.apache.jsp.image_jsp._jspService(image_jsp.java:67)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs.
--------------------------------------------
Apache Tomcat/5.0.30
------------------------------------------------------------
原JSP代码为
<%@ page contentType= "image/jpeg "%>
<%@ page import= "java.awt.*,java.awt.image.*,java.util.*,javax.imageio.* "%>
<%!
Color getRandColor(int fc,int bc){
Random random=new Random();
if(fc> 255) fc=255;
if(bc> 255) bc=255;
int r=fc+random.nextInt(bc-fc);
int g=fc+random.nextInt(bc-fc);
int b=fc+random.nextInt(bc-fc);
return new Color(r,g,b);
}
%>
<%
response.setHeader( "Pragma ", "No-cache ");
response.setHeader( "Cache-Control ", "no-cache ");
response.setDateHeader( "Expirse ",0);
int width=50,height=20;
BufferedImage image=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
Graphics g=image.getGraphics();
Random random=new Random();
g.setColor(getRandColor(200,250));
g.fillRect(0,0,width,height);
g.setFont(new Font( "Times New Roman ",Font.PLAIN,18));
g.setColor(getRandColor(160,200));
for(int i=0;i <50;i++){
int x=random.nextInt(width);
int y=random.nextInt(height);
int xl=random.nextInt(width);
int yl=random.nextInt(height);
g.drawLine(x,y,x+xl,y+yl);
}
String sRand= " ";
for(int i=0;i <4;i++){
String rand=String.valueOf(random.nextInt(10));
sRand+=rand;
g.setColor(new Color(20+random.nextInt(110),20+random.nextInt(110),20+random.nextInt(110)));
g.drawString(rand,11*i+6,16);
}
session.setAttribute( "rand ",sRand);
g.dispose();
ImageIO.write(image, "JPEG ",response.getOutputStream());
%>
请大家帮助解决,谢谢
[解决办法]
运行了,没报错!
[解决办法]
找不类啊,看看路径对了没有
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html