myeclipse的一个错误javax.servlet.ServletException

some3one 2011-01-06 04:55:02
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: Servlet.init() for servlet jsp threw exception
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.NoClassDefFoundError
org.apache.jasper.compiler.JspRuntimeContext.<init>(JspRuntimeContext.java:104)
org.apache.jasper.servlet.JspServlet.init(JspServlet.java:77)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.

================================================
以前也遇到过,后来不知道怎么解决的,现在又出现了,找了好久都没能解决啊,求解啊
...全文
891 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
TzSword 2011-01-07
  • 打赏
  • 举报
回复
我在网上搜的解决方案是更换JRE版本。然后我在myeclipse中的project菜单中的property中,更改JDK compliance分别为1.3,1.4,5.0都不行。在myeclipse中的windows菜单中的preference中修改jre为5.0也不行。用myeclipse自带的JRE也不行。



最终结果是Tomcat下面设置的JDK和应用程序使用的JDK版本不一致所致!!!

解决办法:
1.打开MyEclipse
2.Window
3.Preferences
4.选择Java节点
5.Installed JREs
6.可以看到当前使用的JVM是什么版本,路径在哪里,现在我们要改正和Tomcat一样的虚拟机.
6.Edit
7.JRE home directory
8.Browse 找到:C:\Sun\SDK\jdk\jre(找到你的安装目录)
9.ok
搞定了.!

分析:
比如,你項目中的是JRE5.0但compile是JRE6.0則出現上述錯誤。或者版本不一致!


答案来自http://www.javaeye.com/topic/576365
some3one 2011-01-07
  • 打赏
  • 举报
回复
我是在用structs框架做web项目,因为在部署时有5楼的那个问题,在显示jsp页面时就报了1楼的错误,java新手求教啊
some3one 2011-01-07
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 tzsword 的回复:]
引用 1 楼 tzsword 的回复:
这个错误表示 你缺少servlet-api.jar

这个包在Myeclipse下面有 Tomcat下面也有
[/Quote]

这个包不需要手动添加的吧,默认有的吧,我tomcat启动好了,但启动后部署项目貌似有个问题,会不会是那个的原因

2011-1-7 8:39:50 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\Program Files\Java\jdk1.5.0_06\bin;D:\apache-tomcat-5.5.20\bin
2011-1-7 8:39:50 org.apache.coyote.http11.Http11BaseProtocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2011-1-7 8:39:50 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1843 ms
2011-1-7 8:39:50 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2011-1-7 8:39:50 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/5.5.20
2011-1-7 8:39:50 org.apache.catalina.core.StandardHost start
信息: XML validation disabled
2011-1-7 8:39:52 org.apache.catalina.core.ApplicationContext log
信息: org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRule: Target string: News / Redirect URL: http://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterRule: Target param name: paramName / Target param value: paramValue / Redirect URL: http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL: http://jakarta.apache.org]]
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
2011-1-7 8:40:00 org.apache.commons.modeler.Registry registerComponent
严重: Null component Catalina:type=JspMonitor,name=jsp,WebModule=//localhost/dangdang,J2EEApplication=none,J2EEServer=none
2011-1-7 8:40:01 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2011-1-7 8:40:01 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2011-1-7 8:40:02 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2011-1-7 8:40:02 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2011-1-7 8:40:02 org.apache.coyote.http11.Http11BaseProtocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2011-1-7 8:40:03 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2011-1-7 8:40:03 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/140 config=null
2011-1-7 8:40:03 org.apache.catalina.storeconfig.StoreLoader load
信息: Find registry server-registry.xml at classpath resource
2011-1-7 8:40:03 org.apache.catalina.startup.Catalina start
信息: Server startup in 13110 ms
2011-1-7 8:40:22 org.apache.catalina.startup.HostConfig checkResources
信息: Reloading context [/dangdang]
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
2011-1-7 8:40:27 org.apache.commons.modeler.Registry registerComponent
严重: Null component Catalina:type=JspMonitor,name=jsp,WebModule=//localhost/dangdang,J2EEApplication=none,J2EEServer=none
TzSword 2011-01-07
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 tzsword 的回复:]
这个错误表示 你缺少servlet-api.jar
[/Quote]
这个包在Myeclipse下面有 Tomcat下面也有
Jlins 2011-01-06
  • 打赏
  • 举报
回复
因为你没有引入tomcat服务器 所以缺少了 servlet-api.jar
happyfmy 2011-01-06
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 tzsword 的回复:]
这个错误表示 你缺少servlet-api.jar
[/Quote]
+1
TzSword 2011-01-06
  • 打赏
  • 举报
回复
这个错误表示 你缺少servlet-api.jar
import java.io.IOException; import java.io.PrintWriter; import java.util.*; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * @author xiaoq * */ public class AddVoteServlet extends HttpServlet { /** * Constructor of the object. */ public AddVoteServlet() { super(); } /** * Destruction of the servlet.
*/ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doPost method of the servlet.
* * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=GBK"); PrintWriter out = response.getWriter(); out.println(""); out.println(" add vote"); out.println(" "); String title=request.getParameter("title"); String stile=request.getParameter("stile"); String startTime=request.getParameter("startyear")+"-"+request.getParameter("startmonth")+"-"+ request.getParameter("startday"); String endTime=request.getParameter("endyear")+"-"+request.getParameter("endmonth")+"-"+ request.getParameter("endday"); String active=request.getParameter("active"); int newActive=Integer.parseInt(active); /**test out.println(title+""+stile+""+endTime+""+startTime+""+newActive+""); */ Questions question=new Questions(); question.setTitle(title); question.setStyle(stile); question.setStrStartime(startTime); question.setStrEndtime(endTime); question.setActive(newActive); int n=Integer.parseInt(request.getParameter("n")); Collection items=new ArrayList();

51,397

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧