This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes lazy collection invoked by OgnlUtil.java even though not referenced in JSP page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "lazy collection invoked by OgnlUtil.java even though not referenced in JSP page" Watch "lazy collection invoked by OgnlUtil.java even though not referenced in JSP page" New topic
Author

lazy collection invoked by OgnlUtil.java even though not referenced in JSP page

Ignacio de Cordoba
Greenhorn

Joined: Jan 04, 2010
Posts: 13
Hi there,
I'm getting the following exception in my JSP page even though the lazy property (siblingCategories) is never invoked or referenced in my JSP page. (I am including an action through s:action into a JSP page)
OgnlUtil.java seems to be invoking all properties in my object. Can I somehow prevent this? I often use EJBs in the page but I look after only invoking eager loading properties, as here. I don't know why OGNL is checking every property in the object and so getting the exception.
Thanks for any ideas or directions,
Ignacio

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It's getting referenced *somewhere*, otherwise the getter would not be called.
Ignacio de Cordoba
Greenhorn

Joined: Jan 04, 2010
Posts: 13
Hello,
I've re-checked it and it really is not invoked anyway in the code. The problem seems to be related with the way s:action works; because I'm invoking the same action recursively: They share request environment. First request invokes the Category.action which shows messages and to lists subcategories messages invokes again Category.action with different primary keys as arguments in the s:action tag. I've solved it replacing s:action with sx:div, which makes an AJAX call to the same action. It works ok this way as requests are completely isolated (that is why I am sure nobody is invoking the lazy property there) but makes the browser make multiple HTTP requests (ajax). I wonder if there is any way to completely isolate the "inner" <s:action> from the invoker action environment. Of course, I've set true ignoreContextParams but no difference.

Regards,
Ignacio
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No--that's one of the (several) caveats with the <s:action> tag, and one of the reasons I tend to tell people to avoid it--too many potential "gotchas".
Ignacio de Cordoba
Greenhorn

Joined: Jan 04, 2010
Posts: 13
Thanks a lot for your replies David,
it took me some time till I saw where the problem was. Anyway and forgetting about s:action, can you think of a [better] alternative of using AJAX with or without sx:div (remote div) tag to get included isolated content?

Thanks,
Ignacio
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Depends on the usecase; would a simple jsp:include work? Or a c:include (or whatever it is, I can't recall)?
Ignacio de Cordoba
Greenhorn

Joined: Jan 04, 2010
Posts: 13
I tested these some time ago with a different issue but the problem is usually the same, probably due to the struts2 architecture when different actions invoked share request. I relied on s:action because it, at least, allows to isolate request parameters. The problem is with request objects. I'll give them a try again anyway.

Regards,
Ignacio
 
Don't get me started about those stupid light bulbs.
 
subject: lazy collection invoked by OgnlUtil.java even though not referenced in JSP page
 
Similar Threads
struts 2 validation and prevent double submit
org/apache/tiles/definition/UnresolvingLocaleDefinitionsFactory.java
org.apache.tiles.impl.CannotRenderException:
Struts 2 Jquery integration
struts2 tile 2.2.0