-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem with Quickstart Could not find datasource
PostPosted: Sun Sep 26, 2004 11:40 am 
Newbie

Joined: Sun Sep 26, 2004 11:04 am
Posts: 1
I've already looks through the postings doing a search for quickstart but did not find anything helpful. Can someone help out a newbie here? Thanks in advance :)

Hibernate version:2.1

Mapping documents:
User.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://localhost/dtds/hibernate-mapping-2.0.dtd">
<hibernate-mapping>

<class name="dummies.struts.User" table="User">
<id name="id" type="string" unsaved-value="null">
<column name="ID" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>

<property name="userName">
<column name="USER_NAME" length="16" not-null="true"/>
</property>

<property name="password">
<column name="PASSWORD" length="16" not-null="true"/>
</property>
</class>

</hibernate-mapping>

hibernate.cfg.xml
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://localhost/dtds/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/Login</property>
<property name="show_sql">false</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

<mapping resource="User.hbm.xml"/>

</session-factory>
</hibernate-configuration>

server.xml excerpt
<Context path="/Login" docBase="Login">
<Resource name="jdbc/Login" scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/Login">

<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<!-- DBCP database connection settings -->
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/logindb</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>
</parameter>
<parameter>
<name>username</name>
<value>username</value>
</parameter>
<parameter>
<name>password</name>
<value>password</value>
</parameter>
<!-- DBCP connection pooling options -->
<parameter>
<name>maxWait</name>
<value>3000</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>100</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
</ResourceParams>
</Context>


Code between sessionFactory.openSession() and session.close():
try
{
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
User user = new User();
user.setUserName("administrator");
user.setPassword("password");
session.save(user);
tx.commit();
HibernateUtil.closeSession();
}
catch (HibernateException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}

Full stack trace of any exception that occurs:
Sep 26, 2004 11:28:53 PM net.sf.hibernate.connection.DatasourceConnectionProvider configure
SEVERE: Could not find datasource: java:comp/env/jdbc/Login
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:768)
at org.apache.naming.NamingContext.lookup(NamingContext.java:138)
at org.apache.naming.NamingContext.lookup(NamingContext.java:779)
at org.apache.naming.NamingContext.lookup(NamingContext.java:138)
at org.apache.naming.NamingContext.lookup(NamingContext.java:779)
at org.apache.naming.NamingContext.lookup(NamingContext.java:151)
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:65)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1155)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:789)
at dummies.struts.util.HibernateUtil.<clinit>(HibernateUtil.java:26)
at dummies.struts.LoginBean.<init>(LoginBean.java:27)
at dummies.struts.LoginAction.execute(LoginAction.java:35)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1158)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
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.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)


Name and version of the database you are using:

database: mysql-4.0.20d-win
connector: mysql-connector-java-3.0.14-production


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.