RE: Instantiating Beans on Tomcat

2001-04-11 Thread Jim Cheesman

At 02:01 AM 4/11/2001, you wrote:
Hmm...then I'm not sure what's going on...so is there a package statement in
InfoBean?


In my experience if the bean is not in a package (i.e. not in the top-level 
package) the bean won't work.


As for a setting in tomcat, I don't think you have to set anything to get a
bean to instantiate. I wonder if it has anything to do with Jann mentioned.
I've always put my jsp's in /webapps/mycontext and my beans in
/webapps/mycontext/WEB-INF/classes/package_path and not had any problems
with instantiation.

I've tried both and not had any problems, either.


Also, check your case on the jsp directive. I noticed you've got
jsp:useBean.../, and if you copied/pasted that into your original message,
then you've got that part correct. However, in one I was trying to do, I
thought I had the case correct, but I actually had jsp:usebean/ and
that was why I couldn't get it to instantiate.


That's familiar! Spent a whole afternoon tracking that one down ;( Couldn't 
tomcat throw an error/exception instead of simply accepting this tag?




--

   *   Jim Cheesman   *
 Trabajo: [EMAIL PROTECTED] - (34)(91) 724 9200 x 2360
   Personal: [EMAIL PROTECTED] (34) 606 770 244
  Practice safe eating -- always use condiments.
















RE: Instantiating Beans on Tomcat

2001-04-11 Thread Mark Johnson

Have you tried to use the build script, and build.xml? This will prepare
your webapps directory properly, put the class files in the correct
(expected) place, and you don't need to screw around with the CLASSPATH.
Makes life simpler: after the preparation outlined below, you just
execute "# ./build" from your app development directory after making any
changes. Craig McC., bless his heart, described this in some doc that
comes with Tomcat (I seem to recall).

Eg,
0. # export TOMCAT_HOME=/path_to_tomcat
1. # cd /home/brandon
2. # mkdir test
3. # cd test
4. # mkdir src lib etc web
5. # mkdir src/mypackage
6. # cp InfoBean.java src/mypackage/.
7. # cp build .
8. # cp build.xml .
9. now edit the appropriate lines in build.xml to read:
project name="test" default="compile" basedir="."
property name="app.name" value="test" /
property name="deploy.home" value="${tomcat.home}/webapps/${app.name}"
/
10. now edit your jsp file:
jsp:useBean id="sessionBean" scope="session" class="mypackage.InfoBean"
/
11. # ./build
12. # cd $TOMCAT_HOME/bin
13. # ./startup.sh







Re: Instantiating Beans on Tomcat

2001-04-10 Thread Hunter Hillegas

I was getting those but it was because my bean didn't have a constructor
that took no args but it looks like yours does...

Not sure...

Hunter

 From: "Brandon Cruz" [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 Date: Tue, 10 Apr 2001 17:54:24 -0500
 To: [EMAIL PROTECTED]
 Subject: Instantiating Beans on Tomcat
 
 I am trying to instantiate a very simple bean on Tomcat in a JSP using the
 directive...
 
 jsp:useBean id="sessionBean" scope="session" class="InfoBean" /
 
 Everytime I try to run it, I get the following exception...
 
 javax.servlet.ServletException:  Cannot create bean of class InfoBean




RE: Instantiating Beans on Tomcat

2001-04-10 Thread Brandon Cruz

Yeah, there must be something I'm missing, maybe there's some setting in
tomcat which allows me to use beans or something, but I can't find where
that would be.

Brandon

-Original Message-
From: Hunter Hillegas [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 6:00 PM
To: Tomcat User List
Subject: Re: Instantiating Beans on Tomcat


I was getting those but it was because my bean didn't have a constructor
that took no args but it looks like yours does...

Not sure...

Hunter

 From: "Brandon Cruz" [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 Date: Tue, 10 Apr 2001 17:54:24 -0500
 To: [EMAIL PROTECTED]
 Subject: Instantiating Beans on Tomcat

 I am trying to instantiate a very simple bean on Tomcat in a JSP using the
 directive...

 jsp:useBean id="sessionBean" scope="session" class="InfoBean" /

 Everytime I try to run it, I get the following exception...

 javax.servlet.ServletException:  Cannot create bean of class InfoBean





RE: Instantiating Beans on Tomcat

2001-04-10 Thread Jann VanOver

Two questions:
1. Where did you put your compiled bean?
2. Did you try putting SOMETHING in the constructor -- maybe
System.out.println("I'm here"); or something like that


-Original Message-
From: Brandon Cruz [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 3:54 PM
To: [EMAIL PROTECTED]
Subject: Instantiating Beans on Tomcat


I am trying to instantiate a very simple bean on Tomcat in a JSP using the
directive...

jsp:useBean id="sessionBean" scope="session" class="InfoBean" /

Everytime I try to run it, I get the following exception...

javax.servlet.ServletException:  Cannot create bean of class InfoBean

Any idea why this is happening, my java code doesn't have anything in it
yet, I just want to test it so that the bean will work, here is what I have
in the java in case I have that wrong...



public class InfoBean {
  private String sample = "Sample";

  public InfoBean() {
  }//end constructor


  public String getSample() {
return sample;
  }
  public void setSample(String newSample) {
sample = newSample;
  }
}

Any ideas on what I'm doing wrong, could this be due to some session
settings in Tomcat?

Thanks!

Brandon



RE: Instantiating Beans on Tomcat

2001-04-10 Thread Brandon Cruz

I have my beans in the tomcat_home/classes directory, this is definately in
the classpath, because I can instantiate the class by using

InfoBean test = new InfoBean();

I also have several other classes in there.  Yes, I have put things to
output something in the constructor, doesn't work though for some reason.  I
am very confused by it.

Brandon

-Original Message-
From: Jann VanOver [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 6:33 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Instantiating Beans on Tomcat


Two questions:
1. Where did you put your compiled bean?
2. Did you try putting SOMETHING in the constructor -- maybe
System.out.println("I'm here"); or something like that


-Original Message-
From: Brandon Cruz [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 3:54 PM
To: [EMAIL PROTECTED]
Subject: Instantiating Beans on Tomcat


I am trying to instantiate a very simple bean on Tomcat in a JSP using the
directive...

jsp:useBean id="sessionBean" scope="session" class="InfoBean" /

Everytime I try to run it, I get the following exception...

javax.servlet.ServletException:  Cannot create bean of class InfoBean

Any idea why this is happening, my java code doesn't have anything in it
yet, I just want to test it so that the bean will work, here is what I have
in the java in case I have that wrong...



public class InfoBean {
  private String sample = "Sample";

  public InfoBean() {
  }//end constructor


  public String getSample() {
return sample;
  }
  public void setSample(String newSample) {
sample = newSample;
  }
}

Any ideas on what I'm doing wrong, could this be due to some session
settings in Tomcat?

Thanks!

Brandon




RE: Instantiating Beans on Tomcat

2001-04-10 Thread Jann VanOver

I put my beans into tomcat_home/webapps/myContext/WEB-INF/classes and have
no problem.  Have you tried that?

-Original Message-
From: Brandon Cruz [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 4:39 PM
To: [EMAIL PROTECTED]
Subject: RE: Instantiating Beans on Tomcat


I have my beans in the tomcat_home/classes directory, this is definately in
the classpath, because I can instantiate the class by using

InfoBean test = new InfoBean();

I also have several other classes in there.  Yes, I have put things to
output something in the constructor, doesn't work though for some reason.  I
am very confused by it.

Brandon

-Original Message-
From: Jann VanOver [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 6:33 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Instantiating Beans on Tomcat


Two questions:
1. Where did you put your compiled bean?
2. Did you try putting SOMETHING in the constructor -- maybe
System.out.println("I'm here"); or something like that


-Original Message-
From: Brandon Cruz [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 3:54 PM
To: [EMAIL PROTECTED]
Subject: Instantiating Beans on Tomcat


I am trying to instantiate a very simple bean on Tomcat in a JSP using the
directive...

jsp:useBean id="sessionBean" scope="session" class="InfoBean" /

Everytime I try to run it, I get the following exception...

javax.servlet.ServletException:  Cannot create bean of class InfoBean

Any idea why this is happening, my java code doesn't have anything in it
yet, I just want to test it so that the bean will work, here is what I have
in the java in case I have that wrong...



public class InfoBean {
  private String sample = "Sample";

  public InfoBean() {
  }//end constructor


  public String getSample() {
return sample;
  }
  public void setSample(String newSample) {
sample = newSample;
  }
}

Any ideas on what I'm doing wrong, could this be due to some session
settings in Tomcat?

Thanks!

Brandon



RE: Instantiating Beans on Tomcat

2001-04-10 Thread Brandon Cruz

It is in a package, but it is at the very top level.  It is not a classpath
issue, I have tried to move it to a different directory which is off the
classpath.  When I do that, the error says that it can't find the class at
all.  This error says the class is found, but for some reason can't create a
bean out of it.  I would think that my problem is that I don't have a
constructor with no parameters, but that is not the case.  I'm thinking
there are some permission settings to run a bean or something maybe.  ???

Brandon

-Original Message-
From: Kyle Tippetts [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 6:38 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Instantiating Beans on Tomcat


Is InfoBean in a package? If it is, you need to put the fully-qualified name
in the class= attribute.

It could also be a classpath issue. For example, if your jsp sits at
/jakarta-tomcat/webapps/app, and your bean sits at
/jakarta-tomcat/webapps/app/WEB-INF/classes/com/foo, then you do need to put
/jakarta-tomcat/webapps/app/WEB-INF/classes on the classpath...at least
that's what I've found I have to do to get the beans to instantiate from a
jsp

--Kyle

-Original Message-
From: Brandon Cruz [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 5:15 PM
To: [EMAIL PROTECTED]
Subject: RE: Instantiating Beans on Tomcat


Yeah, there must be something I'm missing, maybe there's some setting in
tomcat which allows me to use beans or something, but I can't find where
that would be.

Brandon

-Original Message-
From: Hunter Hillegas [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 6:00 PM
To: Tomcat User List
Subject: Re: Instantiating Beans on Tomcat


I was getting those but it was because my bean didn't have a constructor
that took no args but it looks like yours does...

Not sure...

Hunter

 From: "Brandon Cruz" [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 Date: Tue, 10 Apr 2001 17:54:24 -0500
 To: [EMAIL PROTECTED]
 Subject: Instantiating Beans on Tomcat

 I am trying to instantiate a very simple bean on Tomcat in a JSP using the
 directive...

 jsp:useBean id="sessionBean" scope="session" class="InfoBean" /

 Everytime I try to run it, I get the following exception...

 javax.servlet.ServletException:  Cannot create bean of class InfoBean





RE: Instantiating Beans on Tomcat

2001-04-10 Thread Kyle Tippetts

Hmm...then I'm not sure what's going on...so is there a package statement in
InfoBean?

As for a setting in tomcat, I don't think you have to set anything to get a
bean to instantiate. I wonder if it has anything to do with Jann mentioned.
I've always put my jsp's in /webapps/mycontext and my beans in
/webapps/mycontext/WEB-INF/classes/package_path and not had any problems
with instantiation. 

Also, check your case on the jsp directive. I noticed you've got
jsp:useBean.../, and if you copied/pasted that into your original message,
then you've got that part correct. However, in one I was trying to do, I
thought I had the case correct, but I actually had jsp:usebean/ and
that was why I couldn't get it to instantiate.

--Kyle


-Original Message-
From: Brandon Cruz [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 5:48 PM
To: [EMAIL PROTECTED]
Subject: RE: Instantiating Beans on Tomcat


It is in a package, but it is at the very top level.  It is not a classpath
issue, I have tried to move it to a different directory which is off the
classpath.  When I do that, the error says that it can't find the class at
all.  This error says the class is found, but for some reason can't create a
bean out of it.  I would think that my problem is that I don't have a
constructor with no parameters, but that is not the case.  I'm thinking
there are some permission settings to run a bean or something maybe.  ???

Brandon

-Original Message-
From: Kyle Tippetts [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 6:38 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Instantiating Beans on Tomcat


Is InfoBean in a package? If it is, you need to put the fully-qualified name
in the class= attribute.

It could also be a classpath issue. For example, if your jsp sits at
/jakarta-tomcat/webapps/app, and your bean sits at
/jakarta-tomcat/webapps/app/WEB-INF/classes/com/foo, then you do need to put
/jakarta-tomcat/webapps/app/WEB-INF/classes on the classpath...at least
that's what I've found I have to do to get the beans to instantiate from a
jsp

--Kyle

-Original Message-
From: Brandon Cruz [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 5:15 PM
To: [EMAIL PROTECTED]
Subject: RE: Instantiating Beans on Tomcat


Yeah, there must be something I'm missing, maybe there's some setting in
tomcat which allows me to use beans or something, but I can't find where
that would be.

Brandon

-Original Message-
From: Hunter Hillegas [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 10, 2001 6:00 PM
To: Tomcat User List
Subject: Re: Instantiating Beans on Tomcat


I was getting those but it was because my bean didn't have a constructor
that took no args but it looks like yours does...

Not sure...

Hunter

 From: "Brandon Cruz" [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 Date: Tue, 10 Apr 2001 17:54:24 -0500
 To: [EMAIL PROTECTED]
 Subject: Instantiating Beans on Tomcat

 I am trying to instantiate a very simple bean on Tomcat in a JSP using the
 directive...

 jsp:useBean id="sessionBean" scope="session" class="InfoBean" /

 Everytime I try to run it, I get the following exception...

 javax.servlet.ServletException:  Cannot create bean of class InfoBean