How to solve the java.lang.StackOverflowError

From WebRatio WebML Wiki

Jump to: navigation, search


The java.lang.StackOverflowError is a runtime error that can be raised by Hybernate and may occur when a unit (i.e. the Selector Unit) manages a great amount of data (thousands of rows).

Using IN clauses inside runtime queries with large set of objects may cause the raise of a java.lang.StackOverflowError. This error is due to the fact that every database can manage a maximum number of objects in IN clauses. For example, using an Oracle database, the root cause of the error may be:

 java.sql.SQLException: ORA-01795: maximum number of expressions in a list is 1000

The problem is caused by too many values that have been passed to a condition applied to a Unit (usually a Key Condition or a Relationship Role Condition). In order to solve the error you'll probably need to change the Web Model of the Web application. In particular you have to find the Units involved in the multiple values passing and merge those units deleting the condition that causes the error and moving the other conditions on the merged unit.

In the following example, an operation group is used to search a product depending on user preferences. The "Related products" Selector Unit searches all the products related to a specific category, the "Searched products" Selector Unit filters the results of the "Related products" Selector Unit according to the name and the price specified by the user.

Image:overflowError.png

In this case, the java.lang.StackOverflowError may occur due to the passage of all the oids of the products from the "Related products" Selector Unit to the "Searched products" Selector Unit. Applying the suggested solution means to have a single Selector Unit with all the conditions.

Image:overflowErrorSolved.png



Related articles:
Category Difficulty Refers
Context Parameters Web Model Beginner Get Unit
Set Unit
Reset Unit
Create Unit Web Model Beginner Create Unit
Create a "Hello world" application Web Model Beginner Site View
WebML
WebRatio
Create a "Simple data centric" web application Web Model Beginner Site View
WebML
WebRatio
Custom Locations and Master pages Web Model Beginner Master Page
Custom Location
… further results












Did you find this article useful? Please rate it!

Rating: 3.1/5 (29 votes cast)

Personal tools