Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » Architecture & Framework
» Spring Framework
打印话题 寄给朋友 订阅主题 |
作者 | 请帮忙看看这个简单的spring程序是什么问题? |
benbon
发贴: 14 积分: 0 |
于 2006-03-17 14:57
错误如下: exception javax.servlet.ServletException: Error instantiating servlet class net.testSpring.servlet.MainServlet org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118) org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) java.lang.Thread.run(Thread.java:595) root cause java.lang.NoClassDefFoundError: org/springframework/context/support/AbstractApplicationContext java.lang.Class.getDeclaredConstructors0(Native Method) java.lang.Class.privateGetDeclaredConstructors(Class.java:2328) java.lang.Class.getConstructor0(Class.java:2640) java.lang.Class.newInstance0(Class.java:321) java.lang.Class.newInstance(Class.java:303) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118) org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705) org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577) org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683) java.lang.Thread.run(Thread.java:595) note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs. 程序: package net.testSpring.sys; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class AppContext { private static AppContext instance; private AbstractApplicationContext appContext; public synchronized static AppContext getInstance() { if (instance == null) { instance = new AppContext(); } return instance; } private AppContext() { try{ this.appContext = new ClassPathXmlApplicationContext( "/applicationContext.xml"); }catch(Exception e){ System.out.println(e.getMessage()); } if(appContext!=null) System.out.println("get AppContext success!"); } public AbstractApplicationContext getAppContext() { return appContext; } } ----------------------------------------------------------------------------------------- package net.testSpring.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.testSpring.beans.TestBean; import net.testSpring.sys.AppContext; import org.springframework.context.ApplicationContext; public class MainServlet extends HttpServlet { /** * */ private static final long serialVersionUID = 1L; /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @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 doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } /** * The doPost method of the servlet. <br> * * 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=gb2312"); try { ApplicationContext ac = AppContext.getInstance().getAppContext(); TestBean tb = (TestBean) ac.getBean("test"); String vs_text = tb.getContent(); System.out.println(vs_text); } catch (Exception e) { e.printStackTrace(); } System.out.println("hello"); } } ---------------------------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="test" class="net.testSpring.beans.TestBean"> <property name="vs_test"><value>Hello World</value></property> </bean> </beans> ------------------------------------------------------------ applicationContext.xml放在web-inf/classes下面 请求JAVA学习方向????? |
话题树型展开 |
人气 | 标题 | 作者 | 字数 | 发贴时间 |
22302 | 请帮忙看看这个简单的spring程序是什么问题? | benbon | 5093 | 2006-03-17 14:57 |
19613 | Re:请帮忙看看这个简单的spring程序是什么问题? | zcjl | 177 | 2006-03-17 16:00 |
19408 | Re:请帮忙看看这个简单的spring程序是什么问题? | benbon | 28 | 2006-03-17 16:51 |
19399 | Re:请帮忙看看这个简单的spring程序是什么问题? | floater | 288 | 2006-03-17 22:52 |
19724 | Re:请帮忙看看这个简单的spring程序是什么问题? | bluepure | 114 | 2006-03-18 18:48 |
20506 | Re:请帮忙看看这个简单的spring程序是什么问题? | rockykid | 24 | 2006-05-21 15:23 |
已读帖子 新的帖子 被删除的帖子 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |