We have been facing issues with Spring 4 / JPA2 application.The JPA implementation is Hibernate 4.2. The application is packaged as war and is self sufficient (all required dependencies packaged). Also the war correctly deploys on tomcat, jetty , Weblogic. It causes issues only on JBoss. The entity manager is bootstrapped using Spring and we are using Hibernate packaged within our application and NOT from the JBoss server. The entities are spread over different jar files in lib directory and the discovery is done by Spring. Spring correctly scans the jar files containing persistence files ( in our case its NOT named persistence.xml) and entities and hands the jar files to the Hibernate entity manager scanner so that it can look for entities. The jar urls begin with prefix "vfs". However the hibernate default scanner org.hibernate.ejb.packaging.NativeScanner fails to recognize the vfs files and ignores the jar files containing entities and the application server throw "Entity not mapped" exception. So the culprit seems to be the hibernate in this case. I can say this because Spring has vfs related handling from version 3 onwards. Spring obviously can correcltly load its classes from vfs path url's which contain Spring specific annotations.
The solution seems to use org.jboss.as.jpa.hibernate.HibernateAnnotationScanner via hibernate.ejb.resource_scanner property, but I doubt I can use that without including JBoss dependencies which I cannot do. Is this issue really a Hibernate issue ?
Till now we had managed to deploy the exploded war file by using a bit of a hack. We had extended hibernate NativeScanner and whenever the path contained "vfs" we changed it to "file" so that Hibernate can understand that. The limitation was obviously that we could not deploy war but only exploded war.
Similar issue was reported at Hibernate entity scanning with JBoss6 and Seam, and I had posted my query but the various answers seemed to be more pointing blame to framework instead of
giving any concrete solution. Mind you - The same setup works absolutely fine in Tomcat, Jetty and Weblogic.