[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Struts - Cannot find bean error

Posted on 2004-08-31
19
Medium Priority
?
924 Views
Last Modified: 2013-12-29
I am getting:

javax.servlet.ServletException: Cannot find bean DateRange in any scope


My Action Class (ShowKalendarList.java) is:
---------------------------------------------------

public ActionForward execute( ActionMapping mapping,
                                                    ActionForm form,
                                                  HttpServletRequest request,
                                                  HttpServletResponse response) throws Exception {
            
            
            try {
                  Context context = new InitialContext();
                  ListSessionHome home = (ListSessionHome)context.lookup(ListSessionHome.JNDI_NAME);
                  ListSession local = home.create();
                  
                  PeriodeSessionHome periodeSessionHome = (PeriodeSessionHome)context.lookup(PeriodeSessionHome.JNDI_NAME);
                  PeriodeSession periodeSession = periodeSessionHome.create();
                                          
                  System.out.println("------------------");
                  
                  GregorianCalendar from = new GregorianCalendar();
                  from.set(2003,9,20,0,0,0);
                  GregorianCalendar to = new GregorianCalendar();
                  to.set(2003,9,23,0,0,0);
                  
                  System.out.println(from.getTime());
                  System.out.println(to.getTime());
                  
                  /* set it in the request */
                  request.setAttribute("DateRange", periodeSession.getPeriodeByDateRange(from.getTime(), to.getTime()));
                  
            }
            catch (NamingException e) {
                  e.printStackTrace();
            }
            catch (CreateException e) {
                  e.printStackTrace();
            }      
            
            
            return mapping.findForward("Default");
      }


and In my show_kalendar_list.jsp, I have:
--------------------------------------------------

      <logic:iterate name="DateRange" id="Date">
                              <td> <bean:write name="Date" property="label" /> </td>
                        </logic:iterate>


In my Struts-config.xml, I have:
--------------------------------------

 <action path="/ShowKalendarList" type="de.grassgmbh.kalendartool.action.ShowKalendarList">
         <forward name="Default" path="/jsp/manage_list/show_kalendar_list.jsp" />
      </action>

Thanks.
0
Comment
Question by:sangeetha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
  • 5
19 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 11940429
What happens if you add the DateRange in the session? Can you still not retrieve it in the next page?
0
 
LVL 35

Accepted Solution

by:
TimYates earned 380 total points
ID: 11940465
afaik....this should work :-/
0
 
LVL 2

Author Comment

by:sangeetha
ID: 11940466
yes, same result.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Assisted Solution

by:TimYates
TimYates earned 380 total points
ID: 11940481
I assume it does print out your debug (so the action is running)?
0
 
LVL 35

Expert Comment

by:girionis
ID: 11940493
With session? Try this:

/* set it in the session */
HttpSession session = request.getSession(false);
session.setAttrigute("DateRange", periodeSession.getPeriodeByDateRange(from.getTime(), to.getTime()));

and in your show_kalendar_list.jsp, do:

Object o = session.getAttribute("DateRange");
System.out.println(o);

Tell us if "o" is null.
0
 
LVL 2

Author Comment

by:sangeetha
ID: 11940497
oops...i think action is not running...

>> System.out.println("------------------");

even doesn't show in my console. !
0
 
LVL 2

Author Comment

by:sangeetha
ID: 11940503
i get

12:58:33,289 ERROR [Engine] StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Cannot find bean ListView in any scope
................
................

in my console.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11940510
Ahhhh...ok...

Where do you use "ListView" in your code?
0
 
LVL 2

Author Comment

by:sangeetha
ID: 11940527
sorry...'ListView' is another bean. I actually get:

13:02:47,210 ERROR [Engine] StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Cannot find bean DateRange in any scope

and so on.
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 120 total points
ID: 11940542
If action is not running you cannot pass the beans around unless you do it from somewhere else.
0
 
LVL 2

Author Comment

by:sangeetha
ID: 11940554
yes, i understand. Could you guess why my 'jsp' that has the 'action' in struts-config.xml doesn't running..
0
 
LVL 35

Assisted Solution

by:TimYates
TimYates earned 380 total points
ID: 11940564
You are going to "ShowKalendarList.do" aren't you?  Not straight to the jsp?
0
 
LVL 2

Author Comment

by:sangeetha
ID: 11940613
nope! I accessed the 'jsp'

If i access "ShowKalendarList.do", i get:

javax.servlet.ServletException: No getter method for property  of bean DateRange
............
............

Thanks for your patience.
0
 
LVL 35

Expert Comment

by:girionis
ID: 11940646
Can you show us the code of the DateRange and what property is missing the getter?
0
 
LVL 2

Author Comment

by:sangeetha
ID: 11940696

public class PeriodeSession implements SessionBean {

/**
      * @author ws 26.08.2004
      * Return a periode array over date range
      *
      * @ejb.interface-method view-type = "both"
      *
      * @return PeriodeView[]
      */
      public PeriodeView[] getPeriodeByDateRange(Date from, Date to){
            
            Calendar calendar = Calendar.getInstance();
            Calendar calendarTemp = Calendar.getInstance();
            ArrayList arrayList = new ArrayList();
            DateFormat df = DateFormat.getDateInstance();
            
            /* WS 26.08.2004
             * Set calendar with date from
             */
            calendar.setTime(from);
            
            /* WS 26.08.2004
             * add one day to from date until the from date is equal to date
             */
            while(calendar.getTime().before(to) || calendar.getTime().equals(to)){
                  
                  PeriodeView periodeView = new PeriodeView();
                  
                  /* WS 26.08.2004
                   * Fill the periode object
                   */
                  calendarTemp.setTime(calendar.getTime());
                  calendarTemp.add(Calendar.MINUTE, 1440);
                  periodeView.setDateFrom(calendar.getTime());
                  periodeView.setDateTo(calendarTemp.getTime());
                  periodeView.setLabel(df.format(calendar.getTime()));
                  
                  arrayList.add(periodeView);
                                    
                  calendar.add(Calendar.DATE, 1);
            }
            
            return (PeriodeView[])arrayList.toArray(new PeriodeView[0]);
      }
      
 ...............................
 ...............................
 ...............................

and my PeriodeView contains all the getter, setter for the variables.

But, i think the problem might be different, as it worked yesterday!
0
 
LVL 35

Expert Comment

by:girionis
ID: 11940728
> But, i think the problem might be different, as it worked yesterday!

What have you changed since yesterday?
0
 
LVL 2

Author Comment

by:sangeetha
ID: 11941127
>> What have you changed since yesterday?

yes, i got it. I have seperate 'Struts' and EJB projects. The mistake was: I didnt made Project-References for them.

I dont know when i will stop wasting time for these silly errors.

Anyhow, i learnt something from you in this Q. Thanks for your patience.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11941149
Yay!  Glad you got it sorted :-)

This sort of thing, just chatting with people sometimes helps you solve it ;-)

Good luck with it!!

Tim
0
 
LVL 35

Expert Comment

by:girionis
ID: 11941259
:)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question