title: JPA entities as a shareable jar not working in a WAR file unde Tomcat 7.0.27
body: <p>i tried to share my entities in a JPA 2.0 project in eclipse Juno, ´cause i´m creating a test project and i need to access then there to make my tests and if i create any other project a can reuse those entities.</p>
  
  <p>The biggest problem is that hibernate ( 4.1.9 ) can find my jar in a relative path, but the most strange is that in my test project using only Spring 3 hibernate read my entities jar and hbm files perfectly. But when i try to do the same with the real project using tomcat 7.0.27 it can locale where the jar is, my real project is a common WAR file in tomcat and with Spring 3. Here is my persistence.xml of real project:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.0"
  xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&gt;
  &lt;persistence-unit name="CustomerServiceMacrosUnit"
      transaction-type="RESOURCE_LOCAL"&gt;
      &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
      &lt;!-- the JNDI data source --&gt;
      &lt;non-jta-data-source&gt;java:comp/env/jdbc/CustomerServiceMacrosDS&lt;/non-jta-data-source&gt;
  
      &lt;jar-file&gt;../lib/aliancaModel.jar&lt;/jar-file&gt;
  
      &lt;shared-cache-mode&gt;ENABLE_SELECTIVE&lt;/shared-cache-mode&gt;
  </code></pre>
  
  <p>And here is my jar persistence with all classes mapped:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;persistence version="2.0"
  xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org   /2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&gt;
  &lt;persistence-unit name="AliancaJPA"&gt;
         &lt;class&gt;br.com.alianca.customerservicemacros.entity.controlefaturas.DocsysBl&lt;/class&gt;
         &lt;class&gt;br.com.alianca.customerservicemacros.entity.controlefaturas.DocsysBooking&lt;/class&gt;
        &lt;class&gt;br.com.alianca.customerservicemacros.entity.controlefaturas.DocsysCharge&lt;/class&gt;
         &lt;class&gt;br.com.alianca.customerservicemacros.entity.controlefaturas.DocsysContainer&lt;/class&gt;
  
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is the error from tomcat´s log:</p>
  
  <pre><code>INFO: Initializing Spring root WebApplicationContext
  28/03/13 12:00  INFO org.hibernate.annotations.common.Version:37
  HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
  28/03/13 12:00  INFO org.hibernate.Version:41
  HHH000412: Hibernate Core {4.1.9.Final}
  28/03/13 12:00  INFO org.hibernate.cfg.Environment:239
  HHH000206: hibernate.properties not found
  28/03/13 12:00  INFO org.hibernate.cfg.Environment:342
  HHH000021: Bytecode provider name : javassist
  28/03/13 12:01  WARN org.hibernate.ejb.packaging.FileZippedJarVisitor:74
  HHH015010: Unable to find file (ignored): file:../lib/aliancaModel.jar
  java.io.FileNotFoundException: ..\lib\aliancaModel.jar (The system cannot find the path specified)
  at java.util.zip.ZipFile.open(Native Method)
  at java.util.zip.ZipFile.&lt;init&gt;(ZipFile.java:127)
  at java.util.jar.JarFile.&lt;init&gt;(JarFile.java:135)
  at java.util.jar.JarFile.&lt;init&gt;(JarFile.java:72)
  at org.hibernate.ejb.packaging.FileZippedJarVisitor.doProcessElements(FileZippedJarVisitor.java:70)
  at org.hibernate.ejb.packaging.AbstractJarVisitor.getMatchingEntries(AbstractJarVisitor.java:149)
  at org.hibernate.ejb.packaging.NativeScanner.getClassesInJar(NativeScanner.java:128)
  at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:485)
  at org.hibernate.ejb.Ejb3Configuration.addMetadataFromScan(Ejb3Configuration.java:475)
  at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:371)
  at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
  at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
  at org.springframework.orm.jpa.LocalEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalEntityManagerFactoryBean.java:92)
  at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1525)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1463)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
  at org.springframework.orm.jpa.EntityManagerFactoryUtils.findEntityManagerFactory(EntityManagerFactoryUtils.java:99)
  at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findNamedEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:512)
  at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:494)
  at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:659)
  at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:630)
  at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:155)
  at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:92)
  at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:340)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1117)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:605)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
  at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
  at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
  at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
  at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
  at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566)
  at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556)
  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
  at java.lang.Thread.run(Thread.java:662)
  </code></pre>
  
  <p>Using the debug, i could force hibernate to locale the jar with full path in my filesystem, but even using the resource it couldn´t find my hbms!</p>
  
  <p>I starting to think that it can only work wit EAR files! :(
  Can someone give some point?</p>