我有一个在Tomcat上开发的Web应用程序,但我需要将其切换到JBoss 7.当我尝试运行我的服务器时,我收到以下错误:
14:55:46,728 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit."reportintegration-0.0.1-SNAPSHOT.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."reportintegration-0.0.1-SNAPSHOT.war".INSTALL: Failed to process phase INSTALL of deployment "reportintegration-0.0.1-SNAPSHOT.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [:1.8.0_131]
at java.lang.Thread.run(Thread.java:748) [:1.8.0_131]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: only one persistence provider can be packaged with an application [org.hibernate.jpa.HibernatePersistenceProvider, org.hibernate.ejb.HibernatePersistence]
at org.jboss.as.jpa.processor.PersistenceProviderProcessor.deploy(PersistenceProviderProcessor.java:65)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
... 5 more
经过大量研究后,似乎JBoss在运行时尝试使用它自己的Hibernate。我不是这方面的专家,所以我的问题是我仍然使用自己的Hibernate或他们的?无论如何,我该怎么做?理想情况下,我可以告诉JBoss忽略他们的。
我的持久性文件如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<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="DirectorDb" transaction-type="RESOURCE_LOCAL">
<description>Persistence unit for Oracle Connection</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.default_schema" value=""/>
<property name="hibernate.connection.autocommit" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.connection.provider_class"
value="org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider" />
<property name="hibernate.connection.isolation" value="2"/>
<property name="hibernate.c3p0.max_size" value="5" />
<property name="hibernate.c3p0.min_size" value="1" />
<property name="hibernate.c3p0.acquire_increment" value="1" />
<property name="hibernate.c3p0.idle_test_period" value="150" />
<property name="hibernate.c3p0.unreturned_connection_timeout" value="300" />
<property name="hibernate.c3p0.debug_unreturned_connection_stack_traces" value="true" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.max_statements_per_connection" value="20" />
<property name="hibernate.c3p0.statement_cache_num_deferred_close_threads" value="0" />
<property name="hibernate.c3p0.timeout" value="300" />
</properties>
</persistence-unit>
<persistence-unit name="DataSourceDb" transaction-type="RESOURCE_LOCAL">
<description>Persistence unit for SQL Server Connection</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="hibernate.default_schema" value=""/>
<property name="hibernate.connection.autocommit" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false"/>
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.connection.provider_class"
value="org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider" />
<property name="hibernate.connection.isolation" value="1"/>
<property name="hibernate.c3p0.max_size" value="5" />
<property name="hibernate.c3p0.min_size" value="1" />
<property name="hibernate.c3p0.acquire_increment" value="1" />
<property name="hibernate.c3p0.idle_test_period" value="150" />
<property name="hibernate.c3p0.unreturned_connection_timeout" value="300" />
<property name="hibernate.c3p0.debug_unreturned_connection_stack_traces" value="true" /> <property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.max_statements_per_connection" value="20" />
<property name="hibernate.c3p0.statement_cache_num_deferred_close_threads" value="0" />
<property name="hibernate.c3p0.timeout" value="300" />
</properties>
</persistence-unit>
</persistence>
我的POM文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>reportintegration</groupId>
<artifactId>reportintegration</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.25</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.25</version>
<!-- <scope>provided</scope> -->
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.25</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<!-- Servlet Context -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.8.Final</version>
</dependency>
<dependency>
<groupId>com.github.noraui</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
</dependency>
<!-- Hibernate c3p0 connection pool -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>4.3.10.Final</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc42</artifactId>
<version>6.0</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.5</version>
</dependency>
</dependencies>
</project>
答案 0 :(得分:0)
通过在我的pom.xml文件中删除对我个人hibernate版本的所有引用,部分解决了这个问题。从那里开始,JBoss对它的版本存在很满意。