When upgrading from Hibernate 3.6.x to Hibernate 4.x it is not possible to create an entity manager factory using a non-JTA Datasource in persistence.xml. When looking up the datasource with JNDI a "javax.naming.NamingException: This context must be accessed through a java: URL" exception is thrown. Debugging the source code we can see that in 3.6.x the lookup is done with "javax.naming.lookup(String)" but in 4.x it is done with "javax.naming.lookup(Name)" which fails.
The attached file is a test case. To reproduce, do the following:
1. Build the project with Maven
2. Deploy to Tomcat
3. Go to /hibernate-test/test
Result: All database records are shown in browser
Now, in pom.xml file, change hibernate.core.version property from 3.6.10.Final to 4.1.0.Final.
Repeat above steps.
Result: an exception stack trace is displayed which ends with:
Caused by: javax.naming.NamingException: This context must be accessed through a java: URL
... 42 more
Tomcat 7, Java 7, Hibernate 4.x, Servlet 3.0