Re: Simple JavaBeans applications not working (newbie question)
--- Wendy Smoak [EMAIL PROTECTED] wrote: Before you continue, you might shut down Tomcat and delete the 'work' directory associated with this webapp to make sure you're starting fresh. (I assume such a thing exists in version 5, I'm still using 4.1.) The work directory still exists in v5.5; it wasn't necessary to delete it in this case (having figured out from the first reply that the misnamed package was the problem). Caching *did* occur to me as a potential problem, however. It's notable that for some pages, the error doesn't always appear, or often different errors appear on successive refreshes. I suspect that *that* is a caching issue (and also that it is common enough to have been explained several times elsewhere, so this isn't a question, just an observation). - MS ___ Yahoo! Messenger - want a free and easy way to contact your friends online? http://uk.messenger.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Simple JavaBeans applications not working (newbie question); FIXED!
--- Anoop kumar V [EMAIL PROTECTED] wrote: Everything works perfectly fine in your jsp and bean except that the package mentioned in your bean (Beany.java) file seems incorrect Aaawwrrgh! (Bangs head against wall several dozen times) Thank you. That was such a stupid mistake; I should have spotted it. If there is any excuse it is that I'd had what *looked* like the same problem with two earlier attempts; the package name was not the problem there. Because I thought this was the same problem, I probably didn't consider the obvious answer again. Really, though; this is a great example of trying too hard, and missing what was staring me in the face. Also you do not need to place a web.xml in the WEB-INF folder - I mean its optional since tomcat5.X That's okay; it seems to work *without* the web.xml file, but not with it(!) I'll have a look at that sometime. Another thing I noticed that you have placed your bean as a jar in the WEB-INF/lib directory Yes; I was trying lots of things out to get it to work; I originally did as you described. Thanks for the help, - MS ___ How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Simple JavaBeans applications not working (newbie question)
On Sat, May 07, 2005 at 01:39:50PM -0400, Anoop kumar V wrote: : Another thing I noticed that you have placed your bean as a jar in the : WEB-INF/lib directory - while this works perfectly the practice is to put : custom class files in the WEB-INF/classes directory as just .class files : under their respective folders (as per package declaration).. What practice would this be? Some would argue that placing your classes in JAR files permits better organization/grouping than a flat space under WEB-INF classes. Per the spec, the only difference between WEB-INF/classes and WEB-INF/lib is that the former is searched first. -QM -- software -- http://www.brandxdev.net/ tech news -- http://www.RoarNetworX.com/ code scan -- http://www.JxRef.org/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Simple JavaBeans applications not working (newbie question)
From: Michael Strorm [EMAIL PROTECTED] skeleton/WEB-INF/lib/subapp/Beany.class Jar files go in WEB-INF/lib. Classes go under WEB-INF/classes in a directory structure matching the package name. What package statement does Beany.java contain? org.apache.jasper.JasperException: /subapp/skeleton.jsp(2,0) The value for the useBean class attribute subclass.Beany is invalid. Shouldn't that be 'subapp.Beany' and not 'subclass.Beany'? That's why I asked, above, about the package statement. Before you continue, you might shut down Tomcat and delete the 'work' directory associated with this webapp to make sure you're starting fresh. (I assume such a thing exists in version 5, I'm still using 4.1.) You're close, just change one thing at a time until you figure it out. -- Wendy Smoak - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Simple JavaBeans applications not working (newbie question)
Hi, First off, let me apologise for the level of detail in this message; if possible, I'd have made it shorter. Anyway, I'm trying to learn J2EE; Tomcat seemed like a good choice to learn the underlying technology, rather than a particular JSP/Servlet container's deployment tool. I can get 'plain' JSP pages working fine. Unfortunately, I'm having major problems developing my own Javabeans applications for Tomcat; they all fail as shown below. The demos that come with Tomcat work fine (although I can't get the demo at http://jakarta.apache.org/tomcat/tomcat-5.5-doc/appdev/sample to work; However- that's another story) I understand that I should simply be able to drop the directory structure containing my program into $CATALINA_HOME/webapps, restart Tomcat (I'm using 5.5.7) and have it work. Its contents (root:root ownership, Tomcat running as root) is:- skeleton skeleton/subapp skeleton/subapp/skeleton.jsp skeleton/WEB-INF skeleton/WEB-INF/classes skeleton/WEB-INF/lib skeleton/WEB-INF/lib/subapp skeleton/WEB-INF/lib/subapp/Beany.class skeleton/WEB-INF/lib/subapp/Beany.java skeleton/WEB-INF/lib/subapp.jar skeleton/WEB-INF/web.xml Contents of files listed at end of message. Here's what happens when I try to run it:- (1) When I try to access http://localhost:8080/skeleton/subapp/skeleton.jsp with the setup as above, I get HTTP Status 404 - Servlet org.apache.jsp.subapp.skeleton_jsp is not available message Servlet org.apache.jsp.subapp.skeleton_jsp is not available (2) If I move skeleton/WEB-INF/lib/subapp to skeleton/WEB-INF/classes/subapp, I get HTTP STATUS 500 - EXCEPTION REPORT The server encountered an internal error () that prevented it from fulfilling this request. EXCEPTION javax.servlet.ServletException: Wrapper cannot find servlet class org.apache.jsp.subapp.skeleton_jsp or a class it depends on org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105) [... SNIP ...] java.lang.Thread.run(Thread.java:595) ROOT CAUSE java.lang.ClassNotFoundException: org.apache.jsp.subapp.skeleton_jsp org.apache.catalina.loader.WebappClassLoader.loadClass (WebappClassLoader.java:1332) [... SNIP ...] java.lang.Thread.run(Thread.java:595) (3) If I remove the deployment descriptor altogether, I get:- HTTP STATUS 500 - EXCEPTION REPORT The server encountered an internal error () that prevented it from fulfilling this request. EXCEPTION org.apache.jasper.JasperException: /subapp/skeleton.jsp(2,0) The value for the useBean class attribute subclass.Beany is invalid. org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39) [... SNIP ...] javax.servlet.http.HttpServlet.service(HttpServlet.java:802) In short, it fails; in three noticeably different ways, granted; but it still fails. What on EARTH am I doing wrong or missing out?! I'd really appreciate some feedback on this. Thank you in advance. Here are the files:- ** SKELETON.JSP: html jsp:useBean id=beanId class=subclass.Beany scope=session / headtitleFoo Bar/title/head body h1Foo Bar/h1 Duzzy wuzzy was a duck; ducky fuzzy duck a wuzz blah blah some more yak. /body /html --- ** WEB.XML ?xml version=1.0 encoding=ISO-8859-1? !-- Copyright 2004 The Apache [SNIP] -- web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4 display-nameDisplay Name/display-name description Display Description /description !-- JSPC servlet mappings start -- servlet servlet-nameorg.apache.jsp.subapp.skeleton_jsp/servlet-name servlet-classorg.apache.jsp.subapp.skeleton_jsp/servlet-class /servlet servlet-mapping servlet-nameorg.apache.jsp.subapp.skeleton_jsp/servlet-name url-pattern/subapp/skeleton.jsp/url-pattern /servlet-mapping !-- JSPC servlet mappings end -- --- --- ** BEANY.JAVA package subapp; public class Beany { private int first; /** Public no-args constructor */ public Beany() { first = 404; } public int getFirst() { return first; } public void setFirst(int first) { this.first = first; } public String stringy = Original Value;
Re: Simple JavaBeans applications not working (newbie question)
Michael, Everything works perfectly fine in your jsp and bean except that the package mentioned in your bean (Beany.java) file seems incorrect: It is: ** BEANY.JAVA package subapp; It should be: ** BEANY.JAVA package subclass; Or else an alternative is to change the folder in which the bean is to subapp from subclass to match the package name... Also you do not need to place a web.xml in the WEB-INF folder - I mean its optional since tomcat5.X (maybe earlier - someone please correct if I am wrong).. and if web.xml is not present the defauly web.xml settings will be applied. Hope that helps, Anoop On 5/7/05, Michael Strorm [EMAIL PROTECTED] wrote: Hi, First off, let me apologise for the level of detail in this message; if possible, I'd have made it shorter. Anyway, I'm trying to learn J2EE; Tomcat seemed like a good choice to learn the underlying technology, rather than a particular JSP/Servlet container's deployment tool. I can get 'plain' JSP pages working fine. Unfortunately, I'm having major problems developing my own Javabeans applications for Tomcat; they all fail as shown below. The demos that come with Tomcat work fine (although I can't get the demo at http://jakarta.apache.org/tomcat/tomcat-5.5-doc/appdev/sample to work; However- that's another story) I understand that I should simply be able to drop the directory structure containing my program into $CATALINA_HOME/webapps, restart Tomcat (I'm using 5.5.7) and have it work. Its contents (root:root ownership, Tomcat running as root) is:- skeleton skeleton/subapp skeleton/subapp/skeleton.jsp skeleton/WEB-INF skeleton/WEB-INF/classes skeleton/WEB-INF/lib skeleton/WEB-INF/lib/subapp skeleton/WEB-INF/lib/subapp/Beany.class skeleton/WEB-INF/lib/subapp/Beany.java skeleton/WEB-INF/lib/subapp.jar skeleton/WEB-INF/web.xml Contents of files listed at end of message. Here's what happens when I try to run it:- (1) When I try to access http://localhost:8080/skeleton/subapp/skeleton.jsp with the setup as above, I get HTTP Status 404 - Servlet org.apache.jsp.subapp.skeleton_jsp is not available message Servlet org.apache.jsp.subapp.skeleton_jsp is not available (2) If I move skeleton/WEB-INF/lib/subapp to skeleton/WEB-INF/classes/subapp, I get HTTP STATUS 500 - EXCEPTION REPORT The server encountered an internal error () that prevented it from fulfilling this request. EXCEPTION javax.servlet.ServletException: Wrapper cannot find servlet class org.apache.jsp.subapp.skeleton_jsp or a class it depends on org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105) [... SNIP ...] java.lang.Thread.run(Thread.java:595) ROOT CAUSE java.lang.ClassNotFoundException: org.apache.jsp.subapp.skeleton_jsp org.apache.catalina.loader.WebappClassLoader.loadClass (WebappClassLoader.java:1332) [... SNIP ...] java.lang.Thread.run(Thread.java:595) (3) If I remove the deployment descriptor altogether, I get:- HTTP STATUS 500 - EXCEPTION REPORT The server encountered an internal error () that prevented it from fulfilling this request. EXCEPTION org.apache.jasper.JasperException: /subapp/skeleton.jsp(2,0) The value for the useBean class attribute subclass.Beany is invalid. org.apache.jasper.compiler.DefaultErrorHandler.jspError( DefaultErrorHandler.java:39) [... SNIP ...] javax.servlet.http.HttpServlet.service(HttpServlet.java:802) In short, it fails; in three noticeably different ways, granted; but it still fails. What on EARTH am I doing wrong or missing out?! I'd really appreciate some feedback on this. Thank you in advance. Here are the files:- ** SKELETON.JSP: html jsp:useBean id=beanId class=subclass.Beany scope=session / headtitleFoo Bar/title/head body h1Foo Bar/h1 Duzzy wuzzy was a duck; ducky fuzzy duck a wuzz blah blah some more yak. /body /html --- ** WEB.XML ?xml version=1.0 encoding=ISO-8859-1? !-- Copyright 2004 The Apache [SNIP] -- web-app xmlns=http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd; version=2.4 display-nameDisplay Name/display-name description Display Description /description !-- JSPC servlet mappings start -- servlet servlet-nameorg.apache.jsp.subapp.skeleton_jsp/servlet-name servlet-classorg.apache.jsp.subapp.skeleton_jsp/servlet-class /servlet servlet-mapping servlet-nameorg.apache.jsp.subapp.skeleton_jsp/servlet-name url-pattern/subapp/skeleton.jsp/url-pattern /servlet-mapping !-- JSPC servlet mappings end -- --- --- ** BEANY.JAVA package
Re: Simple JavaBeans applications not working (newbie question)
Another thing I noticed that you have placed your bean as a jar in the WEB-INF/lib directory - while this works perfectly the practice is to put custom class files in the WEB-INF/classes directory as just .class files under their respective folders (as per package declaration).. IMO the lib folders should only contain jar files that represent generic functionality as opposed to customised project specific class files in the classes folder. regards, Anoop On 5/7/05, Anoop kumar V [EMAIL PROTECTED] wrote: Michael, Everything works perfectly fine in your jsp and bean except that the package mentioned in your bean (Beany.java) file seems incorrect: It is: ** BEANY.JAVA package subapp; It should be: ** BEANY.JAVA package subclass; Or else an alternative is to change the folder in which the bean is to subapp from subclass to match the package name... Also you do not need to place a web.xml in the WEB-INF folder - I mean its optional since tomcat5.X (maybe earlier - someone please correct if I am wrong).. and if web.xml is not present the defauly web.xml settings will be applied. Hope that helps, Anoop On 5/7/05, Michael Strorm [EMAIL PROTECTED] wrote: Hi, First off, let me apologise for the level of detail in this message; if possible, I'd have made it shorter. Anyway, I'm trying to learn J2EE; Tomcat seemed like a good choice to learn the underlying technology, rather than a particular JSP/Servlet container's deployment tool. I can get 'plain' JSP pages working fine. Unfortunately, I'm having major problems developing my own Javabeans applications for Tomcat; they all fail as shown below. The demos that come with Tomcat work fine (although I can't get the demo at http://jakarta.apache.org/tomcat/tomcat-5.5-doc/appdev/sample to work; However- that's another story) I understand that I should simply be able to drop the directory structure containing my program into $CATALINA_HOME/webapps, restart Tomcat (I'm using 5.5.7) and have it work. Its contents (root:root ownership, Tomcat running as root) is:- skeleton skeleton/subapp skeleton/subapp/skeleton.jsp skeleton/WEB-INF skeleton/WEB-INF/classes skeleton/WEB-INF/lib skeleton/WEB-INF/lib/subapp skeleton/WEB-INF/lib/subapp/Beany.class skeleton/WEB-INF/lib/subapp/Beany.java skeleton/WEB-INF/lib/subapp.jar skeleton/WEB-INF/web.xml Contents of files listed at end of message. Here's what happens when I try to run it:- (1) When I try to access http://localhost:8080/skeleton/subapp/skeleton.jsp with the setup as above, I get HTTP Status 404 - Servlet org.apache.jsp.subapp.skeleton_jsp is not available message Servlet org.apache.jsp.subapp.skeleton_jsp is not available (2) If I move skeleton/WEB-INF/lib/subapp to skeleton/WEB-INF/classes/subapp, I get HTTP STATUS 500 - EXCEPTION REPORT The server encountered an internal error () that prevented it from fulfilling this request. EXCEPTION javax.servlet.ServletException: Wrapper cannot find servlet class org.apache.jsp.subapp.skeleton_jsp or a class it depends on org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105) [... SNIP ...] java.lang.Thread.run(Thread.java:595) ROOT CAUSE java.lang.ClassNotFoundException: org.apache.jsp.subapp.skeleton_jsp org.apache.catalina.loader.WebappClassLoader.loadClass (WebappClassLoader.java:1332) [... SNIP ...] java.lang.Thread.run(Thread.java:595) (3) If I remove the deployment descriptor altogether, I get:- HTTP STATUS 500 - EXCEPTION REPORT The server encountered an internal error () that prevented it from fulfilling this request. EXCEPTION org.apache.jasper.JasperException: /subapp/skeleton.jsp(2,0) The value for the useBean class attribute subclass.Beany is invalid. org.apache.jasper.compiler.DefaultErrorHandler.jspError( DefaultErrorHandler.java:39) [... SNIP ...] javax.servlet.http.HttpServlet.service(HttpServlet.java:802) In short, it fails; in three noticeably different ways, granted; but it still fails. What on EARTH am I doing wrong or missing out?! I'd really appreciate some feedback on this. Thank you in advance. Here are the files:- ** SKELETON.JSP: html jsp:useBean id=beanId class=subclass.Beany scope=session / headtitleFoo Bar/title/head body h1Foo Bar/h1 Duzzy wuzzy was a duck; ducky fuzzy duck a wuzz blah blah some more yak. /body /html --- ** WEB.XML ?xml version=1.0 encoding=ISO-8859-1? !-- Copyright 2004 The Apache [SNIP] -- web-app xmlns= http://java.sun.com/xml/ns/j2ee; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation=