Spring 3.1 entityManagerFactory java.lang.NoSuchFieldError: NULL Error
Asked Answered
I

2

35

I have just migrated Spring 3.0.5 to 3.1 GA. I faced runtime error during initialization:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/spring/infrastructure-config.xml]: Initialization of bean failed; nested exception is java.lang.NoSuchFieldError: NULL
...
Caused by: java.lang.NoSuchFieldError: NULL
    at org.springframework.expression.TypedValue.<clinit>(TypedValue.java:32)
    at org.springframework.expression.spel.support.StandardEvaluationContext.setRootObject(StandardEvaluationContext.java:85)
    at org.springframework.expression.spel.support.StandardEvaluationContext.<init>(StandardEvaluationContext.java:74)
    at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:124)
    at org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1299)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.evaluate(BeanDefinitionValueResolver.java:210)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:182)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    ... 39 more

Here is my xml.

<bean id="entityManagerFactory"
    class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="MyPersistenceUnit" />
  </bean>

What is this java.lang.NoSuchFieldError: NULL about? Have no issue with 3.0.5.

Ist answered 14/12, 2011 at 7:14 Comment(0)
J
56

This means there is a version mismatch--most likely with spring classes. So make sure all your spring jars are 3.1.0. Especially spring-expression. (Also upgrade your JPA provider (hibernate?) if it doesn't work after fixing spring)

Justification answered 14/12, 2011 at 7:18 Comment(3)
Yes, you are right. I use Spring Flex which refers to all version. After I ensure all spring jars are 3.1.0, the error is gone. BTW, how do you know java.lang.NoSuchFieldError: NULL is version mismatch issue?Ist
it means a class was compiled with the field in place, but at runtime it doesn't find itJustification
Thanks, that helped me too, I had the problem after using Spring 3.1.0. A look in the maven dependencies in netbeans 7.1 showed that spring-expression version 3.0.6 was there! Forcing the correct dependency by adding it to the pom.xml file solved the problem.Lou
S
1

It may help you. Upgrading from Spring 3.0.3.RELEASE results in: java.lang.NoSuchFieldError: USER_DECLARED_METHODS

Earlier I had like this

<dependencies>
<!-- Spring 3 dependencies -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>3.1.2.RELEASE</version>
</dependency>
...
</dependencies>

Then I added

<dependencies>
<!-- Spring 3 dependencies -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>3.1.2.RELEASE</version>
    <exclusions>
        <exclusion>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </exclusion>
    </exclusions>
</dependency>
...

</dependencies>
Strepphon answered 2/11, 2013 at 2:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.