-
1. Re: Hibernate and CDI with tomcat-embedded
bmajsak May 22, 2013 1:02 PM (in response to yasharbi)As pointed out in another thread, tomcat embedded is not the best container for cdi and jpa, as you will need to wire it up by hand. Any luck with TomEE?
-
2. Re: Hibernate and CDI with tomcat-embedded
yasharbi May 23, 2013 9:26 AM (in response to bmajsak)I am able to run TomEE and arquillian with hibernate and CDI on a sample project , but when I am trying to integrate it with my main project I am getting tha following error when I am running the test
Unable to build EntityManagerFactory
Caused by: java.lang.ClassCastException: org.apache.openejb.hibernate.OpenEJBJtaPlatform cannot be cast to org.hibernate.service.jta.platform.spi.JtaPlatform
-
3. Re: Hibernate and CDI with tomcat-embedded
yasharbi May 28, 2013 6:02 AM (in response to yasharbi)My comppany persist to setting Arquillian with Tomcat-embedded 7, since we running that in the customers sites. So I have to throw a way TomEE and start with tomcat-embedded 7.
I started to setting Arquillian with CDI , hibernate and tomcat-embedded 7. I could find a few example for CDI and tomcat-embedded 7 and it is working fine with my Arquillian tests, but I couldn't find any resources or example for setting Arquillian with hibernate and tomcat-embedded. (samples for setting data source , persistence.xml and shrinkWrap, listeners for running hibernate )
I will appriciate anything in this regard ( example , URL , blog, source code). The only thing which I could find for tomcat and Arquillian is this URL https://github.com/arquillian/arquillian-container-tomcat/
but there is nothing related to JPA (hibernate) settings in these examples
-
4. Re: Hibernate and CDI with tomcat-embedded
bmajsak May 29, 2013 3:54 AM (in response to yasharbi)I'm not really convinced if that's a good idea. Tomcat is bare bone and you will need to configure all your application stack by hand.
At this moment we don't provide such setup in the example and we truly believe that for this very need TomEE is the right approach, as it gives you pre-configured, reliable and well tested Java EE environment based on vanilla Tomcat. Why would like to do the same job on your own?
The reason you were getting class cast exception posted before is because TomEE is shipped with OpenJPA as provider, however you can use hibernate if you like. Please have a look here http://tomee.apache.org/tomee-and-hibernate.html
What is your production environment btw?
-
5. Re: Hibernate and CDI with tomcat-embedded
yasharbi May 29, 2013 4:09 AM (in response to bmajsak)We are running Weld-CDI ( converting right now from the previuosly written seam project) , hibernate, JSF and MySQL on vanilla tomcat in the production envirement.
-
6. Re: Hibernate and CDI with tomcat-embedded
bmajsak May 29, 2013 4:25 AM (in response to yasharbi)Ok, so you have done the work of configuring Tomcat for your own needs. I think you can re-apply the same process on embedded version through ShrinkWrap archives.
-
7. Re: Hibernate and CDI with tomcat-embedded
wangliyu May 30, 2013 7:45 AM (in response to yasharbi)Don't try any embeded container, if you have CDI jar (included beans.xml), with embeded container, Weld will scan and try to load the same bean twice (because one is in the runtime classpath, and you put another one in the generated test war file), other hand the tomcat managed/remote container is better.
I'm switching the test from JBoss6 Remote to Tomcat7 managed Container, most part are good, onlything annoying me is Arquillian is not support Conversation Context.
My code are OK to run with CDI 2.0 (in 2.0, the Conversation Scope is now activated with Servlet, no longer with JSF lifecycle). I think Arquillian team should do some work to catch up, also for the JBoss6 container, I have no idea if that part is dead or not. from what I have seen on github/G+, the team now is more like talking rather than doing (especially Dan?). This gives me some impression that the arquillian is just pet project?
-
8. Re: Hibernate and CDI with tomcat-embedded
yasharbi Jun 4, 2013 7:08 AM (in response to wangliyu)I managed to setup arquillian with Hibernate, CDI and H2 database on embedded-tomcat 7
https://github.com/Yasharbi/Arquillian-TomcatEmbedded-Hibernate-CDI-H2
-
9. Re: Hibernate and CDI with tomcat-embedded
bmajsak Jun 4, 2013 9:18 AM (in response to yasharbi)Thanks a lot for contributing back to the community!