当前位置: 技术问答>java相关
为什么找不到bean.
来源: 互联网 发布时间:2015-01-07
本文导语: 我的路径: TOMCAT-- |-bean |-conf |-doc |-lib |-logs |-src |-webapps-- |-ROOT--(网站根目录) |-index.jsp ...
我的路径:
TOMCAT--
|-bean
|-conf
|-doc
|-lib
|-logs
|-src
|-webapps--
|-ROOT--(网站根目录)
|-index.jsp
|-docs
|-include
|-META-INF
|-WEB-INF--
|-classes--
|-StringBean.java
|-StringBean.class
其中:
----------index.jsp内容
A New indexpage for examples
Initial value(getProperty):
Initial value(JSP expression):
after setting
-------------StringBean.java内容
public class StringBean{
public String message="This is the First.";
public String getMessage(){
return(message);
}
public void setMessage(String message) {
this.message=message;
}
}
-----------报错
Error: 500
Location: /index.jsp
Internal Servlet Error:
javax.servlet.ServletException: StringBean (wrong name: stringb/StringBean)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:399)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
Root cause:
java.lang.NoClassDefFoundError: StringBean (wrong name: stringb/StringBean)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.java:446)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:136)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:181)
at org.apache.jasper.compiler.GetPropertyGenerator.generate(GetPropertyGenerator.java:99)
at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.generate(JspParseEventListener.java:773)
at org.apache.jasper.compiler.JspParseEventListener.generateAll(JspParseEventListener.java:220)
at org.apache.jasper.compiler.JspParseEventListener.endPageProcessing(JspParseEventListener.java:175)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:183)
at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:462)
at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:433)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:152)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:164)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
TOMCAT--
|-bean
|-conf
|-doc
|-lib
|-logs
|-src
|-webapps--
|-ROOT--(网站根目录)
|-index.jsp
|-docs
|-include
|-META-INF
|-WEB-INF--
|-classes--
|-StringBean.java
|-StringBean.class
其中:
----------index.jsp内容
A New indexpage for examples
Initial value(getProperty):
Initial value(JSP expression):
after setting
-------------StringBean.java内容
public class StringBean{
public String message="This is the First.";
public String getMessage(){
return(message);
}
public void setMessage(String message) {
this.message=message;
}
}
-----------报错
Error: 500
Location: /index.jsp
Internal Servlet Error:
javax.servlet.ServletException: StringBean (wrong name: stringb/StringBean)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:399)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
Root cause:
java.lang.NoClassDefFoundError: StringBean (wrong name: stringb/StringBean)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.java:446)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:136)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:181)
at org.apache.jasper.compiler.GetPropertyGenerator.generate(GetPropertyGenerator.java:99)
at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.generate(JspParseEventListener.java:773)
at org.apache.jasper.compiler.JspParseEventListener.generateAll(JspParseEventListener.java:220)
at org.apache.jasper.compiler.JspParseEventListener.endPageProcessing(JspParseEventListener.java:175)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:183)
at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:462)
at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:433)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:152)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:164)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
|
^^^^^^^^^^^
检查这一行,应该是sring1而不是stringB1吧!
另外根据exception stack看,你可能为你的StringBean定义了package name, 这样的话StringBean.class应该被置于 /WEB-INF/classes//StringBean