使用jetty创建bean时出错

时间:2013-02-10 06:40:12

标签: java hibernate tomcat spring-mvc jetty

我在使用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编译包war:war也运行正常,而war文件对Tomcat-7没有任何问题,但是在jetty上面有错误?

1 个答案:

答案 0 :(得分:1)

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

在这里查看例子: Link 1

或者在这里: Link 2

希望这有帮助