我正在使用SPRING 3.0.4,JPA 2,Hibernate 3.5.5开发应用程序。

我正在尝试在链接http://www.javacodegeeks.com/2010/05/jboss-42x-spring-3-jpa-hibernate.html上给出的现有示例。

唯一的区别是我使用的是最新版本的库和JBOSS服务器。

以下是我的/WEB-INF/lib目录文件的列表

antlr-2.7.6.jar

aopalliance.jar

c3p0-0.9.1.jar

commons-collections-3.1.jar

commons-logging-1.1.1.jar

dom4j-1.6.1.jar

gwt-dev.jar

gwt-user.jar

hibernate3.jar

hibernate-jpa-2.0-api-1.0.0.Final.jar

hsqldb.jar

javassist-3.9.0.GA.jar

jta-1.1.jar

log4j-1.2.16.jar

org.springframework.aop-3.0.4.RELEASE.jar

org.springframework.asm-3.0.4.RELEASE.jar

org.springframework.aspects-3.0.4.RELEASE.jar

org.springframework.beans-3.0.4.RELEASE.jar

org.springframework.context.support-3.0.4.RELEASE.jar

org.springframework.context-3.0.4.RELEASE.jar

org.springframework.core-3.0.4.RELEASE.jar

org.springframework.expression-3.0.4.RELEASE.jar

org.springframework.instrument.tomcat-3.0.4.RELEASE.jar

org.springframework.instrument-3.0.4.RELEASE.jar

org.springframework.jdbc-3.0.4.RELEASE.jar

org.springframework.jms-3.0.4.RELEASE.jar

org.springframework.orm-3.0.4.RELEASE.jar

org.springframework.oxm-3.0.4.RELEASE.jar

org.springframework.test-3.0.4.RELEASE.jar

org.springframework.transaction-3.0.4.RELEASE.jar

org.springframework.web.portlet-3.0.4.RELEASE.jar

org.springframework.web.servlet-3.0.4.RELEASE.jar

org.springframework.web.struts-3.0.4.RELEASE.jar

org.springframework.web-3.0.4.RELEASE.jar

slf4j-api-1.5.8.jar

slf4j-log4j12-1.6.1.jar

spring4gwt-0.0.1.jar

以下是我的/WEB-INF/web.xml文件

<?xml version="1.0" encoding="UTF-8"?>


<listener>
    <listener-class>
        org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>

<!-- Servlets -->

<servlet>
    <servlet-name>springGwtRemoteServiceServlet</servlet-name>
    <servlet-class>org.spring4gwt.server.SpringGwtRemoteServiceServlet
</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>springGwtRemoteServiceServlet</servlet-name>
    <url-pattern>/gwtspring/springGwtServices/*</url-pattern>
</servlet-mapping>

<!-- Default page to serve -->
<welcome-file-list>
    <welcome-file>GWTSpring.html</welcome-file>
</welcome-file-list>

以下是我的/WEB-INF/applicationContext.xml文件
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">

<context:component-scan base-package="com.javacodegeeks.gwtspring" />

<task:annotation-driven executor="myExecutor" scheduler="myScheduler" />

<task:executor id="myExecutor" pool-size="5" />

<task:scheduler id="myScheduler" pool-size="10" />

<tx:annotation-driven />

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="MyPersistenceUnit" />
</bean>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

以下是我的/src/resources/META-INF/petsistence.xml文件
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">

<persistence-unit name="MyPersistenceUnit" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <non-jta-data-source>java:/gwtDS</non-jta-data-source>

    <properties>
        <property name="hibernate.hbm2ddl.auto" value="update" />
        <property name="hibernate.show_sql" value="false" />
        <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
        <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
        <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:salvation" />
        <property name="hibernate.connection.username" value="sa" />
        <property name="hibernate.connection.password" value="" />

        <property name="hibernate.c3p0.min_size" value="5" />
        <property name="hibernate.c3p0.max_size" value="20" />
        <property name="hibernate.c3p0.timeout" value="300" />
        <property name="hibernate.c3p0.max_statements" value="50" />
        <property name="hibernate.c3p0.idle_test_period" value="3000" />

    </properties>

</persistence-unit>

现在,当我尝试使用JBOSS服务器进行编译时,出现以下错误



这里有人可以帮助我解决问题吗?

如果您还有其他需要,请告诉我。

谢谢。

最佳答案

我个人从来没有成功将JPA 2.0与JBoss一起使用 5.1.x (由于与JPA 1.0的集成太紧密),尽管JBoss 4.2似乎可行。

我的建议是要么使用JBoss 6.0 M4(在撰写本文时),然后从Web应用程序中删除所有与 hibernate 有关的JAR:

  • antlr-2.7.6.jar
  • commons-collections-3.1.jar
  • dom4j-1.6.1.jar
  • hibernate3.jar
  • hibernate-jpa-2.0-api-1.0.0.Final.jar
  • javassist-3.9.0.GA.jar
  • jta-1.1.jar

  • 或只是简单地使用Tomcat(并按原样部署Web应用程序),因为您没有使用JBoss的任何东西。

    也可以看看
  • JBoss 5.1.0.GA, JPA 2.0, and EClipseLink 2.0(未回答)
  • Hibernate 3.5-Final in JBoss 5.1.0.GA
  • 09-26 18:58