aspose file tools*
The moose likes Java in General and the fly likes Bad use of ArrayList in Action? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Bad use of ArrayList in Action?" Watch "Bad use of ArrayList in Action?" New topic
Author

Bad use of ArrayList in Action?

Christopher Mikos
Greenhorn

Joined: Jan 23, 2006
Posts: 13
I'm having a problem with an augmented version of this example:
Posting

I am trying to return a string which I build from an ArrayList in my Action. I can return simple text but I cannot get my string built from the ArrayList generated more than once. I get the response the first time but not the second and my code only executes to the point where I do:



I'm not getting any kind of errors in the stack or tomcat logs.

The only thing I see is this message in the Eclipse console when tomcat is shutting down:

INFO: Waiting for 4 instance(s) to be deallocated

It's not always four instances, usually depends on the number of times -1 that I have run the action

Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Looks like a problem in the DAO factory implementation.

Note, the Action class is part of the Controller. 90% of the code you have in the execute method shouldn't be there. You should move the code to a plain object business object. Create a Transfer Object and send it to the business object. Do all your data processing and and return whatever string back to the Action class for pushing to the View.

execute(...) should look like:


[ June 27, 2008: Message edited by: James Clark ]
Christopher Mikos
Greenhorn

Joined: Jan 23, 2006
Posts: 13
Thanks for your reply and I will attempt a clean up when I am able to get this working.

The DAO factory works fine for other apps I use it with, if I comment everything else out (i.e. json and getting rows after insert) the insert works over and over again without error.

It seems the problem only arises when I try to go out to the db the second (actually it would be the fourth time, second time through the entire workflow) time to retrieve the rows to send back.
Christopher Mikos
Greenhorn

Joined: Jan 23, 2006
Posts: 13
With the code commented out, as follows, I get the response coming back to the callback every time?

Christopher Mikos
Greenhorn

Joined: Jan 23, 2006
Posts: 13
It goes through the entire workflow the first time but just dies after :





Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
You should not need to instantiate two DAO factories or DAO within the same method. Your best bet is to get this out of the Action class and do further troubleshooting with just the plain Java objects.
Christopher Mikos
Greenhorn

Joined: Jan 23, 2006
Posts: 13
There are some really whacky things going on...

I went back to re-test my example code that I used to test my connection cache and DAO factories and it is exibiting similar behavior. This is crazy though, I ran load tests using over a hundred virtual users...something is quite wrong here...
Christopher Mikos
Greenhorn

Joined: Jan 23, 2006
Posts: 13
You were absolutely correct, this problem is coming from somewhere within the DAOFactory, thanks and excuse my persistence with regards to assuming the problem was from somewhere else... I'm still a bit stumped as to how I didn't get this before... I'll report back here when I can get it working
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bad use of ArrayList in Action?