|Summary:||DataSource JNDI lookup with javax.naming.Name failed|
|Product:||Tomcat 7||Reporter:||moogle <easyrasta>|
|Component:||Catalina||Assignee:||Tomcat Developers Mailing List <dev>|
Description moogle 2012-03-05 15:25:49 UTC
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
Comment 1 moogle 2012-03-06 09:57:15 UTC
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)
Comment 2 Mark Thomas 2012-03-08 22:44:45 UTC
Fixed in trunk and 7.0.x and will be included in 7.0.27 onwards. Thanks for the report.
Comment 3 La Chamelle 2012-03-12 18:20:16 UTC
The same bug happen on Tomcat 6.
Comment 4 Mark Thomas 2012-03-12 19:52:17 UTC
Re-opening to fix in Tomcat 6.
Comment 5 Mark Thomas 2012-03-12 19:53:46 UTC
Fix proposed for 6.0.x.
Comment 6 Konstantin Kolinko 2012-03-21 00:47:51 UTC
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; ]]]
Comment 7 Konstantin Kolinko 2012-03-23 16:44:30 UTC
(In reply to comment #6) I've applied this alternative implementation in r1304468 (trunk), r1304471 (TC7)
Comment 8 Mark Thomas 2012-06-29 19:38:24 UTC
Fixed in 6.0.x and will be included in 6.0.36 onwards.
Comment 9 sebastien michea 2012-07-23 05:47:11 UTC
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.
Comment 10 Mark Thomas 2012-07-24 16:34:40 UTC
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,