[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Struts - Cannot find bean error

Posted on 2004-08-31
19
Medium Priority
?
936 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
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month18 days, 4 hours left to enroll

831 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