Raghav Viswanathan

+ Follow
since Apr 26, 2012
Raghav likes ...
Chrome Eclipse IDE Java
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 Raghav Viswanathan


Two most easily confused terms. SOA and ESB. These days for even the most simplest applications claim the use of SOA. SOA is a design concept. It is a way of thinking. A way of designing applications. I would beg to differ to the fact that SOA is for large companies. A well designed and well thought out architecture can scale really well. Who knows your company could be the next big thing in IT space. In my own company, the architecture proposed was a real good architecture. The system has so many interfaces, so many systems that it talks to. I was involved in one such migration. We had shifted to JBoss ESB from VITRIA. The system currently handles more than a couple of million messages per hour. The system also has 25 different interface, of which atleast 10 have webservice endpoints.

Coming back to SOA, it is about how fine grained your want your services to be defined. It is about drawing clear boundaries as to what your services must do. ESB can get you there. That is it can help you design a good Service oriented architecture. Jboss ESB for instance
1. defines a clear flow of data
2. where and when it is transformed and into what format
3. what happens after it reaches a service endpoint.
4. Most importantly it does not cost a penny. (Unless of course you dont need a production support).
5. It does scale well.

A good SOA thought process does not complicate the design but really does bring bad design to lime light as it makes the design all the more transparent.

Raghav. V
4 years ago
Hello Anayonkar, Jeff,

I apologise if I have mislead. Please find the explanantion below

Now when I execute this piece of code with the toString() in Frog Class , The value that gets added as a key in the Map M2 is [my name is arthur]. (tried that by printing the keyset in the map)

When I remove the toString() method from the Frog Class and if I ran this piece of code again, the output I got was [com.mycalc.Frog@19821f]

Even I was under the same impression as both of you have pointed out that if I add f2 to the map, the key would actually be the reference to the object. I was stummped when I saw the result.

The reason why I tried to put the hashcode of the objects as key was to demonstrate that the hascode of the objects were the same. I apologise if I have mislead or given wrong information.

5 years ago
Hello Brian,

Firstly, An interesting piece of code that I have come accross.

i found two things,

1. In the code, when you add

the "thing" that gets added as your key is:

2. When I remove toString() method from Frog class, the "thing" that gets added as a key is instance of the class or the object f2 itself.


The following print statement helped me immensly.

Hope this helps

Also, If you add

you will get your desired result.

Hope this helps.

Raghav. V

5 years ago
Please do use a good Hava reference book or Sun/Oracle tutorial on Java. This should give you a great head start. Most of the concepts are covered there and they are arranged in a sequence so that one can easily understand.

Should class name and file name be identical?

Yes they must be. Java is case sensitive too. Rule Number 1.

Please use th below URL

Java basics

5 years ago
Hello Gihan,

Welcome to the java ranch.

Does work fine for me though. Not really sure as to what impact public access modifier on class would have on the result or output

Output is :
not in the loop
Still in the loop
x =1
Still in the loop
x =2
Still in the loop
x =3
Still in the loop
x =4
Still in the loop
x =5

Do reply with details about the error that you got. There should not be any compilation error as you say.

Thanks and regards,

5 years ago
Hello Vishal,

Please refer to the post below.

what does xmlns mean

More precisely

An XML namespace is declared using the reserved XML pseudo-attribute xmlns or xmlns:prefix, the value of which must be a valid namespace name.

For example, the following declaration maps the "xhtml:" prefix to the XHTML namespace:

Any element or attribute whose name starts with the prefix "xhtml:" is considered to be in the XHTML namespace, if it or an ancestor has the above namespace declaration.
It is also possible to declare a default namespace. For example:

In this case, any element without a namespace prefix is considered to be in the XHTML namespace, if it or an ancestor has the above default namespace declaration.

Attributes are never subject to the default namespace. An attribute without an explicit namespace prefix is considered not to be in any namespace.


Please note that the above text is taken from Wiki Namspace declaration

Hope this helps

Thanks and regards,

Campbell Ritchie wrote:Are you sure you won’t end up adding "3"s until you run out of memory?

I dont think so . Because,
1. (for ArrayList) :the Iterator when it was created will have a length of 5 and new additions will cause Concurrentmodification

2. For CopyOnWriteArrayList: : The iterator retains a copy and when calling add, a new copy of array list is created and on that the add is performed. It does not affect the arraylist object associated to the iterator

The Code looks like this.

the output for the code would be ,

List Value:1
My Old List >>>>>>>>>>> [1, 2, 3, 4, 5]
List Value:2
My Old List >>>>>>>>>>> [1, 2, 3, 4, 5]
List Value:3
My Old List >>>>>>>>>>> [1, 2, 4, 5, 3]
List Value:4
My Old List >>>>>>>>>>> [1, 2, 4, 5, 3]
List Value:5
My Old List >>>>>>>>>>> [1, 2, 4, 5, 3]

If you need to add something, use a for loop rather than an Iterator

I did not understand this part. becasue even if i use a for-loop instead of an iterator, I would end up at ConcurrentModification error.

Thanks and regards,
5 years ago
Hello Priyanka,

Hope you do understand the wightage of what you said

it contain abstract method

. I have written a small peice of code to illustrate it

Hope this example helps.

5 years ago
Thanks Tony for your Reply.

Campbell Ritchie,

The following is a scenario that closely represents the way its implemented.

1. I have a global list of String (Screen field names for which some modfication has happened)
1.1 In a scenario, I have a String (StringObject1) which has been modified by the user on screen.
1.2 The modified element has a rule that suggests that if StringObject1= "Some Value" then StringObject2 will take "New Value".
1.3 In this case First, the list of modified element (global list that is maintained) is first iterated and each element in the list is processed to check for rules.
1.4 The Rule in Point 1.2 is triggered, thus modifying the value of StringObject2.
1.5 When ever a value is modified, the element is added to the global list.
1.6 at the next point of next iteration I run into ConcurrentMod.

I know this sounds silly and would be complex. If at all this needs to be refactored, it would mean a complete redesign. The fix to this problem seems to be either CopyOnWrite or Clone. Please suggest.
5 years ago
Hello Greenhorns,

few days back I faced an exception "java.util.ConcurrentModificationException"

We get this error similar to the scenario desribed below

The catch is that I have say a global list where I keep adding values when there is a change of property.

The way to solve this would be to
1. Clone the global list and use the cloned list for iteration
2.Use CopyOnWriteArrayList

I presonally prefer the CopyOnWriteArrayList because,

It creates a copy only when we would run into Concurrent modification

But am not able to substantiate my claim. Could anyone please help out on the understanding of the best solution and why one is better than the other?.
5 years ago
Hello Anitha,
Could you please post a code sample of the objects that you have to compare. The post doesnt seem to be that clear.

Raghav V
5 years ago
Hello Michele,

Just incase you have not found the right place to put the environment variables, you can find the same in run.conf for "default" configuration of JBOSS server. I also hope you are aware that there is no one-size-fits-all -xmx and -xms setting. Moreover, just because we have a high RAM available, we must not set the heap size high. the simple reason is that the higher the heap size, more time will be taken by JVM to clear the objects in heap. There are many articles on the internet that would help you set a good heap size. You would need to simulate your production/ real life environment and keep adjusting your heap size untill you get a fix on one specification. the following list would be my consideration.

1. Number of concurrent users.
2. Size of objects getting created.

Based on this it would be better to profile the application and/ or do a load test or stress test. This would ensure you have a better number for -xmx and -xms. Also do have a look at the Sun Specification that talks about rules regarding setting the heap size and of other parameters.

Between, I am still not sure if your previous message meant that the "system works like charm"

Would be happy to help. Kindly post a few more details.

Thanks and regards,
5 years ago
Hello Suhas,

Issue seems to be with your JNDI name. Kindly check your console again as to what your JNDI name was when the EJB got deployed.

This post has no information about the environment. Kindly let us know about the environment (Version of JBOSS and Version of EJB )being used. Please note that post JEE6 JBOSS the defult bindings have changed a lot. Kindly check the JEE6 specification for more details (If your JBOSS is running on either 6 or 7).

For instance in JBOSS 5 the bindings happen as follows

RemoteClassName/remote (please note class name here is not fully qualified class name). You can check the JNDI name in the trace while its getting deployed. A sample is given below.

15:21:36,237 INFO [JBossASKernel] Created KernelDeployment for: SmapleEJB.jar
15:21:36,237 INFO [JBossASKernel] installing bean: jboss.j2ee:jar=SmapleEJB.jar,name=SmpleEJBBean,service=EJB3
15:21:36,237 INFO [JBossASKernel] with dependencies:
15:21:36,237 INFO [JBossASKernel] and demands:
15:21:36,237 INFO [JBossASKernel] jboss.ejb:service=EJBTimerService
15:21:36,237 INFO [JBossASKernel] and supplies:
15:21:36,237 INFO [JBossASKernel] Class:de.dl.hex.sample.SmpleEJBRemote
15:21:36,237 INFO [JBossASKernel] jndi:SmpleEJBBean/remote-de.dl.hex.sample.SmpleEJBRemote
15:21:36,237 INFO [JBossASKernel] jndi:SmpleEJBBean/remote
15:21:36,237 INFO [JBossASKernel] Added bean(jboss.j2ee:jar=SmapleEJB.jar,name=SmpleEJBBean,service=EJB3) to KernelDeployment of: SmapleEJB.jar
15:21:36,267 INFO [SessionSpecContainer] Starting jboss.j2ee:jar=SmapleEJB.jar,name=SmpleEJBBean,service=EJB3
15:21:36,267 INFO [EJBContainer] STARTED EJB: de.dl.hex.sample.SmpleEJBBean ejbName: SmpleEJBBean
15:21:36,267 INFO [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:

SmpleEJBBean/remote - EJB3.x Default Remote Business Interface
SmpleEJBBean/remote-de.dl.hex.sample.SmpleEJBRemote - EJB3.x Remote Business Interface

The ones in bold denote the JNDI Names. You can use both of them to invoke.

Hope this helps

Thanks and regards,
Hello Lalit,

A warm welcome to Java. Hope your journey towards mastering Java is still on its course. Most of the terms or keywords that Java has is synonymous to english meanings. I would actually anyday bet on Sun's Java tutorial which can be found http://docs.oracle.com/javase/tutorial/java/index.html. This tutorial would cover all/most of the topics. As you start learning a concept say for example Interfaces and Inheritence, you can/must search the net for articles related to it and subsequently try and understand few examples. You would come up with a huge list of doubts, queries and you can post them here. There are lots of geniuses on this forum and they would be more than happy to help you out. This way you would make your learning stuctured and fun filled.

Lastly, Head first is an awesome book first up, do have that as a reference but you would have to practice a lot more with examples on the internet. You could also download some interesting open source projects and try to understand why people have coded in a certain way. If you could not find an answer you can always post them here . Happy Learning.

Thanks and regards,
6 years ago
Hello Campbell,

Happy to know that my imagination of the concept was right.

Thanks and regards,
6 years ago