简体   繁体   English

NoSQL和Java EE:使用EntityManager时如何使用Jboss服务器?

[英]NoSQL & Java EE : How to use a Jboss server when using EntityManager?

I working with the oracle example for glassfish and cannot figure out how to use Jboss AS7 in replace of glassfishV3. 我使用的是glassfish的oracle 示例 ,但无法弄清楚如何使用Jboss AS7替代glassfishV3。 The errors I keep getting are 我不断得到的错误是

16:08:09,597 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-12) MSC00001: Failed to start service jboss.persistenceunit."javaee-nosql.war#javaee-nosql": org.jboss.msc.service.StartException in service jboss.persistenceunit."javaee-nosql.war#javaee-nosql": Failed to start service
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_31]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_31]
    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_31]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: javaee-nosql] Unable to build EntityManagerFactory
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889)
    at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162)
    at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
    ... 3 more
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: model.Order column: city (should be mapped with insert="false" update="false")
    at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:680)
    at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:702)
    at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:698)
    at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:724)
    at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:477)
    at org.hibernate.mapping.RootClass.validate(RootClass.java:268)
    at org.hibernate.cfg.Configuration.validate(Configuration.java:1287)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1729)
    at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84)
    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904)

The oracle project I'm working with is here 我正在使用的Oracle项目在这里

Desired Goal/Result: 期望的目标/结果:

Simply change from glassfishv3 to Jboss AS7 只需从glassfishv3更改为Jboss AS7

Application you try to deploy is EclipseLink specific, it uses such a functionality that is implemented in EclipseLink, but not in Hibernate. 您尝试部署的应用程序是特定于EclipseLink的,它使用在EclipseLink中实现的功能,但未在Hibernate中实现。 If you take a look to the log file in your question, you will see that at the moment you are using Hibernate, and thats the reason why it does not work. 如果您查看问题中的日志文件,那么您将在使用Hibernate的那一刻看到它,这就是它不起作用的原因。

Reason why it worked in GlasshFish is that default JPA provider is EclipseLink. 它在GlasshFish中起作用的原因是默认的JPA提供程序是EclipseLink。 JBoss AS 7 is shipped with Hibernate. Hibernate随附了JBoss AS 7。

As you see from the pom.xml file, EclipseLink dependendies do have provided scope, but they are naturally not provided by JBoss. 从pom.xml文件中可以看到,EclipseLink依赖项确实提供了作用域,但JBoss自然不会提供它们。

Instruction to replace Hibernate with EclipseLink can be found from here . 此处可以找到使用EclipseLink替换Hibernate的指令。 But it is likely that some problems will pop up. 但是可能会出现一些问题

The application in Arun's blog not only uses EclipseLink as JPA provider but also some EclipseLink proprietary features (MongoDB mapping). Arun博客中的应用程序不仅使用EclipseLink作为JPA提供程序,而且还使用了某些EclipseLink专有功能(MongoDB映射)。 So, even if you could replace this with Hibernate you would still be missing the mentioned features. 因此,即使您可以用Hibernate代替它,您仍然会缺少上述功能。 You should give HibernateOGM a try and replace the needed functionality with Hibernate OGM parts ... see here: http://www.hibernate.org/subprojects/ogm.html 您应该尝试使用HibernateOGM并用Hibernate OGM部件替换所需的功能...请参见此处: http : //www.hibernate.org/subprojects/ogm.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM