2013-09-23 48 views
4

道的hbm.xml:當試圖部署到tomcat,引起:java.lang.NoSuchFieldError的:NULL

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd 
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> 

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
     <property name="location" value="classpath:/sss.properties"/> 
    </bean> 

    <bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> 
     <property name="driverClass" value="${driverClass}"/> 
     <property name="minPoolSize" value="${minPoolSize}"/> 
     <property name="maxPoolSize" value="${maxPoolSize}"/> 
     <property name="maxIdleTime" value="${maxIdleTime}"/> 
     <property name="maxStatements" value="${maxStatements}"/> 
     <property name="idleConnectionTestPeriod" value="${idleConnectionTestPeriod}"/> 
     <property name="autoCommitOnClose" value="${autoCommitOnClose}"/> 
     <property name="user" value="${user}"/> 
     <property name="password" value="${password}"/> 
     <property name="jdbcUrl" value="${jdbcUrl}"/> 
    </bean> 

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 
     <property name="dataSource" ref="dataSource"/> 
     <property name="mappingResources"> 
      <list> 
      <value>ups/scanning/spss/hibernate/sss.hbm.xml</value> 

         .....  
      </list> 
     </property> 
     <property name="hibernateProperties"> 
      <props> 
      <prop key="hibernate.dialect">${hbmDialect}</prop> 
      <prop key="hibernate.show_sql">${hbmShowSql}</prop> 
      <prop key="hibernate.format_sql">${hbmFormatSql}</prop> 
      <prop key="hibernate.use_sql_comments">${hbmSqlComments}</prop> 
      </props> 
     </property> 
    </bean> 

    <bean name="jdbcTemplate" class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate"> 
     <constructor-arg ref="dataSource"/> 
    </bean> 

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 
     <property name="sessionFactory" ref="sessionFactory"/> 
    </bean> 

    <tx:annotation-driven proxy-target-class="true"/> 

    <bean id="sssLoadDao" class="ups.scanning.spss.dao.sssLoadHbmDao"/> 
    <bean id="sssPieceDao" class="ups.scanning.spss.dao.sssPieceHbmDao"/> 
    ..... 
</beans> 

POM依賴我,

<dependencies> 
    <dependency> 
     <groupId>org.springframework.ws</groupId> 
     <artifactId>spring-ws-test</artifactId> 
     <version>2.1.2.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-expression</artifactId> 
     <version>3.1.4.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-orm</artifactId> 
     <version>3.1.4.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-core</artifactId> 
     <version>3.1.3.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-config</artifactId> 
     <version>3.1.3.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-web</artifactId> 
     <version>3.1.3.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-jms</artifactId> 
     <version>3.1.4.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.webflow</groupId> 
     <artifactId>spring-webflow</artifactId> 
     <version>2.3.2.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.webflow</groupId> 
     <artifactId>spring-js</artifactId> 
     <version>2.3.2.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.webflow</groupId> 
     <artifactId>spring-binding</artifactId> 
     <version>2.3.2.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security</groupId> 
     <artifactId>spring-security-taglibs</artifactId> 
     <version>3.1.3.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context-support</artifactId> 
     <version>3.1.4.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-beans</artifactId> 
     <version>3.1.4.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>3.1.4.RELEASE</version> 
     </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>3.1.4.RELEASE</version> 
     </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>3.1.4.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-test</artifactId> 
     <version>3.1.4.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-webmvc</artifactId> 
     <version>3.1.4.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-tx</artifactId> 
     <version>3.1.4.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.ws</groupId> 
     <artifactId>spring-ws-test</artifactId> 
     <version>2.1.2.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.ws</groupId> 
     <artifactId>spring-ws-core</artifactId> 
     <version>2.1.2.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.mail</groupId> 
     <artifactId>mail</artifactId> 
     <version>1.4.1</version> 
    </dependency>  
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.10</version> 
    </dependency> 
    <dependency> 
     <groupId>com.oracle</groupId> 
     <artifactId>ojdbc6</artifactId> 
     <version>11.2.0.1.0</version> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-log4j12</artifactId> 
     <version>1.6.1</version> 
    </dependency> 
    <dependency> 
     <groupId>javassist</groupId> 
     <artifactId>javassist</artifactId> 
     <version>3.12.0.GA</version> 
    </dependency> 
    <dependency> 
     <groupId>c3p0</groupId> 
     <artifactId>c3p0</artifactId> 
     <version>0.9.1.2</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-io</groupId> 
     <artifactId>commons-io</artifactId> 
     <version>2.0.1</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.jms</groupId> 
     <artifactId>jms</artifactId> 
     <version>1.1</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-fileupload</groupId> 
     <artifactId>commons-fileupload</artifactId> 
     <version>1.2.2</version> 
    </dependency> 
    <dependency> 
     <groupId>taglibs</groupId> 
     <artifactId>standard</artifactId> 
     <version>1.1.2</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>jstl</artifactId> 
     <version>1.2</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-codec</groupId> 
     <artifactId>commons-codec</artifactId> 
     <version>1.5</version> 
    </dependency> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>servlet-api</artifactId> 
     <version>2.5</version> 
    </dependency> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.16</version> 
    </dependency> 
    <dependency> 
     <groupId>joda-time</groupId> 
     <artifactId>joda-time</artifactId> 
     <version>2.1</version> 
    </dependency> 
    <dependency> 
     <groupId>joda-time</groupId> 
     <artifactId>joda-time-hibernate</artifactId> 
     <version>1.1</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-logging</groupId> 
     <artifactId>commons-logging</artifactId> 
     <version>1.1.1</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-lang</groupId> 
     <artifactId>commons-lang</artifactId> 
     <version>2.6</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-collections</groupId> 
     <artifactId>commons-collections</artifactId> 
     <version>3.2.1</version> 
    </dependency> 
    <dependency> 
     <groupId>cglib</groupId> 
     <artifactId>cglib-nodep</artifactId> 
     <version>2.2</version> 
    </dependency> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-core</artifactId> 
     <version>3.6.8.Final</version> 
    </dependency> 
    <dependency> 
     <groupId>org.seleniumhq.selenium.client-drivers</groupId> 
     <artifactId>selenium-java-client-driver</artifactId> 
     <version>1.0.2</version> 
    </dependency> 
    <dependency> 
     <groupId>org.seleniumhq.selenium</groupId> 
     <artifactId>selenium-server</artifactId> 
     <version>2.25.0</version> 
    </dependency> 
</dependencies> 

試圖匹配所有版本,刪除。清除本地存儲庫,仍然得到相同的錯誤。有什麼建議需要糾正什麼? 堆棧strace的,

15:32:36,407 ERROR ContextLoader:318 - Context initialization failed 
org.springframework.beans.factory.BeanCreationException: Error creating bean wit 
h name 'org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0 
' defined in class path resource [dao-hbm.xml]: Initialization of bean failed; n 
ested exception is java.lang.NoSuchFieldError: NULL 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456) 
     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb 
ject(AbstractBeanFactory.java:294) 
     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr 
y.getSingleton(DefaultSingletonBeanRegistry.java:225) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe 
an(AbstractBeanFactory.java:291) 
     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean 
(AbstractBeanFactory.java:197) 
     at org.springframework.context.support.AbstractApplicationContext.invoke 
BeanFactoryPostProcessors(AbstractApplicationContext.java:650) 
     at org.springframework.context.support.AbstractApplicationContext.refres 
h(AbstractApplicationContext.java:454) 
     at org.springframework.web.context.ContextLoader.configureAndRefreshWebA 
pplicationContext(ContextLoader.java:388) 
     at org.springframework.web.context.ContextLoader.initWebApplicationConte 
xt(ContextLoader.java:293) 
     at org.springframework.web.context.ContextLoaderListener.contextInitiali 
zed(ContextLoaderListener.java:111) 
     at org.apache.catalina.core.StandardContext.listenerStart(StandardContex 
t.java:4701) 
     at org.apache.catalina.core.StandardContext$1.call(StandardContext.java: 
5204) 
     at org.apache.catalina.core.StandardContext$1.call(StandardContext.java: 
5199) 
     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) 
     at java.util.concurrent.FutureTask.run(FutureTask.java:166) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor. 
java:1145) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor 
.java:615) 
     at java.lang.Thread.run(Thread.java:722) 
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:88) 
     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.evaluat 
eBeanDefinitionString(AbstractBeanFactory.java:1299) 
     at org.springframework.beans.factory.support.BeanDefinitionValueResolver 
.evaluate(BeanDefinitionValueResolver.java:211) 
     at org.springframework.beans.factory.support.BeanDefinitionValueResolver 
.resolveValueIfNecessary(BeanDefinitionValueResolver.java:183) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1118) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBean 
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) 
     ... 18 more 
+0

它似乎是一個春天汽車佈線問題。無法從您發佈的內容中找出根本原因。 – duffymo

+0

看起來你的pom.xml沒有問題;而是你的Spring配置。請顯示這個。 – blackpanther

+0

請顯示'dao-hbm.xml' –

回答

13

你混合春季版本和你混合Spring Security的版本(3.1.3和3.1.4),Spring Security的3.1對3.0春天的依賴,而你正在嘗試使用3.1。 Spring WS 2.1依賴於Spring 3.2 ...所以你有一個完整的混合。

我建議升級到Spring 3.2.4(最新版本),並使用一個屬性元素來確定版本,而不是爲每個依賴項指定它。接下來我還建議使用<dependencyManagement />標籤來強制依賴某個版本。最後(或者可能是第一次)我建議使用帶有依賴性收斂規則的maven-enforcer插件,如果某些依賴項存在衝突版本,則會破壞構建。

強制實施插件

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-enforcer-plugin</artifactId> 
      <version>1.3.1</version> 
      <executions> 
       <execution> 
        <id>enforce-banned-dependencies</id> 
        <goals> 
         <goal>enforce</goal> 
        </goals> 
        <configuration> 
         <rules> 
          <DependencyConvergence/> 
          <bannedDependencies> 
           <searchTransitive>true</searchTransitive> 
           <excludes> 
            <exclude>commons-logging:commons-logging</exclude> 
            <exclude>org.slf4j:slf4j-simple</exclude> 
           </excludes> 
          </bannedDependencies> 
         </rules> 
         <fail>true</fail> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins>  
</build> 

使用特性

<properties> 
    <spring-framework.version>3.2.4.RELEASE</spring-framework.version> 
    <spring-security.version>3.1.4.RELEASE</spring-security.version> 
    <spring-ws.version>2.1.3.RELEASE</spring-ws.version> 
</properties> 

<dependencies> 
    <dependency> 
     <groupId>org.springframework.security<groupId> 
     <artifactId>spring-security-web</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.security<groupId> 
     <artifactId>spring-security-config</artifactId> 
    </dependency> 
</dependencies> 
<!-- Other dependencies go here --> 

使用依賴管理

<dependencyManagement> 
    <dependencies> 
     <!-- Spring --> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-aop</artifactId> 
      <version>${spring-framework.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-aspects</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-context-support</artifactId> 
      <version>${spring-framework.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-core</artifactId> 
      <version>${spring-framework.version}</version> 
      <exclusions> 
       <exclusion> 
        <groupId>commons-logging</groupId> 
        <artifactId>commons-logging</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-expression</artifactId> 
      <version>${spring-framework.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-jdbc</artifactId> 
      <version>${spring.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-jms</artifactId> 
      <version>${spring-framework.version}</version> 
      <exclusions> 
       <exclusion> 
        <groupId>commons-logging</groupId> 
        <artifactId>commons-logging</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-orm</artifactId> 
      <version>${spring-framework.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-oxm</artifactId> 
      <version>${spring-framework.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-tx</artifactId> 
      <version>${spring-framework.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-web</artifactId> 
      <version>${spring-framework.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>${spring-framework.version}</version> 
     </dependency> 
     <!-- Spring Security --> 
    <dependency> 
    <groupId>org.springframework.security</groupId> 
    <artifactId>spring-security-web</artifactId> 
    <version>${spring-security.version}</version> 
    </dependency> 
    <dependency> 
    <groupId>org.springframework.security</groupId> 
    <artifactId>spring-security-config</artifactId> 
    <version>${spring-security.version}</version> 
    </dependency> 
     <!-- Spring WS --> 
     <dependency> 
      <groupId>org.springframework.ws</groupId> 
      <artifactId>spring-ws-core</artifactId> 
      <version>${spring-ws.version}</version> 
      <exclusions> 
       <exclusion> 
        <groupId>commons-logging</groupId> 
        <artifactId>commons-logging</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.ws</groupId> 
      <artifactId>spring-ws-support</artifactId> 
      <version>${spring-ws.version}</version> 
      <exclusions> 
       <exclusion> 
        <groupId>commons-logging</groupId> 
        <artifactId>commons-logging</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 

使用此功能時,您可以在<dependencies />部分中省略版本號。

這個XML不包含commons-logging,因爲我們不使用我們使用SLF4J和jcl-over-slf4j包裝jar。如果你想使用commons-logging,只需從執行插件中刪除排除和規則。

+0

不錯,它有助於解決問題! – user1609085