2015-01-06 78 views
3

我正在試圖在jboss eap 6.2上使用monogodb提供程序來獲得hibernate-ogm。如何讓hibernate-ogm在jboss eap 6.2上工作?

我已經配置我的persistence.xml

<?xml version="1.0"?> 
<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="monitor" transaction-type="JTA"> 
     <provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider> 
     <!--<jta-data-source>java:/jdbc/monitorservice/monitorDs</jta-data-source>--> 
     <!--<jta-data-source>java:/DefaultDS</jta-data-source>--> 
     <properties> 
      <property name="hibernate.transaction.jta.platform" 
         value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" /> 

      <property name="hibernate.ogm.datastore.provider" value="mongodb" /> 
      <property name="hibernate.ogm.datastore.database" value="db"/> 
      <property name="hibernate.ogm.datastore.host" value="server"/> 
      <property name="hibernate.ogm.datastore.port" value="port"/> 
      <property name="hibernate.ogm.datastore.username" value="user"/> 
      <property name="hibernate.ogm.datastore.password" value="pass"/> 

     </properties> 
    </persistence-unit> 
</persistence> 

這是我的類,它使用實體管理器:

@Stateless 
public class ProcessDao { 

    @PersistenceUnit(name = "monitor") 
    private EntityManager entityManager; 
... 
} 

但在執行代碼時,我得到以下異常:

Caused by: java.lang.IllegalArgumentException: Can not set javax.persistence.EntityManager field com.example.ProcessDao.entityManager to org.hibernate.ogm.hibernatecore.impl.OgmSessionFactoryImpl 
     at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:164) [rt.jar:1.7.0_71] 
     at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:168) [rt.jar:1.7.0_71] 
     at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) [rt.jar:1.7.0_71] 
     at java.lang.reflect.Field.set(Field.java:741) [rt.jar:1.7.0_71] 
     at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:114) [jboss-as-ee-7.3.2.Final-redhat-2.jar:7.3.2.Final-redhat-2] 
     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1] 
     at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1] 
     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1] 
     at org.jboss.as.ee.component.ManagedReferenceInterceptorFactory$ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptorFactory.java:95) [jboss-as-ee-7.3.2.Final-redhat-2.jar:7.3.2.Final-redhat-2] 
     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1] 
     at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1] 
     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1] 
     at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.3.2.Final-redhat-2.jar:7.3.2.Final-redhat-2] 
     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1] 
     at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:272) [jboss-as-ejb3-7.3.2.Final-redhat-2.jar:7.3.2.Final-redhat-2] 
     ... 165 more 

任何想法我能做些什麼來得到這個工作?

+0

我在hibernate ogm論壇上提出過同樣的問題:https://forum.hibernate.org/viewtopic.php?f=31&t=1037708&start=0 – cremersstijn

回答

2

Hibernate OGM需要JBoss EAP附帶的某些庫的更新版本(例如,它只使用最新版本的Hibernate ORM提供的功能)。

曾經有一個實驗ZIP文件,您可以在安裝時將其解壓縮,以添加Hibernate OGM和所有必需的模塊。不幸的是,這個ZIP文件最近沒有更新,因此不是Hibernate OGM 4.1.0.Final發行版的一部分。我們計劃更新ZIP文件,但我們還沒有。

因此,暫時您可能會在Wildfly 8上使用Hibernate OGM。或者,如果您覺得冒險,則可以構建模塊ZIP from source並調查所需的更改(如果需要這樣做,很樂意整合它)。

相關問題