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?
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
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
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?
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.
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.
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?
Thanks a lot for contributing back to the community!