【问题标题】:Error creating bean with jetty使用码头创建 bean 时出错
【发布时间】:2013-01-25 13:34:42
【问题描述】:

我在使用 Jetty 启动 Web 应用程序时遇到问题,但是当我使用 Tomcat-07 启动它时没有这样的问题,

错误:

org.springframework.beans.factory.BeanCreationException:  
Error creating bean with name    
'hbmSessionFactory' defined in ServletContext resource 
[/WEB-INF/applicationContext.xml]:
Invocation of init method failed; nested exception is java.lang.NoSuchMethodError:   
javax.persistence.OneToMany.orphanRemoval()Z  

可能是什么原因?

谢谢,

<properties>
    <org.springframework.version>3.0.5.RELEASE</org.springframework.version>
    <slf4j.version>1.5.6</slf4j.version><cxf.version>2.3.3</cxf.version>
    <ehcacheVersion>2.4.2</ehcacheVersion><toolkitVersion>3.3.0</toolkitVersion>
</properties><dependencies>        
    <dependency><groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId><version>${org.springframework.version}</version>
    </dependency><dependency>
        <groupId>org.springframework</groupId><artifactId>spring-expression</artifactId>
        <version>${org.springframework.version}</version>
    </dependency><dependency>
        <groupId>org.springframework</groupId><artifactId>spring-beans</artifactId>
        <version>${org.springframework.version}</version>
    </dependency><dependency>
        <groupId>org.springframework</groupId><artifactId>spring-aop</artifactId>
        <version>${org.springframework.version}</version>
    </dependency><dependency>
        <groupId>org.springframework</groupId><artifactId>spring-context</artifactId>
        <version>${org.springframework.version}</version>
    </dependency><dependency>
        <groupId>org.springframework</groupId><artifactId>spring-context-support</artifactId>
        <version>${org.springframework.version}</version>
    </dependency><dependency>
        <groupId>org.springframework</groupId><artifactId>spring-tx</artifactId>
        <version>${org.springframework.version}</version>
    </dependency><dependency>
        <groupId>org.springframework</groupId><artifactId>spring-jdbc</artifactId>
        <version>${org.springframework.version}</version>
    </dependency><dependency>
        <groupId>org.springframework</groupId><artifactId>spring-orm</artifactId>
        <version>${org.springframework.version}</version>
    </dependency><dependency>
        <groupId>org.springframework</groupId><artifactId>spring-oxm</artifactId>
        <version>${org.springframework.version}</version>
    </dependency><dependency>
        <groupId>org.springframework</groupId><artifactId>spring-web</artifactId>
        <version>${org.springframework.version}</version>
    </dependency><dependency>
        <groupId>org.springframework</groupId><artifactId>spring-webmvc</artifactId>
        <version>${org.springframework.version}</version>
    </dependency><dependency>
        <groupId>org.springframework</groupId><artifactId>spring-webmvc-portlet</artifactId>
        <version>${org.springframework.version}</version>
    </dependency><dependency>
        <groupId>org.springframework</groupId><artifactId>spring-test</artifactId>
        <version>${org.springframework.version}</version><scope>test</scope>
    </dependency><dependency>
        <groupId>javax.servlet</groupId><artifactId>servlet-api</artifactId>
        <version>2.5</version><type>jar</type><scope>compile</scope>
    </dependency><dependency>
        <groupId>javax.servlet</groupId><artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency><dependency>
        <groupId>taglibs</groupId><artifactId>standard</artifactId>
        <version>1.1.2</version>
    </dependency><dependency>
        <groupId>javax.transaction</groupId><artifactId>jta</artifactId>
        <version>1.1</version>
    </dependency><dependency>
        <groupId>org.aspectj</groupId><artifactId>aspectjrt</artifactId>
        <version>1.6.2</version>
    </dependency><dependency>
        <groupId>commons-io</groupId><artifactId>commons-io</artifactId>
        <version>2.0</version>
    </dependency><dependency>
        <groupId>commons-dbcp</groupId><artifactId>commons-dbcp</artifactId>
        <version>1.2.2</version>
    </dependency><dependency>
        <groupId>commons-pool</groupId><artifactId>commons-pool</artifactId>
        <version>1.4</version>
    </dependency><dependency>
        <groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId>
        <version>5.1.18</version>
    </dependency><dependency>
        <groupId>org.hibernate</groupId><artifactId>hibernate-entitymanager</artifactId>
        <version>3.5.5-Final</version>
    </dependency><dependency>
        <groupId>org.hibernate.java-persistence</groupId><artifactId>jpa-api</artifactId>
        <version>2.0-cr-1</version>
    </dependency><dependency>
        <groupId>javax.ws.rs</groupId><artifactId>jsr311-api</artifactId>
        <version>0.11</version>
    </dependency><dependency>
        <groupId>javax.validation</groupId><artifactId>validation-api</artifactId>
        <version>1.0.0.GA</version>
    </dependency><dependency>
        <groupId>org.hibernate</groupId><artifactId>hibernate-validator</artifactId>
        <version>4.0.2.GA</version>
    </dependency><dependency>
        <groupId>javax.annotation</groupId><artifactId>jsr250-api</artifactId>
        <version>1.0</version><scope>provided</scope>
    </dependency></dependencies>  

感谢您的回复,所有依赖项都正确加载,mvn clean compile package war:war 也可以正常工作,并且该 war 文件在 Tomcat-7 上没有任何问题,但在 jetty 出现上述错误?

【问题讨论】:

    标签: java hibernate tomcat spring-mvc jetty


    【解决方案1】:

    我认为是因为这个方法在你的类路径中的 OneToMany 的 jar 接口中不存在。 它应该是相对较新的东西(JPA 2),并且您的类路径中可能有 jpa-1 罐子。 所以试着找出你的罐子的版本并在这里发布。 或许我们可以说出那里缺少什么。

    例如看这里: Link 1

    或者在这里: Link 2

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2020-02-23
      • 2012-12-16
      • 1970-01-01
      • 2017-07-15
      • 1970-01-01
      • 1970-01-01
      • 2023-02-02
      • 2016-06-24
      • 2017-08-20
      相关资源
      最近更新 更多