问题描述
我在这个MayServlet.java内写下:importjava.awt.Color;importjava.io.IOException;importjavax.servlet.ServletException;importjavax.servlet.ServletOutputStream;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importcom.mapinfo.mapj.MapJ;importcom.mapinfo.mapxtreme.client.MapXtremeImageRenderer;importcom.mapinfo.util.*;importcom.mapinfo.xmlprot.mxtj.ImageRequestComposer;//importcom.myservlets.DoubleRect;//importcom.mapinfo.unit.LinearUnitimportcom.mapinfo.dp.*;importcom.mapinfo.dp.util.*;importcom.mapinfo.graphics.*;importcom.mapinfo.mapj.Layer;importcom.mapinfo.mapj.Layers;importcom.mapinfo.mapxtreme.client.MapXtremeDataProviderRef;importcom.mapinfo.mapdefcontainer.MapDefContainer;publicclassMyServletextendsHttpServlet{privatestaticfinallongserialVersionUID=1L;publicMyServlet(){super();}//输出图片的格式privatestaticStringmimeType="image/gif";//定义mdf文件的位置privatestaticStringm_mapPath="E:\MapXtremeJava471\MapXtreme-4.7.1\examples\server\data\PCOS-02220523\guizhou.mdf";//定义mapxtremeservlet的URLprivatestaticStringm_mxtURL="http://localhost:8080/mapxtreme471/servlet/mapxtreme";//实现httpService的doget()方法protectedvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{//设置contentType的类型response.setContentType(mimeType);//设置返回响应的输出流ServletOutputStreamsos=response.getOutputStream();//创建mapJ对象MapJm_mapj=newMapJ();//加载地图m_mapj.loadMapDefinition(m_mapPath);//设置地图大小m_mapj.setDeviceBounds(newDoubleRect(0,0,800,600));try{//设置图像请求器(包装mapJ、图片的色位、底色、contentType类型)ImageRequestComposerirc=ImageRequestComposer.create(m_mapj,ImageRequestComposer.MAX_COLORS_TRUECOLOR,Color.white,mimeType);//创建图片渲染器MapXtremeImageRendererrenderer=newMapXtremeImageRenderer(m_mxtURL);//用渲染器渲染请求器renderer.render(irc);//渲染器输出图片流到输出流,客户端显示之renderer.toStream(sos);//释放渲染器renderer.dispose();//刷新输出流sos.flush();//关闭输出流sos.close();}catch(Exceptione){System.out.println("Error");e.printStackTrace();}}protectedvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{this.doGet(request,response);}}出现错误::::java.lang.ClassNotFoundException:com.mapinfo.mapj.MapJatorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)atorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)atcom.servlets.MapServlet.doGet(MapServlet.java:38)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:617)atjavax.servlet.http.HttpServlet.service(HttpServlet.java:717)atorg.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)atorg.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)atorg.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)atorg.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)atorg.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)atorg.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)atorg.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)atorg.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)atorg.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)atorg.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)atorg.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)atjava.lang.Thread.run(UnknownSource)包已经都插进去了,有时候建同样的项目好的,有时候就这样出错,哎
解决方案
解决方案二:
楼主现在解决了吧,可以交流会吗?