Java Springs SEVERE Exception : javax.servlet.ServletException: Circular view path

Java Springs SEVERE  Exception : javax.servlet.ServletException: Circular view path

Exception : occurred while calling REST API in Springs

 org.apache.catalina.core.StandardWrapperValve invoke SEVERE:

Servlet.service() for servlet [Spring] in context with path [/app] threw exception

[Circular view path [events]: would dispatch back to the current handler URL [/app/service/events] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)] with root cause javax.servlet.ServletException: Circular view path [events]: would dispatch back to the current handler URL [/app/service/events] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.) at org.springframework.web.servlet.view.InternalResourceView.prepareForRendering(InternalResourceView.java:209) at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:149) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1526) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1482) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)

Solution :

Change your controller API signature from

public EventListResponse fetchEvents() 


public @ResponseBody EventListResponse fetchEvents

Regular Expressions : How Exactly they work internally ?

Regular Expressions : How Exactly they work internally ?

Regular expressions were playing major role in computers from several decades, they are not as simple as we think. They are need extensive computational power, a decade before regular expressions were a big headache for computer programmers and scientists because they were consuming lot of time to complete the task.

History behind Regular Expressions :

A neuroscientist  who tried to understand how the human brain could produce complex patterns using simple cells that are bound together. In 1943, Warren McCulloch and Walter Pitts published “A logical calculus of the ideas immanent in nervous activity”.  this paper had a great influence on computer science during that time. In 1956, mathematician Stephen Kleene developed this model one step further. In the paper “Representation of events in nerve nets and finite automata” he presents a simple algebra. The terms Regular Sets and Regular Expressions were born from then. As mentioned above, Kleene’s algebra had only two operations and one function. In 1968, the Unix pioneer Ken Thompson published the article “Regular Expression Search Algorithm” in Communications.

A Pattern in regular expression :

How to learn regular expressions ? How to understand regular expressions?. They look confusing to understand regular expression but regular expressions are an elegant way to do some string manipulations.

We have studied finite automata and the regular expressions all just works on this theory, but Most modern programming languages (Perl, Python, Ruby, Java (and JVM based languages), C#) do not use this approach rather they use recursive backtracking approach. But finite automata is really good to understand regular expressions with its state diagrams and not a bad idea to implement in this approach may be recursive backtracking is better. So do you need a help to understand regular expression? here it is…

Let us take one example, Validating an email address

If this is your regular expression


The respective state diagram might look like below

Regular expression state diagram

Regular expression state diagram


Regular expression parser Source Code

If you want to try out with your own regular expression code you can better go through here 



Mathematics to solve real-world problem

Analysing problem of global warming using Mathematics

we studied mathematics in high-school, degree college but never tried to apply the concepts in real-world. I was just thinking what example I shall take and how to write a program for the same. I got to know an interesting problem, only the problem is interesting but in real the problem is really worrying.


in Arctic the ice surface reflects 90% of the radiation but the water surface reflects only 10% of the radiation. Considering the fact in last two decades the Arctic like places showing effect of climate change. The water surface absorbs 90% of the radiation and hence leads to chain reaction. Assuming for every 1000 gray radiation, 0.65 sqft/hr water formation from ice surface, to predict how much ice surface might vanish and what could be the impact on global warming in next two decades?

To solve this problem one must apply integration which we study in Mathematics calculus, the same problem in other way to find out the rate of change of water surface can be evaluated using differential calculus.

Let me try out this problem with a C program, definitely I still didn’t find the integration or differential calculus equation to solve, but let me prepare set of simulated data with certain assumptions.

C Program

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
    Ice surface - reflects 90% of the sun light
    Water surface - reflects 10% of the sub light
    100 ice surface             - 10% absorbs
    100 water surface           - 90%
    Radiation = 100 gray
    100 * 90 = 9000 gray
    100 * 10 = 1000 gray
    assume that as temperature decreases ice surface increases, at the rate say 0.6 sqft per 1000 gray
    float iceSurfaceArea;
    float waterSurfaceArea;
    float radiationQuantity;
    float iceSurfaceAbsorption;
    float waterSurfaceAbsorption;
    float waterFormationPerHour;
int main(int argc, const char * argv[])
    ICE_RADIATION_INFO iceRadiationSamples[100];
    short int index;
// Just to initialise the set of data for analysis - 
    for (index = 0; index < 100; ++index) {
        ICE_RADIATION_INFO  *iceRadiationSample = &iceRadiationSamples[index];
        // 1.5 is constant taken to generate area in floating point number
        iceRadiationSample->iceSurfaceArea = (rand() % 100) * 1.5;
        iceRadiationSample->waterSurfaceArea = iceRadiationSample->iceSurfaceArea;
        iceRadiationSample->radiationQuantity = (rand() % 1000) * 1.5;
      // absorption is as per discussion 90% from water surface and 10% from ice surface
        iceRadiationSample->iceSurfaceAbsorption = iceRadiationSample->radiationQuantity * 0.1;
        iceRadiationSample->waterSurfaceAbsorption = iceRadiationSample->radiationQuantity * 0.9;
    // with an assumption for every 1000 gray radiation, 0.65 sqft water forms
        iceRadiationSample->waterFormationPerHour = ( 0.65 * iceRadiationSample->radiationQuantity) / 1000; // 0.65 sqft/hr for 1000 gray
            Every hour 0.65 sqft water occumulation , this intern absorbs 90% of radiation , here have to apply integration
            dx/dt = 0.65
    printf("Surface Area \t Radiation \t\t Ice Absorption \t Water absorption\n");
    for (index = 0; index < 50; ++index) {
        ICE_RADIATION_INFO iceRadiationSample = iceRadiationSamples[index];
        printf("%f\t\t %f \t\t %f \t\t %f\n",iceRadiationSample.iceSurfaceArea,iceRadiationSample.radiationQuantity,iceRadiationSample.iceSurfaceAbsorption,iceRadiationSample.waterSurfaceAbsorption);
    return 0;


Surface Area              Radiation                    Ice Absorption                  Water absorption

10.500000                   373.500000                  37.349998                           336.149994

109.500000                 987.000000                  98.699997                            888.299988

45.000000                   408.000000                   40.799999                           367.200012

66.000000                   1317.000000                 131.699997                         1185.300049

34.500000                   1063.500000                 106.349998                         957.150024

Understanding of computer Memory With a C Program

Memory is one of the important resource , we can say its a crucial resource in computers. In a limited amount of memory an operating system tries to satisfy all the applications and the need of memory.

Let us try to understand how a memory looks – the theory and an example simple program to understand the concept in a better way.

Memory –


 Understanding Of Memory

When we say a memory is allocated for an instance ! How exactly you visualise the memory and allocation ?

A memory is array of smallest unit of space which is nothing but a byte of space location. If a variable holds an integer, float or any type of data, it occupies certain set of such memory locations. Typically it looks like below.

Array of memory locations

In the above memory structure we can see how data is stored in memory.

The String “XYZ” , the number 15 , it looks like at location 12, number 15 is stored, starting from location 21, string XYZ is stored.

If I dig into the depth of it, every thing in computers will be converted into binary , so ‘X’ will be converted into binary which occupies 8 bits , similarly each character will be converted to its ASCII and the ASCII value will be converted to binary ( Ref – http://sticksandstones.kstrom.com/appen.html )

Let us consider one example and try to fill the memory locations 

char subjects[3][2][25] ;

The above character multidimensional array will holds 2 subjects of 3 semesters each of length 25 characters.

subjects[0] -> will give you 2 subjects of first sem, each subject of 25 characters.

subjects[1] -> will give you 2 subjects of second sem, each subject of 25 characters.

If I assign the subjects to this array , the subject names in memory looks like below


For better understanding just check the below diagram of memory layout

Memory Layout