Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

Mustafa Garhi

Ranch Hand
+ Follow
since Nov 05, 2008
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mustafa Garhi

For one million records i just found difference of a few seconds between 1000 and 10,000.

We decided to stick to 10,000.

CommitInterval has done the trick.

Thanks everybody !!
10 years ago
Thanks everyone. The posts have really helped me understand batch better.

I got commitInterval added to the code.

On a little more research of our tomcat's memory settings (1 GB max) and the fact that this process runs every night at 2:00 AM which means less load on server, i deduced that i did not need to worry much about high value of commitInterval overflowing the memory and set the value to 10000.

The process completed in 44 mins.

Should I lower this value? (I am sorry I didn't read Sam's latest post carefully about the ideal value of commitInterval).

Thanks again mates.

10 years ago
All right Sam. Thanks again.

One more question - if I am fetching only one column from the DB, should i need a RowMapper?

I think I can save some time if I can get rid of the mapper somehow.

I have tried removing it and my tomcat throws an error stating about the mandatory mapper.

I am digging more into this, but would appreciate if you had any ideas.
10 years ago
Sam, I am sorry but I wouldn't be able to post the config.

However, I realized that my knowledge of commitInterval was completely wrong as I thought it to be related to DB commits.

After your post I tried the commitInterval and it has made the process faster for sure. How much - I am still seeing, will let you know.

I am assuming if I keep the commitInterval too high, it will keep items in memory which means heap issues and all. Right?

Thanks for that great help.
10 years ago

Before a couple of days I was new to Spring Batch and I have done some reading.

We have a process written in batch that is supposed to read close to a million rows with only one column from a table and write it to a text file.

It points to ORACLE DB and the batch read size is default (10).

Driver used is oracle.jdbc.driver.OracleDriver.

ItemReader we have used is Spring's JdbcCursorItemReader and we have implemented ItemWriter, ItemStream, StepExecutionListener, InitializingBean for the writer.

We have a row mapper.

The whole process of read/write takes 5 hrs everyday which is not acceptable to the client.

When i check the logs I see that the time taken from the time a row is mapped till it is written (for each record) only 1 or 2 milliseconds are being used.

However the next row is mapped only after 15 milliseconds - what is Spring doing here in between? We want to optimize this.

Where should I start?

Please suggest, I would be grateful !
10 years ago
Thank you mate. The article made much more sense to me after your post.
10 years ago
Hello everyone,

Please refer to

And then the following explanation:

At class load time, the interposed class must be found before the original one...The interposed class must have the same full name as the original. For example, a class Foo may exist in package and create an instance of class Bar from package Creating a file in another directory, such as fake/pub/bar and prepending /fake to the classpath, ensures that the JVM will load our definition of class rather than the original. In this way, we can interpose our definitions of Bar's methods over the originals.

In the example that follows is the interface - the object of which would be interposed.

I cannot understand what use case is Sun explaining in the quote above. Specific doubts:
1. Which is the original class being mentioned?
2. In what case would I need to have my own fake/ and not use the original one (in case i have interpreted the meaning of original correctly). Please explain with example if possible.

Thanks in advane
10 years ago
Thank you guys.

I don't know how easy it is to go through any specs but i definitely need to learn that.

Closing this issue.


I have been struggling to find an example on internet that depicts how Security works in an EJB 3 and Jboss 5 combination.

I went through a few and nothing makes the code work.

Here is what i have:




My Remote Session bean:

And the client code is here:

The above code results in Exception in thread "main" javax.ejb.EJBAccessException: Invalid User.

And surprisingly the result doesn't change when i provide nanu/nanunanu as the credentials.

When is this authentication happening? Before even contacting the SessionBean is my call. Probably while trying to lookUp() it goes to my SessionBean's metadata and checks that it is secured and never lets the client go ahead.

This is now forcing me to download glassfish and move ahead.

Let me know if i have missed a trick.

Thanks in advance
10 years ago

I read that NEVER can be useful when you do not want developers to write Database critical code in a method, so that if they do that an exception would result. So while trying to practice that at home, i tried to decorate my interface method declaration with attribute @TransactionAttribute(TransactionAttributeType.NEVER) but no exceptions were thrown when i call the Session Bean without already having a transaction. Surprisingly, when i decorated the Session Bean's method (as opposed to the method declaration in interface) itself with @TransactionAttribute(TransactionAttributeType.NEVER), the same call results in an Exception. I am using jboss 5. What went wrong here? Can i not use @TransactionAttribute(TransactionAttributeType.NEVER) in the Remote Interface itself?

This was in continuation to a thread that was listing the differences between Intercept Filters and Front Controller patterns and i asked that in context of that to strengthen my knowledge. How is this generic in any sense?

A mistake that i certainly made is not put my opinion. I feel i would handle all of these in a Intercepting Filter and let Front Controller take care of the core services and navigation. Let me know if that is wrong.

Where would we handle the following and why?

1. Logging
2. Authentication
3. Authorization
4. Transaction management
5. Security

Thank you guys. I agree completely with you Bear.
Bear i couldn't understand your point. Can you please clarify which conventions are we talking about?

Thanks for all the patience.
Thank you both.

We can still create the object of the Driver using reflection. So there would be the flexibility of having string driver name defined in the peroperty file.

I am sure this will be an overhead. So what i want to ask here is other than reducing the overhead is there any other advantage of going the Class.forName way?

Thanks again