I try to use tomcat 7 with hibernate 4.x I got an Naming exception on getting dataSource with javax.naming.Name. Works when search with string. But hibernate migrate to Name in their code. See: https://hibernate.onjira.com/browse/HHH-7012
Doesn't work with a javax.naming.Name create with key "java:comp/env/jdbc/mydb" If you look at http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/SelectorContext.java?revision=1225625&view=markup You could see that prefix is only "java:" and protected Name parseName(Name name) return name.getSuffix(1)
Fixed in trunk and 7.0.x and will be included in 7.0.27 onwards. Thanks for the report.
The same bug happen on Tomcat 6.
Re-opening to fix in Tomcat 6.
Fix proposed for 6.0.x.
Regarding the patch - r1298635 - I see one minor (theoretical?) issue. It calls Name result = new CompositeName(); .. result.addAll(name.getSuffix(1)); Looking at CompositeName#addAll(Name) in Java 6u31 I see that it expects that (Name instanceof CompositeName) and throws InvalidNameException if it is not. With a generic Name.getSuffix(int) that is not true. Though I do not see how other name implementations could be used here. Here is alternative implementation of the fix: TestNamingContext passes with it as well. [[[ Name result = name.getSuffix(1); result.add(0, name.get(0).substring(prefixLength)); return result; ]]]
(In reply to comment #6) I've applied this alternative implementation in r1304468 (trunk), r1304471 (TC7)
Fixed in 6.0.x and will be included in 6.0.36 onwards.
on tomcat 7.0.29, with hibernate 4.1.5 final, i get the same error when defining my jdbc/mbsousdb in web.xml and context.xml then using <non-jta-data-source>java:/comp/env/jdbc/mbsousdb</non-jta-data-source> in persistence.xml. I tried jdbc/mbsousdb, java:comp/env/jdbc/mbsousdb an java:/comp//env/jdbc/mbsousdb, without success.
Bugzilla is not a support forum and there is insufficient information in comment #9 to determine if there is a bug or if it is just a configuration error. Please follow-up on the users mailing list and only re-open this issue if it is determined there is still a bug to fix. If you do re-open this issue, you'll need to provide a test case (ideally the simplest web application possible - i.e. without hibernate) that demonstrates the issue. The simpler the tets case, the easier it will be for the developers to investigate,