Author Archive

Struts 1.1: Problems with logic:iterate tags and “Cannot find bean XXX under any scope”

Tuesday, June 12th, 2007 by AK One

While trying to use the in my application i ran into the error:

javax.servlet.jsp.JspException: Cannot find bean providerListData in any scope

trying to use a . This is a generic error message that the compiler throws to let you know something is wrong with either your data or your setup.
First make sure you have included the taglib necessary to interpret the logic:iterate tag ie adding the line:

‘<'%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %'>‘

to you JSP (Assuming you do have the struts.jar jar in your WEB-INF/lib folder and the TLD files in your WEB-INF folder ). If that still does not solve your problem, check the spelling of your bean name, believe it or not it might be as simple as a capitalization error. In my application i wrote my tag this way:

'<'logic:iterate id="providerListData" name="ProviderView" type="com.sls.beans.Physician" '>‘

and i set the ProviderView collection in my Action class this way:

request.setAttribute(”ProviderView”, ps);

with ps being an array of Physician objects. If you have gone through all these steps and you still are getting the “cannot find bean” error, then your data must be the error, as it must contain null values. If your collection might contain null elements, make sure to use a tag. I added the line

‘<'logic:present name="ProviderView"'>‘
‘<'logic:iterate id="providerListData" name="ProviderView" type="com.sls.beans.Physician" '>‘

…Rest of my display logic

‘<'/logic:present'>‘
‘<'/logic:iterate'>‘
‘<'/logic:present'>‘

The line checking for the existence of the collection element got rid of the error message. So always make sure you return data (in your collection) does not contain null elements and if it does, use the or tags to handle those cases and you should be fine. On a related not, i kept running into a

javax.servlet.jsp.JspException: No getter method available for property physicianId for bean under name org.apache.struts.taglib.html.BEAN

while trying to set up a radio input this way:

Even though my bean had the getPhysicianId() set up properly and spelled correctly because again spelling could be the issue. If you have a property called “myId”, your getter method should be getMyId(). Since a spelling error was not the issue here, i looked closely at the attribute description on the Jakarta homepage and this line got my attention:

The attribute name of the bean whose properties are consulted when rendering the current value of this input field. If not specified, the bean associated with the form tag we are nested within is utilized. (RT EXPR)

So the problem was that since i did not specify the name of the bean to use, it was using the default one (ActionForm) which of course did not have a getPhysicianId() method. By rewriting the code like this:

Specifying the name attribute was what it took to fix the problem for me!

HIH (Hope It Helps)!

Eclipse 3.2 and “Out Of Memory” errors

Wednesday, June 6th, 2007 by AK One

I’ve been working on a project that requires Struts so to speed up my development time i downloaded the latest Exadel Studio Pro (Soon to become Red Hat Developer Studio) for Eclipse. That’s when the nightmare started. I followed the installation instructions, including the part that recommends allocating more memory to Eclipse when launching the program. I thought i had the set up done right but to my dismay, my Eclipse kept crashing every 5 minutes or so, especially when i was trying to edit a struts-config.xml through Exadel’s diagram view. After a fair amount of googling the topic, i found out that i needed to increase my MaxPermSize from the default 64 Mb to 128Mb at least. Easier said than done. Most posts you will find about the topic will advise you to edit you eclipse.ini file this way:

-vmargs
-Xms512m
-Xmx512m
-XX:MaxPermSize=128m

Seemed pretty easy and straight forward yet it did not work and Eclipse kept crashing. I was put on the right track thanks to Max’s Blog. It turns out that Eclipse.ini file has quirks when it comes to the syntax and each argument needs to be put on individual lines, which i have been doing but to no avail. So i decided to take matters in my own hand and specify those same arguments directly when lauching Eclipse. I deleted all the content in my Eclipse.ini and went to the Eclipse’s shortcut on my desktop and under the “Shortcut” tag, i specified the target as:

C:\Eclipse-SDK-3.2.1\eclipse\eclipse.exe -vmargs -Xmx512m -Xms256m -XX:MaxPermSize=128m -Dcom.sun.management.jmxremote

Launching Eclipse that way did not give me any “Could Not Start the Java Virtual Machine” errors i have been having using the Eclipse.ini file. It also correctly set my memory settings, which you can check by going to “Help/About Eclipse SDK”, “Configuration Details” and then checking your “eclipse.vmargs” value. Mine now looks like this:


eclipse.vmargs=-Xmx512m
-Xms256m
-XX:MaxPermSize=128m
-Dcom.sun.management.jmxremote
-jar
C:\Eclipse-SDK-3.2.1\eclipse\startup.jar

I added the “DCom.sun.management.jmxremote” line on a suggestion from Exadel’s blog to be able to monitor my JVM memory usage using Sun’s jconsole. If you would like to do the same, include that command to your vmargs and once Eclipse has been launched run a “jconsole” command and choose the Eclipse process from the “local” tab. It should be the only item in the list anyway.

My Eclipse now runs smooth, and i haven’t experienced any more “Out Of Memory” errors and i don’t have to give up on Exadel’s Studio Pro which is a great tool to develop Struts applications by the way.

HIH (Hope It Helps)!