You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Alexander ten Bruggencate <a....@home.nl> on 2000/11/15 16:57:36 UTC

aaargh..

for the past 3 days i've been trying to get a jsp to work with an ejb of
mine.
the only problem is that <jsp:setProperty ..../> and <jsp:getProperty
..../> won't work.

tomcat reports: org.apache.jasper.JasperException: Attempted a bean
operation on a null object.
        at
org.apache.jasper.runtime.JspRuntimeLibrary.handleGetProperty(JspRuntimeLibrary.java:427)

part of the jsp file:
<%
nl.step.stepdb.person.interfaces.Person p;
p = pbrowse.createUser();
%>

now I KNOW that the creation of the person is succesfull because it
turns up in the datatbase.
so what's wrong here?

i use jboss-2.0-final with tomcat 3.2b7.
i could really use some help here...

-Alexander.


RE: aaargh..

Posted by Ranko Bijelonic <ra...@dietsmart.com>.
not an ejb, right, just a bean?  and what is your bean here? pbrowse?

> for the past 3 days i've been trying to get a jsp to work with an ejb of

-----Original Message-----
From: Danno Ferrin [mailto:shemnon@earthlink.net]
Sent: Wednesday, November 15, 2000 12:00 PM
To: tomcat-user@jakarta.apache.org
Subject: Re: aaargh..


try storing the object p in the page attributes under the name that the
setProperty attribute is attempting to modify.  setProperty and
getProperty cannot function without the objects existing in one of the
attributes set.  (incidentally the jsp:useBean automatically exports the
object to the page attributes, which is why it works seamlessly).

--Danno

Alexander ten Bruggencate wrote:

> for the past 3 days i've been trying to get a jsp to work with an ejb of
> mine.
> the only problem is that <jsp:setProperty ..../> and <jsp:getProperty
> ...../> won't work.
>
> tomcat reports: org.apache.jasper.JasperException: Attempted a bean
> operation on a null object.
>         at
>
org.apache.jasper.runtime.JspRuntimeLibrary.handleGetProperty(JspRuntimeLibr
ary.java:427)
>
> part of the jsp file:
> <%
> nl.step.stepdb.person.interfaces.Person p;
> p = pbrowse.createUser();
> %>
>
> now I KNOW that the creation of the person is succesfull because it
> turns up in the datatbase.
> so what's wrong here?
>
> i use jboss-2.0-final with tomcat 3.2b7.
> i could really use some help here...
>
> -Alexander.
>
>
>
>



Re: aaargh..

Posted by Danno Ferrin <sh...@earthlink.net>.
try storing the object p in the page attributes under the name that the 
setProperty attribute is attempting to modify.  setProperty and 
getProperty cannot function without the objects existing in one of the 
attributes set.  (incidentally the jsp:useBean automatically exports the 
object to the page attributes, which is why it works seamlessly).

--Danno

Alexander ten Bruggencate wrote:

> for the past 3 days i've been trying to get a jsp to work with an ejb of
> mine.
> the only problem is that <jsp:setProperty ..../> and <jsp:getProperty
> ...../> won't work.
> 
> tomcat reports: org.apache.jasper.JasperException: Attempted a bean
> operation on a null object.
>         at
> org.apache.jasper.runtime.JspRuntimeLibrary.handleGetProperty(JspRuntimeLibrary.java:427)
> 
> part of the jsp file:
> <%
> nl.step.stepdb.person.interfaces.Person p;
> p = pbrowse.createUser();
> %>
> 
> now I KNOW that the creation of the person is succesfull because it
> turns up in the datatbase.
> so what's wrong here?
> 
> i use jboss-2.0-final with tomcat 3.2b7.
> i could really use some help here...
> 
> -Alexander.
> 
> 
> 
> 


RE: aaargh..

Posted by Ranko Bijelonic <ra...@dietsmart.com>.
Its all of because where your code gets placed.
That is, the useBean tag is translated into code which comes before any of
the <% %> code in the body of JSP.
So when you use setProperty it is transalted into code that comes before
your <% %> code but there is no bean at that point.

Instead of changing the bean, you could put initialization code inside the
useBean tag.

<jsp:useBean id="mybean" scope="myscope" class="myclass">
<%
	...any java code....
%>
</jsp:useBean>

This way, the code you include will be placed at the right point when your
JSP is turned into a servlet.
The setProperty tags will get transalted into code that comes after this.

I hope this helps.

>just for arguments sake, why does then usebean tag need to create a bean
before i can use set-
>and getProperty on it?

thnx,
-Alexander.



Re: aaargh..

Posted by Alexander ten Bruggencate <a....@home.nl>.
William Brogden wrote:

> Alexander ten Bruggencate wrote:
> >
> > for the past 3 days i've been trying to get a jsp to work with an ejb of
> > mine.
> > the only problem is that <jsp:setProperty ..../> and <jsp:getProperty
> > ..../> won't work.
> >
> > tomcat reports: org.apache.jasper.JasperException: Attempted a bean
> > operation on a null object.
> >         at
> > org.apache.jasper.runtime.JspRuntimeLibrary.handleGetProperty(JspRuntimeLibrary.java:427)
> >
> > part of the jsp file:
> > <%
> > nl.step.stepdb.person.interfaces.Person p;
> > p = pbrowse.createUser();
> > %>
> >
> > now I KNOW that the creation of the person is succesfull because it
> > turns up in the datatbase.
> > so what's wrong here?
> >
> > i use jboss-2.0-final with tomcat 3.2b7.
> > i could really use some help here...
> >
> > -Alexander.
>
> In your useBean tag, did you give the complete package when naming the
> class?
> If you just give the class, the bean will not be created.
>
> --
> WBB - wbrogden@bga.com
> Author of Java Developer's Guide to Servlets and JSP
> ISBN 0-7821-2809-2

Hi!,

i didn't use the <jsp:useBean> tag at all, because i made an idGeneratorBean that creates a
unique id for a person. Right now this means that <jsp:useBean ... /> cannot create a person
because it doesn't know how to give that person a unique id...

So you are saying that the usebean tag should create the instance of my person bean? and only
after that can i try getProperty and setProperty?

This would mean some re-writing of my beans, so something like below WOULD work?
:::::::::::
add.jsp
:::::::::::
<jsp:useBean id="idgen" class="nl.step.stepdb.idgen.interfaces.IdGenerator" scope="page"/>
<jsp:useBean id="person" class="nl.step.stepdb.person.interfaces.Person" scope="page/>

<% person.setId(idgen.createId("Person")); %>
<jsp:setProperty name="person" property="*"/>

just for arguments sake, why does then usebean tag need to create a bean before i can use set-
and getProperty on it?

thnx,
-Alexander.


Re: aaargh..

Posted by William Brogden <wb...@bga.com>.

Alexander ten Bruggencate wrote:
> 
> for the past 3 days i've been trying to get a jsp to work with an ejb of
> mine.
> the only problem is that <jsp:setProperty ..../> and <jsp:getProperty
> ..../> won't work.
> 
> tomcat reports: org.apache.jasper.JasperException: Attempted a bean
> operation on a null object.
>         at
> org.apache.jasper.runtime.JspRuntimeLibrary.handleGetProperty(JspRuntimeLibrary.java:427)
> 
> part of the jsp file:
> <%
> nl.step.stepdb.person.interfaces.Person p;
> p = pbrowse.createUser();
> %>
> 
> now I KNOW that the creation of the person is succesfull because it
> turns up in the datatbase.
> so what's wrong here?
> 
> i use jboss-2.0-final with tomcat 3.2b7.
> i could really use some help here...
> 
> -Alexander.

In your useBean tag, did you give the complete package when naming the
class?
If you just give the class, the bean will not be created.

-- 
WBB - wbrogden@bga.com
Author of Java Developer's Guide to Servlets and JSP 
ISBN 0-7821-2809-2