snippetjournal

– notes, snippet codes, and my journal

Archive for March 2015

Session in Spring MCV

leave a comment »

It good article about session in spring mvc, so i bookmarked in my blog 😀

What is the HTTP session? What for it exist? I hope you know that HTTP is a stateless protocol, that’s mean that there is no permanent connection between a browser and server. And as the result server doesn’t know who is an initiator of a request, even if an application has just one user. The session is a tool for identifying of requests author. The previous sentence is rough enough, but it explains the main purpose of the sessions. Every user gets it own session with unique identifier when he visits site first time.

Advertisements

Written by snippetjournal

March 26, 2015 at 3:04 am

Posted in Programming

Tagged with ,

Spring 4 Maven Dependency : misbehaviors error spring mvc

with 3 comments

It was very late, almost midnight and I can not resist to write this problem that i got. Almost spent more than one hour to figure out what is wrong with this spring mvc error.

This is my second time develop java web from scratch using spring mvc and i use spring web version 4.x.x. After prepare all xml configuration, there is no problem. All went well until i want to redirect the url from index.jsp to another url that will invoke my controller and the confusion begin 😦

SEVERE: Servlet.service() for servlet [eleveniaTest] in context with path [/elevenia-test] threw exception [Servlet execution threw an exception] with root cause

java.lang.NoSuchFieldError: STANDARD_NUMBER_TYPES

at org.springframework.web.context.request.ServletRequestAttributes.(ServletRequestAttributes.java:55)

at org.springframework.web.servlet.FrameworkServlet.buildRequestAttributes(FrameworkServlet.java:1031)

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:958)

at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)

at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)

…..

After goggling and trying figure out what the cause, some post in stackoverflow instruct to add maven dependency eclipse configuration, and refer the path web-inf/lib.

But it doesn’t solve my problem, because the configuration its already there and the culprit clearly not the maven lib config.

So after looking my previous spring 4.x project there is additional configuration in pom.xml that force all the spring libs 4.x to avoid this misbehavior

<dependencyManagement>
<dependencies>

<!-- Force the version of all the spring jars (core, beans, context, ...)
pulled by spring-data-jpa:1.3.4.RELEASE to 3.2.x when spring-data pulls the
3.1.x versions to prevent some misbehaviors of maven which sometimes pulls
both 3.2.x and 3.1.x versions of spring-core, spring-beans and spring-context -->

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring-framework.version}</version>
</dependency>

</dependencies>
</dependencyManagement>

 

It is likely somehow the spring data jpa pulls between spring version 3.1.x or spring 3.2.x from spring core into libs. so caused above error

Written by snippetjournal

March 11, 2015 at 4:43 pm

Posted in Programming

Tagged with ,