tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <yucca...@live.co.za>
Subject hibernate not finding global resource datasource defined by tomcat
Date Mon, 14 Jun 2010 20:26:02 GMT
Hello tomcats!! 

Please advise as to why hibernate us unable to find jndi datasource configured in tomcat?

Trying 2 different setups here:

1) server.xml resource as follows:

<GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
      <Resource
        name="jdbc/auth"
        description="The Jar Bar user authentication"
        type="javax.sql.DataSource"
        auth="Container"
        driverClassName="com.mysql.jdbc.Driver"
        maxActive="30" maxIdle="10"
        maxWait="10000"
        password="myPass"
        url="jdbc:mysql://localhost:3306/yucca123_thejarbar"
        validationQuery="/* ping */ SELECT 1"
        username="yucca123_tom"/>



  </GlobalNamingResources>

throws:
Jun 14, 2010 10:13:20 PM org.apache.catalina.core.ApplicationContext log
Jun 14, 2010 10:13:20 PM org.apache.catalina.core.ApplicationContext log
Jun 14, 2010 10:13:46 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
 at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
 at org.apache.naming.SelectorContext.lookup(SelectorContext.java:152)
 at javax.naming.InitialContext.lookup(InitialContext.java:392)
 at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
 at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
 at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
 at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414)
 at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
 at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
 at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
 at org.bar.jar.util.HibernateUtil.<clinit>(HibernateUtil.java:24)
 at org.bar.jar.backing.TutorialIndexBacking.getAllUnflaggedComments(TutorialIndexBacking.java:21)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
 at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
 at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
 at org.apache.el.parser.AstValue.getValue(AstValue.java:123)
 at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
 at org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
 at javax.faces.component.UIData.getValue(UIData.java:609)
 at javax.faces.component.UIData.getDataModel(UIData.java:1124)
 at javax.faces.component.UIData.setRowIndex(UIData.java:451)
 at com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:77)
 at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
 at javax.faces.component.UIData.encodeBegin(UIData.java:962)
 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:928)
 at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
 at com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:266)
 at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:197)
 at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
 at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
 at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:465)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
 at java.lang.Thread.run(Thread.java:619)


with hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="connection.url">jdbc:mysql://localhost:3306/yucca123_thejarbar</property>
      <property name="hibernate.connection.datasource">java:comp/env/jdbc/auth"</property>
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="connection.username">yucca123_tom</property>
      <property name="current_session_context_class">thread</property>
    <property name="connection.password">pookie123</property>
      <mapping resource="org/bar/jar/model/UserRolesEntity.hbm.xml"/>
      <mapping resource="org/bar/jar/model/UsercommentsEntity.hbm.xml"/>
      <mapping resource="org/bar/jar/model/UsersEntity.hbm.xml"/>
      <!-- DB schema will be updated if needed -->
    <!-- <property name="hbm2ddl.auto">update</property> -->
  </session-factory>
</hibernate-configuration>

so I try 

2) moving resource and realm element to context.xml with adding localdatasource attribute
to  resource (true) and get same exception?

What am I missing here?

tomcat is latest 6.0.26
mysql 5 with global connector (inside common/lib)

Ideally I want the global(server.xml) config for the resource as it WILL be shared among deployed
applications, but because this is first application I am willing to use just contect configured
resource.




Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message