title: Jboss JNDI name not found in hibernate configuration with Spring MVC
body: <p>I recently migrated from Struts 1.2 to Spring MVC. I am trying to deploy ear in Jboss 7.1.1, and starting application from Scratch instead of using Action classes from Struts. I am using Hibernate as ORM tool for application.</p>
  
  <p>Earlier in Struts application, JNDI datasource lookup by hibernate configuration was no issue. But for some reason, the same configuration does not seem to work with Spring. I am getting following error again and again:</p>
  
  <p>Caused by: javax.naming.NameNotFoundException: env/oraclePool -- service jboss.naming.context.java.module.ExecEngine."ExecEngine.war".env.oraclePool</p>
  
  <p>The datasource in Jboss is configured in following way:</p>
  
  <p>&lt;datasource jndi-name="java:/oraclePool" pool-name="oraclePool" enabled="true" use-java-context="true"> ........ 
  &lt;/datasource></p>
  
  <p>And hibernate configuration being used in hibernate.cfg.xml is:</p>
  
  <p>&lt;property name="connection.datasource">java:comp/env/oraclePool&lt;/property></p>
  
  <p>The name of the ear which I am trying to deploy is ExecEngine.ear having war and jar with the same name. The structure of this ear is:</p>
  
  <ul>
  <li>META-INF folder having MANIFEST.MF and application.xml</li>
  <li>lib folder</li>
  <li>ExecEngine.jar</li>
  <li>ExecEngine.war having WEB-INF folder which contains spring-servlet.xml and web.xml.</li>
  </ul>