[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-7012) Jndi lookup doesn't found datasource with tomcat

Steve Ebersole (JIRA) noreply at atlassian.com
Mon Mar 5 11:48:49 EST 2012


    [ https://hibernate.onjira.com/browse/HHH-7012?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45832#comment-45832 ] 

Steve Ebersole commented on HHH-7012:
-------------------------------------

Well we only ever need to use the {{Name}} variant when we have to perform binding.  For just doing look ups, the {{String}} variant is fine.  If multiple JNDI implementations have problems with their {{NameParser}} it might be better to switch back to the {{String}} variant for look ups.  I just switched for consistency, but obviously a working solution that accounts for seeming bugs on various platforms trumps consistency :(

If I had to guess, probably the NameParser returned from getNameParser( "" ) for the impls that fall down here are "rooted" at {{java:comp/env}} and does not recognize that as a prefix when passing in the full {{java:comp/env/jdbc/myCompDb}} string.  Kind of retarded NameParser implementation if you ask me, but oh well.  If that is the case, you should be able to name your datasource as {{jdbc/myCompDb}} to Hibernate and this code should then resolve correctly.  

> Jndi lookup doesn't found datasource with tomcat
> ------------------------------------------------
>
>                 Key: HHH-7012
>                 URL: https://hibernate.onjira.com/browse/HHH-7012
>             Project: Hibernate ORM
>          Issue Type: Bug
>    Affects Versions: 4.0.1
>         Environment: oracle 10g, tomcat 7
>            Reporter: Mathevet
>
> I migrate my application from hibernate 3 to 4, but at startup I got an exception that I couldn't get datasource. Seem that InitialContext is empty. I let tomcat manages connection.
> Caused by: org.hibernate.service.jndi.JndiException: Unable to lookup JNDI name [java:comp/env/jdbc/myCompDb]
>    at org.hibernate.service.jndi.internal.JndiServiceImpl.locate(JndiServiceImpl.java:68)
>    at org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl.configure(DatasourceConnectionProviderImpl.java:116)
> I ask on forum at:
> https://forum.hibernate.org/viewtopic.php?f=1&t=1013101

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list