2

Problem: I got this error:

java.lang.NoSuchFieldError: STANDARD_NUMBER_TYPES

Situation: I'm trying to add spring-jpa for Spring Data JPA and with this configuration of dispatcher-servlet.xml

 <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
        xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:jpa="http://www.springframework.org/schema/data/jpa"
        xsi:schemaLocation="  
    http://www.springframework.org/schema/beans  
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
    http://www.springframework.org/schema/context  
    http://www.springframework.org/schema/context/spring-context-3.0.xsd  
    http://www.springframework.org/schema/tx  
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
    http://www.springframework.org/schema/data/jpa
    http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd">
...
<jpa:repositories base-package="pl.test.library.dao"/>

I'm getting yellow exlamation mark (at line:)

<jpa:repositories base-package="pl.test.library.dao"/>

that says:

Unable to locate Spring NamespaceHandler for element 'jpa:repositories' of schema namespace 'http://www.springframework.org/schema/data/jpa'

So I bet there are some dependencies missing. After adding:

<dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>1.8.1.RELEASE</version>
        </dependency>

and trying to start apache (up-to-date version) I'm getting this error just at the end of server startup:

root cause java.lang.NoSuchFieldError: STANDARD_NUMBER_TYPES org.springframework.web.context.request.ServletRequestAttributes.(ServletRequestAttributes.java:55) org.springframework.web.servlet.FrameworkServlet.buildRequestAttributes(FrameworkServlet.java:1032) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:959) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858) javax.servlet.http.HttpServlet.service(HttpServlet.java:618) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843) javax.servlet.http.HttpServlet.service(HttpServlet.java:725) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

Tried also adding different combinations of below, with no luck aswell:

 <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-commons-core</artifactId>
            <version>1.4.1.RELEASE</version>
        </dependency>
 <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aop</artifactId>
    <version>4.1.7.RELEASE</version>
</dependency>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
efem
  • 31
  • 1
  • 4
  • 1
    check the class NumberUtils – andy Jul 21 '15 at 06:49
  • Thanks Andy! Checking this class lead me to https://github.com/spring-projects/spring-framework/blob/master/spring-core/src/main/java/org/springframework/util/NumberUtils.java which got me thinking do I have **spring-core** dependency... And I didn't, so that was the solution. – efem Jul 21 '15 at 08:22

2 Answers2

0

Change the shcemaLocation, the schema location seems to be the issue here.

from

xsi:schemaLocation="  
    http://www.springframework.org/schema/beans  
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
    http://www.springframework.org/schema/context  
    http://www.springframework.org/schema/context/spring-context-3.0.xsd  
    http://www.springframework.org/schema/tx  
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
    http://www.springframework.org/schema/data/jpa
    http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd">

to

 xsi:schemaLocation="  
    http://www.springframework.org/schema/beans  
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
    http://www.springframework.org/schema/context  
    http://www.springframework.org/schema/context/spring-context-3.0.xsd  
    http://www.springframework.org/schema/tx  
    http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
    http://www.springframework.org/schema/data/jpa
    http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
Vikram Palakurthi
  • 2,406
  • 1
  • 27
  • 30
0

It might be because you have duplicate spring libraries in your build.

If you're using Intellj you can check your out/artifacts/.._war_exploded/WEB-INF/lib directory.

Yet
  • 94
  • 1
  • 7