简体   繁体   中英

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. 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

Desired Goal/Result:

Simply change from glassfishv3 to Jboss AS7

Application you try to deploy is EclipseLink specific, it uses such a functionality that is implemented in EclipseLink, but not in 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.

Reason why it worked in GlasshFish is that default JPA provider is EclipseLink. JBoss AS 7 is shipped with Hibernate.

As you see from the pom.xml file, EclipseLink dependendies do have provided scope, but they are naturally not provided by JBoss.

Instruction to replace Hibernate with EclipseLink can be found from here . 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). So, even if you could replace this with Hibernate you would still be missing the mentioned features. You should give HibernateOGM a try and replace the needed functionality with Hibernate OGM parts ... see here: http://www.hibernate.org/subprojects/ogm.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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