| Author |
Can't get my simple bean to work!
|
K DeLucia
Ranch Hand
Joined: Apr 11, 2008
Posts: 68
|
|
I created a java bean based on a tutorial. After a little bit of trouble with the classpath, getting files in the right place, etc, I finally got it working. Whoo hoo! Now, I'm working on a second java bean and I cannot get it to work. I'm at the point where I've stripped it down so it's basically identical to the tuturial with just a few changes. When it runs I get a NoSuchMethodError. I've checked, rechecked and re-rechecked my case and my names many many many times. I've rebooted. I've restarted Tomcat and my browser multiple times. What am I missing? This is my Test.html: This is my Test.jsp: This is my java bean code: The UserData.class file is in C:\apache-tomcat-6.0.10\webapps\EME\WEB-INF\classes\user The WebPageData.class file is in C:\apache-tomcat-6.0.10\webapps\EME\WEB-INF\classes\com\penntraffic\emeApp Both paths are included in my CLASSPATH environment variable. This is the error text that I get when I click on the 'Search' button in Test.html (submit button): type Exception report message The server encountered an internal error () that prevented it from fulfilling this request. org.apache.jasper.JasperException: An exception occurred processing JSP page /Test.jsp at line 12 9: </head> 10: <body> 11: <%= user.getUsername() %> 12: <%= webPageData.getHhnum() %> 13: <table> 14: <tr><td> 15: <select name=LookupType> Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:408) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause javax.servlet.ServletException: java.lang.NoSuchMethodError: com.penntraffic.emeApp.WebPageData.getHhnum()Ljava/lang/String; org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:855) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:784) org.apache.jsp.Test_jsp._jspService(Test_jsp.java:111) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause java.lang.NoSuchMethodError: com.penntraffic.emeApp.WebPageData.getHhnum()Ljava/lang/String; org.apache.jsp.Test_jsp._jspService(Test_jsp.java:87) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) If I remove the line that attempts to get the value of hhnum from the bean, everything works fine and I get the username value from the first bean. So the user bean is working, but there's obviously something wrong with my second bean (webPageData). I've also tried using <jsp:getProperty name="webPageData" property="hhnum"/> rather than <%= webPageData.getHhnum() %>. I thought they would return identical results, but instead I get the below errors: type Exception report description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: Cannot find any information on property 'hhnum' in a bean of type 'com.penntraffic.emeApp.WebPageData' org.apache.jasper.runtime.JspRuntimeLibrary.getReadMethod(JspRuntimeLibrary.java:839) org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1045) org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:1101) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336) org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386) org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2392) org.apache.jasper.compiler.Node$Root.accept(Node.java:489) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336) org.apache.jasper.compiler.Generator.generate(Generator.java:3394) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:210) org.apache.jasper.compiler.Compiler.compile(Compiler.java:306) org.apache.jasper.compiler.Compiler.compile(Compiler.java:286) org.apache.jasper.compiler.Compiler.compile(Compiler.java:273) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) This shouldn't be this hard!! Any help would be greatly appreciated!
|
 |
Deepa Neela
Greenhorn
Joined: May 01, 2008
Posts: 6
|
|
|
I got it working, and I did not get any nosuchmethod error.
|
 |
K DeLucia
Ranch Hand
Joined: Apr 11, 2008
Posts: 68
|
|
Any ideas on why I would be getting that error? Some configuration setting I missed somewhere? I'm using Tomcat. I've tried everything and I'm really at a loss.
|
 |
Deepa Neela
Greenhorn
Joined: May 01, 2008
Posts: 6
|
|
Inside the tomcat directory, tomcat>work>Catalina>localhost delete (localhost) folder and shutdown the tomcat,then start it again and try running your application. This might help sometimes
|
 |
 |
|
|
subject: Can't get my simple bean to work!
|
|
|