You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "David M. Karr" <dm...@earthlink.net> on 2001/09/25 04:11:09 UTC

"Cannot find bean XX in scope null"

I'd appreciate some help figuring out what I'm doing wrong with my Struts/EJB
application.  I'm sure I've made more than one mistake, from architectural to
logical.

I have a simple EJB application.  I implemented JAAS using
DatabaseServerLoginModule.  I started to build a web app on top of this, and I
was able to get form-based auth working.

My main page just has a set of links to pages associated with domain objects
(one page per domain class), which will attempt to list all the objects of that
class.  I'd like to use "<logic:iterate>" on each page to iterate through each
object.

I'm certain of that much, at least.  As I get further on with this, I get less
certain of what I should be doing.

For each page listing the domain objects, I'm thinking I would need an
ActionForm subclass.  I thought the attribute of the Form class would be the
Collection containing the list of value objects I obtain through my DAO class
(the EJB bridge).  I thought the "reset()" method is where I would call the
method on the DAO to get the collection of objects.

I assume that in my "struts-config.xml", I would have a "form-beans" element
containing a "form-bean" element which describes my ActionForm subclass.

I also assume that I would have an "<action>" element in the
"<action-mappings>" element that has the "path", "name", and "scope"
attributes.  I don't have a "type" setting because it didn't seem like I needed
an Action class, but it's not clear to me whether that's legal (I didn't see an
error message).

So, to summarize the symptom I see, when the JSP compiler tries to generate and
compile my servlet from the JSP, I see the following:

-----------------
javax.servlet.ServletException: Cannot find bean listClassesForm in scope null
	at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459)
	at c_00025ass._0002fclass_0002flistClasses_0002ejsplistClasses_jsp_6._jspService(_0002fclass_0002flistClasses_0002ejsplistClasses_jsp_6.java:169)
   ...
Root cause:

javax.servlet.jsp.JspException: Cannot find bean listClassesForm in scope null
	at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:495)
   ...
-----------------

I also include here my "struts-config.xml":
-----------------
<struts-config>
 <form-beans>
  <form-bean name="listClassesForm" type="com.intsoft.sgs.web.actions.ListClassesForm"/>
 </form-beans>
 <global-forwards type="org.apache.struts.action.ActionForward">
  <forward name="home" path="/main/main.jsp" redirect="false" />
  <forward name="listUsers" path="/user/listUsers.jsp" redirect="false" />
  <forward name="listClasses" path="/class/listClasses.jsp" redirect="false" />
  <forward name="listStudents" path="/student/listStudents.jsp" redirect="false" />
 </global-forwards>
 <action-mappings>
  <action path="/listClasses" name="listClassesForm" scope="request"/>
 </action-mappings>
</struts-config>
-----------------

Again, I would appreciate any guidance towards the right path.

-- 
===================================================================
David M. Karr          ; Best Consulting
dmkarr@earthlink.net   ; Java/Unix/XML/C++/X ; BrainBench CJ12P (#12004)