RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1
Good Saturday! I believe I am getting the same bug. I am getting: Caused by: java.lang.IndexOutOfBoundsException: Index: 2, Size: 0 at java.util.ArrayList.RangeCheck(ArrayList.java:508) at java.util.ArrayList.get(ArrayList.java:320) at test.IndexedForm.getParameter(IndexedForm.java:28) ... 46 more running jakarta-struts-1.1-b2 on Apache Tomcat/4.1.12 JSDK=1.4.1_01-b01 Trying to do this simple indexed ArrayList I built on top of the struts-example webapp. See source code attached. What are the alternatives here. Go back to JDK 1.3.1 ? Thank you so much, Leo From: Jim Krygowski [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Date: Fri, 15 Nov 2002 10:01:35 -0500 We've run some more tests, and documented them. The results are totally consistent and reproducible across all my developers' machines. We develop targeting JRun, but we've tested against Tomcat and seen the same IndexOutOfBoundsException. The cause is always due to the misidentification of an ArrayList attribute as a PropertyDescriptor instead of an IndexedPropertyDescriptor. In the table below are our testing outcomes. Success means that the ArrayList attribute was correctly identified as a IndexedPropertyDescriptor and the code ran without exceptions. Fail consistently means that the ArrayList was misidentified causing an exception to be thrown. We see the problem in JRun and Tomcat, so we can rule out the App Servers. We see the problem in 1.1b2+1.4.1 and Nightly+1.4.1. I've written a test case independent of struts that examines my ActionForm (Introspector.getBeanInfo, beanInfo.getPropertyDescriptors) and regardless of which JDK I'm using, the results come out correctly each time. That leads me to believe that something funny is happening to my ActionForm somewhere in the Struts code. Has anyone else seen this?? I have three developers who came across this error independently so I have to imagine that some of you out there bumped into it too when you moved up to JDK 1.4.1. App Svr; Struts Rel; JDK; Outcome; ---; --; -; ---; JRun 4.1; 1.1b2; 1.3.1; Success; JRun 4.1; 1.1b2; 1.4.1; Fail; Tomcat4.0.9; 1.1b2; 1.3.1; Success; Tomcat4.0.9; 1.1b2; 1.4.1; Fail; JRun 4.1; Nightly; 1.3.1; Success; JRun 4.1; Nightly; 1.4.1; Fail; NONE; NONE; 1.3.1; Success; NONE; NONE; 1.4.1; Success; thanks in advance for you suggestions. jk _ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus %@ page contentType=text/html;charset=UTF-8 language=java % %@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean % %@ taglib uri=/WEB-INF/struts-html.tld prefix=html % %@ taglib uri=/WEB-INF/struts-logic.tld prefix=logic % head titleIndexed Test/title /head body bgcolor=white h3Indexed Form/h3 logic:iterate id=parameter name=indexedForm property=pair bean:write name=parameter property=value / nbsp;nbsp; bean:write name=parameter property=name / brbr /logic:iterate /body /html:html %@ page contentType=text/html;charset=UTF-8 language=java % %@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean % %@ taglib uri=/WEB-INF/struts-html.tld prefix=html % %@ taglib uri=/WEB-INF/struts-logic.tld prefix=logic % head titleIndexed Test/title /head body bgcolor=white h3Indexed Form/h3 html:form action=/indexedResult logic:iterate id=parameter name=indexedForm property=pair bean:write name=parameter property=value / nbsp;nbsp; html:text name=parameter property=name indexed=true/ brbr /logic:iterate html:submit value=Submit/ /html:form /body /html:html ?xml version=1.0 encoding=ISO-8859-1 ? !DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts Configuration 1.1//EN http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd; !-- This is the Struts configuration file for the example application, using the proposed new syntax. NOTE: You would only flesh out the details in the form-bean declarations if you had a generator tool that used them to create the corresponding Java classes for you. Otherwise, you would need only the form-bean element itself, with the corresponding name and type attributes. -- struts-config !-- == Data Source Configuration === -- !-- data-sources data-source set-property property=autoCommit value=false/ set-property property=description value=Example Data Source Configuration/ set-property property=driverClass value=org.postgresql.Driver/ set-property property=maxCount value=4/ set-property property=minCount value=2/ set-property property=password
Re: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1
Jim Krygowski wrote: That leads me to believe that something funny is happening to my ActionForm somewhere in the Struts code. Has anyone else seen this?? I have three developers who came across this error independently so I have to imagine that some of you out there bumped into it too when you moved up to JDK 1.4.1. If you can package your code into a --bare-- minimal cactus/junit test that can reproduce the problem then you'll be able to get other eyes on the problem. Also including your Introspection code that worked correctly would help. And just for fun did it work with Struts 1.0.2 ? If it does work correctly then it might be usefull to determine which version of BeanUtil it was broken in. But again file a bug report with a small junit test that demonstrates the problem. -Rob -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
Re: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1
I've seen some Index out of bounds errors recently that have had to do with parsing of URI's to determine which module is being accessed. Can you try making your app the 'default web application' for your container (i.e., not in a module) and see if this solves the problem? Also, since this processing had changed a number of times in recent nightly builds, it may be worth either checking the 1.1b2 release or a more recent nightly build - depending on which version you're using. But I also really like Rob's suggestion below - isolating a JUnit/Cactus test that can create the problem would isolate it pretty quickly. Best of luck - Kevin Robert Leland [EMAIL PROTECTED] on 11/15/2002 11:35:02 AM Please respond to Struts Users Mailing List [EMAIL PROTECTED] To:Struts Users Mailing List [EMAIL PROTECTED] cc: (bcc: Kevin Bedell/Systems/USHO/SunLife) Subject:Re: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Jim Krygowski wrote: That leads me to believe that something funny is happening to my ActionForm somewhere in the Struts code. Has anyone else seen this?? I have three developers who came across this error independently so I have to imagine that some of you out there bumped into it too when you moved up to JDK 1.4.1. If you can package your code into a --bare-- minimal cactus/junit test that can reproduce the problem then you'll be able to get other eyes on the problem. Also including your Introspection code that worked correctly would help. And just for fun did it work with Struts 1.0.2 ? If it does work correctly then it might be usefull to determine which version of BeanUtil it was broken in. But again file a bug report with a small junit test that demonstrates the problem. -Rob -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org --- This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and erase this e-mail message immediately. --- -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1
Hi all- we have an application originally written to struts 1.1b2 and J2SDK 1.3.1_03 that was working fine. Recently, we've been given the signal to upgrade to J2SDK 1.4.1. Fine, but now we're finding that our form posts are failing with IndexOutOfBoundsException. I've traced through the Struts source with a debugger and found the problem in this block of PropertyUtils code: // Call the property getter and return the value Object value = readMethod.invoke(bean, new Object[0]); if (!value.getClass().isArray()) { if (!(value instanceof java.util.List)) { throw new IllegalArgumentException(Property ' + name + ' is not indexed); } else { //get the List's value return ((java.util.List) value).get(index); } } else { //get the array's value return (Array.get(value, index)); } It seems to me that the line: return ((java.util.List) value).get(index) fails because the form bean just got created by Struts and hasn't been populated yet. However, it works just fine when I switch back to JDK 1.3.1. Anyone got any suggestions as to what might be happening? -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1
Been doing some research since my last post. Here's the setup, same application code, same struts jars, same app server switching between JDK 1.3.1 and 1.4.1: When processing a submit, in the PropertyUtils the following check is made in the getIndexedProperty method on or around line 468: if (descriptor instanceof IndexedPropertyDescriptor) { With JDK 1.3.1 running descriptor is indeed an IndexedPropertyDescriptor, but with JDK 1.4.1 I get a java.beans.PropertyDescriptor, so the code passes by the block that should handle the property I've passed an onto a block of code that results in the IndexOutOfBoundsException. This seems like a 1.4.1 induced bug. Should I log it in Bugzilla? Has anyone else seen this bug? -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] Sent: Thursday, November 14, 2002 11:32 AM To: Struts Users Mailing List Subject: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Hi all- we have an application originally written to struts 1.1b2 and J2SDK 1.3.1_03 that was working fine. Recently, we've been given the signal to upgrade to J2SDK 1.4.1. Fine, but now we're finding that our form posts are failing with IndexOutOfBoundsException. I've traced through the Struts source with a debugger and found the problem in this block of PropertyUtils code: // Call the property getter and return the value Object value = readMethod.invoke(bean, new Object[0]); if (!value.getClass().isArray()) { if (!(value instanceof java.util.List)) { throw new IllegalArgumentException(Property ' + name + ' is not indexed); } else { //get the List's value return ((java.util.List) value).get(index); } } else { //get the array's value return (Array.get(value, index)); } It seems to me that the line: return ((java.util.List) value).get(index) fails because the form bean just got created by Struts and hasn't been populated yet. However, it works just fine when I switch back to JDK 1.3.1. Anyone got any suggestions as to what might be happening? -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1
Step through the getPropertyDescriptor() method, which is called just before that check. That's what makes the decision on what type to return. What is the value of name? -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] Sent: Thursday, November 14, 2002 10:43 AM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Been doing some research since my last post. Here's the setup, same application code, same struts jars, same app server switching between JDK 1.3.1 and 1.4.1: When processing a submit, in the PropertyUtils the following check is made in the getIndexedProperty method on or around line 468: if (descriptor instanceof IndexedPropertyDescriptor) { With JDK 1.3.1 running descriptor is indeed an IndexedPropertyDescriptor, but with JDK 1.4.1 I get a java.beans.PropertyDescriptor, so the code passes by the block that should handle the property I've passed an onto a block of code that results in the IndexOutOfBoundsException. This seems like a 1.4.1 induced bug. Should I log it in Bugzilla? Has anyone else seen this bug? -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] Sent: Thursday, November 14, 2002 11:32 AM To: Struts Users Mailing List Subject: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Hi all- we have an application originally written to struts 1.1b2 and J2SDK 1.3.1_03 that was working fine. Recently, we've been given the signal to upgrade to J2SDK 1.4.1. Fine, but now we're finding that our form posts are failing with IndexOutOfBoundsException. I've traced through the Struts source with a debugger and found the problem in this block of PropertyUtils code: // Call the property getter and return the value Object value = readMethod.invoke(bean, new Object[0]); if (!value.getClass().isArray()) { if (!(value instanceof java.util.List)) { throw new IllegalArgumentException(Property ' + name + ' is not indexed); } else { //get the List's value return ((java.util.List) value).get(index); } } else { //get the array's value return (Array.get(value, index)); } It seems to me that the line: return ((java.util.List) value).get(index) fails because the form bean just got created by Struts and hasn't been populated yet. However, it works just fine when I switch back to JDK 1.3.1. Anyone got any suggestions as to what might be happening? -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1
Hi David- As you suggested I delved into getDisplaySections. I found that my name value, displaySections, was inappropriately identified as an PropertyDescriptor even though it is defined as an ArrayList with get and set methods that handle the ArrayList datatype. The funny thing is that the propertyType attribute of the PropertyDescriptor is ArrayList for the displaySections node. Given this new info, what do you think is going on here? -Original Message- From: Karr, David [mailto:david.karr;attws.com] Sent: Thursday, November 14, 2002 2:03 PM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Step through the getPropertyDescriptor() method, which is called just before that check. That's what makes the decision on what type to return. What is the value of name? -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] Sent: Thursday, November 14, 2002 10:43 AM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Been doing some research since my last post. Here's the setup, same application code, same struts jars, same app server switching between JDK 1.3.1 and 1.4.1: When processing a submit, in the PropertyUtils the following check is made in the getIndexedProperty method on or around line 468: if (descriptor instanceof IndexedPropertyDescriptor) { With JDK 1.3.1 running descriptor is indeed an IndexedPropertyDescriptor, but with JDK 1.4.1 I get a java.beans.PropertyDescriptor, so the code passes by the block that should handle the property I've passed an onto a block of code that results in the IndexOutOfBoundsException. This seems like a 1.4.1 induced bug. Should I log it in Bugzilla? Has anyone else seen this bug? -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] Sent: Thursday, November 14, 2002 11:32 AM To: Struts Users Mailing List Subject: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Hi all- we have an application originally written to struts 1.1b2 and J2SDK 1.3.1_03 that was working fine. Recently, we've been given the signal to upgrade to J2SDK 1.4.1. Fine, but now we're finding that our form posts are failing with IndexOutOfBoundsException. I've traced through the Struts source with a debugger and found the problem in this block of PropertyUtils code: // Call the property getter and return the value Object value = readMethod.invoke(bean, new Object[0]); if (!value.getClass().isArray()) { if (!(value instanceof java.util.List)) { throw new IllegalArgumentException(Property ' + name + ' is not indexed); } else { //get the List's value return ((java.util.List) value).get(index); } } else { //get the array's value return (Array.get(value, index)); } It seems to me that the line: return ((java.util.List) value).get(index) fails because the form bean just got created by Struts and hasn't been populated yet. However, it works just fine when I switch back to JDK 1.3.1. Anyone got any suggestions as to what might be happening? -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1
So you're telling me that in both test cases, the name value is displaySections, and in the before test case, you get back an IndexedPropertyDescriptor, and in the after test case, you get back a PropertyDescriptor? I'm not that familiar with this code, but I don't see how you could get back an IndexedPropertyDescriptor, no matter what JDK version you're using. If your name value was displaySections[number] then you should get an IndexedPropertyDescriptor, otherwise a PropertyDescriptor. -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] As you suggested I delved into getDisplaySections. I found that my name value, displaySections, was inappropriately identified as an PropertyDescriptor even though it is defined as an ArrayList with get and set methods that handle the ArrayList datatype. The funny thing is that the propertyType attribute of the PropertyDescriptor is ArrayList for the displaySections node. Given this new info, what do you think is going on here? -Original Message- From: Karr, David [mailto:david.karr;attws.com] Sent: Thursday, November 14, 2002 2:03 PM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Step through the getPropertyDescriptor() method, which is called just before that check. That's what makes the decision on what type to return. What is the value of name? -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] Sent: Thursday, November 14, 2002 10:43 AM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Been doing some research since my last post. Here's the setup, same application code, same struts jars, same app server switching between JDK 1.3.1 and 1.4.1: When processing a submit, in the PropertyUtils the following check is made in the getIndexedProperty method on or around line 468: if (descriptor instanceof IndexedPropertyDescriptor) { With JDK 1.3.1 running descriptor is indeed an IndexedPropertyDescriptor, but with JDK 1.4.1 I get a java.beans.PropertyDescriptor, so the code passes by the block that should handle the property I've passed an onto a block of code that results in the IndexOutOfBoundsException. This seems like a 1.4.1 induced bug. Should I log it in Bugzilla? Has anyone else seen this bug? -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] Sent: Thursday, November 14, 2002 11:32 AM To: Struts Users Mailing List Subject: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Hi all- we have an application originally written to struts 1.1b2 and J2SDK 1.3.1_03 that was working fine. Recently, we've been given the signal to upgrade to J2SDK 1.4.1. Fine, but now we're finding that our form posts are failing with IndexOutOfBoundsException. I've traced through the Struts source with a debugger and found the problem in this block of PropertyUtils code: // Call the property getter and return the value Object value = readMethod.invoke(bean, new Object[0]); if (!value.getClass().isArray()) { if (!(value instanceof java.util.List)) { throw new IllegalArgumentException(Property ' + name + ' is not indexed); } else { //get the List's value return ((java.util.List) value).get(index); } } else { //get the array's value return (Array.get(value, index)); } It seems to me that the line: return ((java.util.List) value).get(index) fails because the form bean just got created by Struts and hasn't been populated yet. However, it works just fine when I switch back to JDK 1.3.1. Anyone got any suggestions as to what might be happening? -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:struts-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:struts-user-help;jakarta.apache.org
RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1
The usage of displaySections[0] comes from struts itself when it disassembles the request to determine which HTML form field values map to what Bean properties. The identification of PropertyDescriptor vs IndexedPropertyDescriptor is solely the realm of BeanInfo.getPropertyDescriptor. You can see this at work in PropertyUtils method public static PropertyDescriptor[] getPropertyDescriptors(Class beanClass). So no matter what struts thinks about names, it's really all up to Java's reflection capabilities. This is why I feel that we've got a potential JDK 1.4.1 issue here. -Original Message- From: Karr, David [mailto:david.karr;attws.com] Sent: Thursday, November 14, 2002 2:40 PM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 So you're telling me that in both test cases, the name value is displaySections, and in the before test case, you get back an IndexedPropertyDescriptor, and in the after test case, you get back a PropertyDescriptor? I'm not that familiar with this code, but I don't see how you could get back an IndexedPropertyDescriptor, no matter what JDK version you're using. If your name value was displaySections[number] then you should get an IndexedPropertyDescriptor, otherwise a PropertyDescriptor. -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] As you suggested I delved into getDisplaySections. I found that my name value, displaySections, was inappropriately identified as an PropertyDescriptor even though it is defined as an ArrayList with get and set methods that handle the ArrayList datatype. The funny thing is that the propertyType attribute of the PropertyDescriptor is ArrayList for the displaySections node. Given this new info, what do you think is going on here? -Original Message- From: Karr, David [mailto:david.karr;attws.com] Sent: Thursday, November 14, 2002 2:03 PM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Step through the getPropertyDescriptor() method, which is called just before that check. That's what makes the decision on what type to return. What is the value of name? -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] Sent: Thursday, November 14, 2002 10:43 AM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Been doing some research since my last post. Here's the setup, same application code, same struts jars, same app server switching between JDK 1.3.1 and 1.4.1: When processing a submit, in the PropertyUtils the following check is made in the getIndexedProperty method on or around line 468: if (descriptor instanceof IndexedPropertyDescriptor) { With JDK 1.3.1 running descriptor is indeed an IndexedPropertyDescriptor, but with JDK 1.4.1 I get a java.beans.PropertyDescriptor, so the code passes by the block that should handle the property I've passed an onto a block of code that results in the IndexOutOfBoundsException. This seems like a 1.4.1 induced bug. Should I log it in Bugzilla? Has anyone else seen this bug? -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] Sent: Thursday, November 14, 2002 11:32 AM To: Struts Users Mailing List Subject: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Hi all- we have an application originally written to struts 1.1b2 and J2SDK 1.3.1_03 that was working fine. Recently, we've been given the signal to upgrade to J2SDK 1.4.1. Fine, but now we're finding that our form posts are failing with IndexOutOfBoundsException. I've traced through the Struts source with a debugger and found the problem in this block of PropertyUtils code: // Call the property getter and return the value Object value = readMethod.invoke(bean, new Object[0]); if (!value.getClass().isArray()) { if (!(value instanceof java.util.List)) { throw new IllegalArgumentException(Property ' + name + ' is not indexed); } else { //get the List's value return ((java.util.List) value).get(index); } } else { //get the array's value return (Array.get(value, index)); } It seems to me that the line: return ((java.util.List) value).get(index) fails because the form bean just got created by Struts and hasn't been populated yet. However, it works just fine when I switch back to JDK 1.3.1. Anyone got any suggestions
RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1
if you think thats the case, you could crack open the jar files for 1.3.x, take out the reflection classes and replace them in the 1.4.1 jar. If that works then look at the modification notes in the 1.4.1 source, see what they did and email the developers directly. dz -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] Sent: Thursday, November 14, 2002 2:49 PM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 The usage of displaySections[0] comes from struts itself when it disassembles the request to determine which HTML form field values map to what Bean properties. The identification of PropertyDescriptor vs IndexedPropertyDescriptor is solely the realm of BeanInfo.getPropertyDescriptor. You can see this at work in PropertyUtils method public static PropertyDescriptor[] getPropertyDescriptors(Class beanClass). So no matter what struts thinks about names, it's really all up to Java's reflection capabilities. This is why I feel that we've got a potential JDK 1.4.1 issue here. -Original Message- From: Karr, David [mailto:david.karr;attws.com] Sent: Thursday, November 14, 2002 2:40 PM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 So you're telling me that in both test cases, the name value is displaySections, and in the before test case, you get back an IndexedPropertyDescriptor, and in the after test case, you get back a PropertyDescriptor? I'm not that familiar with this code, but I don't see how you could get back an IndexedPropertyDescriptor, no matter what JDK version you're using. If your name value was displaySections[number] then you should get an IndexedPropertyDescriptor, otherwise a PropertyDescriptor. -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] As you suggested I delved into getDisplaySections. I found that my name value, displaySections, was inappropriately identified as an PropertyDescriptor even though it is defined as an ArrayList with get and set methods that handle the ArrayList datatype. The funny thing is that the propertyType attribute of the PropertyDescriptor is ArrayList for the displaySections node. Given this new info, what do you think is going on here? -Original Message- From: Karr, David [mailto:david.karr;attws.com] Sent: Thursday, November 14, 2002 2:03 PM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Step through the getPropertyDescriptor() method, which is called just before that check. That's what makes the decision on what type to return. What is the value of name? -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] Sent: Thursday, November 14, 2002 10:43 AM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Been doing some research since my last post. Here's the setup, same application code, same struts jars, same app server switching between JDK 1.3.1 and 1.4.1: When processing a submit, in the PropertyUtils the following check is made in the getIndexedProperty method on or around line 468: if (descriptor instanceof IndexedPropertyDescriptor) { With JDK 1.3.1 running descriptor is indeed an IndexedPropertyDescriptor, but with JDK 1.4.1 I get a java.beans.PropertyDescriptor, so the code passes by the block that should handle the property I've passed an onto a block of code that results in the IndexOutOfBoundsException. This seems like a 1.4.1 induced bug. Should I log it in Bugzilla? Has anyone else seen this bug? -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] Sent: Thursday, November 14, 2002 11:32 AM To: Struts Users Mailing List Subject: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Hi all- we have an application originally written to struts 1.1b2 and J2SDK 1.3.1_03 that was working fine. Recently, we've been given the signal to upgrade to J2SDK 1.4.1. Fine, but now we're finding that our form posts are failing with IndexOutOfBoundsException. I've traced through the Struts source with a debugger and found the problem in this block of PropertyUtils code: // Call the property getter and return the value Object value = readMethod.invoke(bean, new Object[0]); if (!value.getClass().isArray()) { if (!(value instanceof java.util.List)) { throw new IllegalArgumentException(Property ' + name + ' is not indexed); } else { //get the List's value return
RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1
H given that the reflection package experienced a major refactoring between 1.3.1 and 1.4.1 I don't think mixing and matching classes between the two jars is a worthwhile expenditure of time. We may end up spending more time getting a 1.3.1/1.4.1 franken-jar working than actually solving our problem. I'm pretty satisfied that when we change the JDK we point to (and recompile), our code stops working. I did look at the modification notes and the developers suggest that they completely reworked the BeanInfo code for performance. I'm not sure how that is causing our problem though. I have one of my developers digging into this. If we get to the bottom of it or discover anything new, I'll share it here. thanks for the suggestions thus far. -Original Message- From: Drew Zimber [mailto:drew.zimber;shaws.com] Sent: Thursday, November 14, 2002 3:03 PM To: 'Struts Users Mailing List' Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 if you think thats the case, you could crack open the jar files for 1.3.x, take out the reflection classes and replace them in the 1.4.1 jar. If that works then look at the modification notes in the 1.4.1 source, see what they did and email the developers directly. dz -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] Sent: Thursday, November 14, 2002 2:49 PM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 The usage of displaySections[0] comes from struts itself when it disassembles the request to determine which HTML form field values map to what Bean properties. The identification of PropertyDescriptor vs IndexedPropertyDescriptor is solely the realm of BeanInfo.getPropertyDescriptor. You can see this at work in PropertyUtils method public static PropertyDescriptor[] getPropertyDescriptors(Class beanClass). So no matter what struts thinks about names, it's really all up to Java's reflection capabilities. This is why I feel that we've got a potential JDK 1.4.1 issue here. -Original Message- From: Karr, David [mailto:david.karr;attws.com] Sent: Thursday, November 14, 2002 2:40 PM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 So you're telling me that in both test cases, the name value is displaySections, and in the before test case, you get back an IndexedPropertyDescriptor, and in the after test case, you get back a PropertyDescriptor? I'm not that familiar with this code, but I don't see how you could get back an IndexedPropertyDescriptor, no matter what JDK version you're using. If your name value was displaySections[number] then you should get an IndexedPropertyDescriptor, otherwise a PropertyDescriptor. -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] As you suggested I delved into getDisplaySections. I found that my name value, displaySections, was inappropriately identified as an PropertyDescriptor even though it is defined as an ArrayList with get and set methods that handle the ArrayList datatype. The funny thing is that the propertyType attribute of the PropertyDescriptor is ArrayList for the displaySections node. Given this new info, what do you think is going on here? -Original Message- From: Karr, David [mailto:david.karr;attws.com] Sent: Thursday, November 14, 2002 2:03 PM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Step through the getPropertyDescriptor() method, which is called just before that check. That's what makes the decision on what type to return. What is the value of name? -Original Message- From: Jim Krygowski [mailto:james.krygowski;shaws.com] Sent: Thursday, November 14, 2002 10:43 AM To: Struts Users Mailing List Subject: RE: IndexOutOfBounds error, Struts 1.1b2, J2SDK 1.4.1 Been doing some research since my last post. Here's the setup, same application code, same struts jars, same app server switching between JDK 1.3.1 and 1.4.1: When processing a submit, in the PropertyUtils the following check is made in the getIndexedProperty method on or around line 468: if (descriptor instanceof IndexedPropertyDescriptor) { With JDK 1.3.1 running descriptor is indeed an IndexedPropertyDescriptor, but with JDK 1.4.1 I get a java.beans.PropertyDescriptor, so the code passes by the block that should handle the property I've passed an onto a block of code that results in the IndexOutOfBoundsException. This seems like a 1.4.1 induced bug. Should I log it in Bugzilla? Has anyone else seen this bug? -Original Message- From: Jim Krygowski