0

我在使用 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 没有任何问题,但在码头有上述错误?

4

1 回答 1

1

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

看这里例如: 链接1

或在这里: 链接 2

希望这可以帮助

于 2013-02-10T06:44:39.083 回答