Greetings,
I am working on the quickstart and I have my web app in Tomcat 5.5 (I MUST use 5.5 for the project.) For some reason Hibernate gets hit with a JNDI exception when it tries to create the session factory.
The message in the log is ...
- Could not find datasource: java:comp/env/jdbc/CandiedServices
What am I doing wrong here?
TIA
Hibernate version:
Current
Tomcat Documents:
server.xml
Code:
<?xml version='1.0' encoding='utf-8'?>
<Server>
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase" pathname="conf/tomcat-users.xml" factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
<Resource name="jdbc/CandiedServices" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" password="resUSC" maxIdle="2" maxWait="5000" username="CSUser" url="jdbc:mysql://localhost/CandiedServices" maxActive="4"/>
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080" redirectPort="8443" maxSpareThreads="75" maxThreads="150" minSpareThreads="25">
</Connector>
<Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8443">
</Connector>
<Engine defaultHost="localhost" name="Catalina">
<Host appBase="webapps" name="localhost">
</Host>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
</Engine>
</Service>
</Server>
Mapping documents:hibernate.cfg.xmlCode:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/CandiedServices</property>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<!-- Mapping files -->
<mapping resource="data.hbm.xml" />
</session-factory>
</hibernate-configuration>
data.hbm.xmlCode:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping schema="CandiedServices"
package="com.bmw.candy.candiedServices.data">
<class name="Subscription" table="SUBSCRIPTION">
<id name="ID" type="long" unsaved-value="null" column="ID">
<generator class="native" />
</id>
<property name="name" length="16" not-null="true" />
<property name="sequenceNum" />
<list name="items" table="SUBSCRIPTION_ITEMS" lazy="true">
<key column="_itemID" />
<index column="_position"/>
<element type="string" length="1024" not-null="true" />
</list>
</class>
<class name="SubscriberInfo" table="SUBSCRIBER_INFO" lazy="true">
<id name="ID" type="long" unsaved-value="null" column="ID">
<generator class="native" />
</id>
<property name="username" length="15" not-null="true" />
<property name="password" length="30" not-null="true" />
<property name="familyName" length="30" not-null="true" />
<property name="givenName" length="30" not-null="true" />
<set name="subscriptions" table="SUBSCRIBER_SUBSCRIPTIONS">
<key column="_statusID" />
<composite-element class="SubscriptionStatus">
<property name="lastSequenceNumber" />
<many-to-one name="subscription"/>
</composite-element>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Using HibernateUtil pattern as specified in Quickstart.
Full stack trace of any exception that occurs:
javax.naming.NameNotFoundException: :\Dokumente und Einstellungen\robert\Eigene Dateien
at org.apache.naming.NamingContext.lookup(NamingContext.java:769)
at org.apache.naming.NamingContext.lookup(NamingContext.java:139)
at org.apache.naming.NamingContext.lookup(NamingContext.java:780)
at org.apache.naming.NamingContext.lookup(NamingContext.java:139)
at org.apache.naming.NamingContext.lookup(NamingContext.java:780)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:136)
at javax.naming.InitialContext.lookup(Unknown Source)
at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:76)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1160)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:794)
at com.bmw.candy.candiedServices.HibernateUtil.<clinit>(HibernateUtil.java:39)
at com.bmw.candy.candiedServices.SubscriptionAccess.listAvailableSubscriptions(SubscriptionAccess.java:48)
at org.apache.jsp.JSPs.AdminSubscriptions_jsp._jspService(org.apache.jsp.JSPs.AdminSubscriptions_jsp:92)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
- Servlet.service() for servlet jsp threw exception
java.lang.Error: net.sf.hibernate.HibernateException: Could not find datasource
at com.bmw.candy.candiedServices.HibernateUtil.<clinit>(HibernateUtil.java:41)
at com.bmw.candy.candiedServices.SubscriptionAccess.listAvailableSubscriptions(SubscriptionAccess.java:48)
at org.apache.jsp.JSPs.AdminSubscriptions_jsp._jspService(org.apache.jsp.JSPs.AdminSubscriptions_jsp:92)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Caused by: net.sf.hibernate.HibernateException: Could not find datasource
at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:48)
at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:76)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1160)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:794)
at com.bmw.candy.candiedServices.HibernateUtil.<clinit>(HibernateUtil.java:39)
... 22 more
Caused by: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:769)
at org.apache.naming.NamingContext.lookup(NamingContext.java:139)
at org.apache.naming.NamingContext.lookup(NamingContext.java:780)
at org.apache.naming.NamingContext.lookup(NamingContext.java:139)
at org.apache.naming.NamingContext.lookup(NamingContext.java:780)
at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:136)
at javax.naming.InitialContext.lookup(Unknown Source)
at net.sf.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
... 27 more
- Servlet.service() for servlet jsp threw exception
java.lang.NoClassDefFoundError
at com.bmw.candy.candiedServices.SubscriptionAccess.listAvailableSubscriptions(SubscriptionAccess.java:48)
at org.apache.jsp.JSPs.AdminSubscriptions_jsp._jspService(org.apache.jsp.JSPs.AdminSubscriptions_jsp:92)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Name and version of the database you are using:
MySQL Essentials 4.x
The generated SQL (show_sql=true):
NA
Debug level Hibernate log excerpt:
NA