users@glassfish.java.net

RE: java.util.Vector cannot be cast to entity bean

From: Eve Pokua <gorgeous65_at_msn.com>
Date: Sat, 17 Oct 2009 18:27:20 +0100

Hassan,

 

This' what the method is -

 

//To retrieve all bales
        public List<Baleent> findAllBales(){
            List<Baleent> baleent=null;

  try{
                   baleent=(List<Baleent>)em.createNamedQuery("getAllBales").getResultList();

                 return baleent;
                }catch (Exception ex) {

                    System.err.println("Can not get all bales");
            throw new EJBException(ex);
        }
        }//end of All bales


 

Collects data from the DB.

 

I used to use the jsp for loop to display data till I changed everything into

display tag -

 

<c:forEach items="${baleent}" var="baleent">

 

eve


 
> Date: Sat, 17 Oct 2009 09:40:41 -0700
> From: hassan.schroeder_at_gmail.com
> To: users_at_glassfish.dev.java.net
> Subject: Re: java.util.Vector cannot be cast to entity bean
>
> On Sat, Oct 17, 2009 at 9:17 AM, Eve Pokua <gorgeous65_at_msn.com> wrote:
>
> > I managed to get things working.
> > When I change the useBean scopet to application or requestion-
> >
> > <jsp:useBean id="baleent" scope="session" class="entityJB.Baleent" />
> >
> > But then the data I want to display is a null.
>
> ? That doesn't sound like my idea of "working" :-)
>
> > I am trying to establise why the data is a null. It looks like data is
> > not being forwarded from my servlet to my jsp. IN my servlet I have -
>
> You seem fundamentally confused. Your code below:
>
> > baleent=baleBeanRemote.findAllBales();
> > session.setAttribute("baleent",baleent);
>
> :: is setting a session attribute, not "forwarding" anything.
>
> When the JSP page is passed the request, it needs to retrieve the
> attribute from the session. Changing the JSP to look for a "baleent"
> *request* or *application* attribute will certainly return null unless
> you're setting that somewhere else.
>
> But this is dancing around the original problem. I'll ask again --
> what does baleBeanRemote.findAllBales() return?
>
> --
> Hassan Schroeder ------------------------ hassan.schroeder_at_gmail.com
> twitter: @hassan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
                                               
_________________________________________________________________
Download Messenger onto your mobile for free
http://clk.atdmt.com/UKM/go/174426567/direct/01/
--_3e096b24-9788-487b-aa73-c059ad209490_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hassan,<BR>
&nbsp;<BR>
This' what the&nbsp;method is -<BR>
&nbsp;<BR>
//To retrieve all bales<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public List&lt;Baleent&gt; findAllBales(){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List&lt;Baleent&gt; baleent=null;<BR>
&nbsp;&nbsp;try{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; baleent=(List&lt;Baleent&gt;)em.createNamedQuery("getAllBales").getResultList();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return baleent;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }catch (Exception ex) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.err.println("Can not get all bales");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new EJBException(ex);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }//end of All bales<BR><BR>
&nbsp;<BR>
Collects data from the&nbsp;DB.<BR>
&nbsp;<BR>
I used to use&nbsp;the jsp for loop to display data till I&nbsp;changed everything into<BR>
display tag -<BR>
&nbsp;<BR><SPAN lang=EN-GB>
&lt;c:forEach items="${baleent}" var="baleent"&gt; <BR>
&nbsp;<BR>
eve<BR>
</SPAN><BR>&nbsp;<BR>&gt; Date: Sat, 17 Oct 2009 09:40:41 -0700<BR>&gt; From: hassan.schroeder@gmail.com<BR>&gt; To: users@glassfish.dev.java.net<BR>&gt; Subject: Re: java.util.Vector cannot be cast to entity bean<BR>&gt; <BR>&gt; On Sat, Oct 17, 2009 at 9:17 AM, Eve Pokua &lt;gorgeous65@msn.com&gt; wrote:<BR>&gt; <BR>&gt; &gt; I managed to get things working.<BR>&gt; &gt; When I change the useBean scopet to application or requestion-<BR>&gt; &gt;<BR>&gt; &gt; &lt;jsp:useBean id="baleent" scope="session" class="entityJB.Baleent" /&gt;<BR>&gt; &gt;<BR>&gt; &gt; But then the data I want to display is a null.<BR>&gt; <BR>&gt; ? That doesn't sound like my idea of "working" :-)<BR>&gt; <BR>&gt; &gt; I am trying to establise why the data is a null.&nbsp; It looks like data is<BR>&gt; &gt; not being forwarded from my servlet to my jsp. IN my servlet I have -<BR>&gt; <BR>&gt; You seem fundamentally confused. Your code below:<BR>&gt; <BR>&gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; baleent=baleBeanRemote.findAllBales();<BR>&gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; session.setAttribute("baleent",baleent);<BR>&gt; <BR>&gt; :: is setting a session attribute, not "forwarding" anything.<BR>&gt; <BR>&gt; When the JSP page is passed the request, it needs to retrieve the<BR>&gt; attribute from the session. Changing the JSP to look for a "baleent"<BR>&gt; *request* or *application* attribute will certainly return null unless<BR>&gt; you're setting that somewhere else.<BR>&gt; <BR>&gt; But this is dancing around the original problem. I'll ask again --<BR>&gt; what does baleBeanRemote.findAllBales() return?<BR>&gt; <BR>&gt; -- <BR>&gt; Hassan Schroeder ------------------------ hassan.schroeder@gmail.com<BR>&gt; twitter: @hassan<BR>&gt; <BR>&gt; ---------------------------------------------------------------------<BR>&gt; To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net<BR>&gt; For additional commands, e-mail: users-help@glassfish.dev.java.net<BR>&gt; <BR> <br /><hr />Download Messenger onto your mobile for free. <a href='http://clk.atdmt.com/UKM/go/174426567/direct/01/' target='_new'>Learn more.</a></body>
</html>
--_3e096b24-9788-487b-aa73-c059ad209490_--