Unable to build EntityManagerFactory with not-JTA Datasource

Description

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
at org.apache.naming.SelectorContext.parseName(SelectorContext.java:776)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:135)
at javax.naming.InitialContext.lookup(InitialContext.java:415)
at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:65)
... 42 more

Environment

Tomcat 7, Java 7, Hibernate 4.x, Servlet 3.0

Assignee

Unassigned

Reporter

W

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure