2011-03-27 66 views
4

我很難讓Jersey與Spring 3.0.5一起工作。我發現很多人說他們在哪裏能夠工作,但我運氣不好。我總是得到:Jersey 1.6與Spring 3.0.5使用Maven

java.lang.NoSuchMethodError:org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava /朗/字符串;)

是任何人能夠使這項工作?


謝謝你的幫忙!


這裏是我的POM依賴關係:

<dependencies> 
    <dependency> 
     <groupId>com.sun.jersey</groupId> 
     <artifactId>jersey-server</artifactId> 
     <version>${jersey-version}</version> 
    </dependency> 

    <dependency> 
     <groupId>com.sun.jersey.contribs</groupId> 
     <artifactId>jersey-spring</artifactId> 
     <version>${jersey-version}</version> 
     <exclusions> 
      <exclusion> 
       <artifactId>spring-core</artifactId> 
       <groupId>org.springframework</groupId> 
      </exclusion> 
      <exclusion> 
       <artifactId>spring-aop</artifactId> 
       <groupId>org.springframework</groupId> 
      </exclusion> 
      <exclusion> 
       <artifactId>spring-beans</artifactId> 
       <groupId>org.springframework</groupId> 
      </exclusion> 
      <exclusion> 
       <artifactId>spring-context</artifactId> 
       <groupId>org.springframework</groupId> 
      </exclusion> 
      <exclusion> 
       <artifactId>spring-web</artifactId> 
       <groupId>org.springframework</groupId> 
      </exclusion> 
     </exclusions> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
     <version>3.0.5.RELEASE</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-aop</artifactId> 
     <version>3.0.5.RELEASE</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>3.0.5.RELEASE</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-beans</artifactId> 
     <version>3.0.5.RELEASE</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
     <version>3.0.5.RELEASE</version> 
    </dependency> 
</dependencies> 

和這裏的錯誤:

GRAVE: Exception while loading the app java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V at com.sun.enterprise.web.WebApplication.start(WebApplication.java:117) at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126) at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:241) at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:236) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:339) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:183) at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:272) at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:310) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:320) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1176) at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$900(CommandRunnerImpl.java:83) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235) at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:141) at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:573) at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:459) at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:391) at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:376) at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:195) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462)

+0

有沒有嵌套異常? – sourcedelica 2011-03-27 18:27:27

回答

4

做一個mvn dependency:tree,並確保沒有任何更多Spring的版本從其他地方進入。 Spring 2.5中不存在ConfigurableWebApplicationContext.setId(),但它在3.x中。

+0

另外做一個雙重檢查,確保這些依賴關係不在你的WEB-INF/lib文件夾中。 – Fil 2011-03-28 19:00:49

+0

依賴關係樹中沒有對Spring 2.5的引用。 WEB-INF下的所有庫都與Spring 3.0.5相關。 – MobileSam 2011-03-28 23:00:11

+1

哪裏有嵌套異常? com.sun.enterprise.web.WebApplication.start()絕對不會調用Spring。 – sourcedelica 2011-03-29 00:46:48

0

謝謝ERICACM,真棒回答。我有使用spring 3.0.5.release的同樣的問題。有2.5.6罐卡在我的web-inf/lib文件夾中。刪除這些解決了這個問題。