You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Fabian Dittrich <fa...@gmail.com> on 2006/12/18 12:01:21 UTC

DB-Connection

Hi tapestry-users,

before i used a file in conf/catalina/localhost/ to configure my
db-connection there in an xml file, like this:

<Context
docBase="c:/workspace/MCG/context"
path="/MCG"
reloadable="true">


    <Resource name="jdbc/bankDataSource" auth="Container"
        type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver "

        url="jdbc:mysql://localhost/MCG" username="root"
        password="" maxActive="20" defaultAutoCommit="false"
        timeBetweenEvictionRunsMillis="60000" />
</Context>


Now i want to deploy my app directly into Tomcat/webapps

Anyone knows where to put the settings for the db-connection now?

Thanks for any advice

Fabian

Re: DB-Connection

Posted by Shing Hing Man <ma...@yahoo.com>.
In your hibernate.cfg.xml,
 Have you set the property connection.datasource to
the 
data source ?
Something like :

<property
name="connection.datasource">java:comp/env/jdbc/bankDataSource</property>

Also don't forget to include <resource-ref> in web.xml
for your data source.

Shing


--- Fabian Dittrich <fa...@gmail.com> wrote:

> I tried to put the context.xml file in META-INF
> 
> The file is like:
> <?xml version="1.0" encoding="UTF-8"?>
> 
> <Context>
> 
>     <Resource name="jdbc/bankDataSource"
> auth="Container"
>         type=" javax.sql.DataSource"
> driverClassName="com.mysql.jdbc.Driver"
>         url="jdbc:mysql://localhost/MCG"
> username="root"
>         password="" maxActive="20"
> defaultAutoCommit="false"
>         timeBetweenEvictionRunsMillis="60000" />
> 
> </Context>
> 
> I get following error:
> 
> An exception has occurred.
> 
> You may continue by
>
*restarting<http://localhost:8080/mcgWebapps/app?service=restart>
> * the session.
> 
>  org.apache.hivemind.ApplicationRuntimeException 
> Unable to construct
> service
> com.nuromobile.accounting.hibernate.SessionCreator:
> Unable to
> instantiate instance of class
>
com.nuromobile.accounting.hibernate.DefaultSessionCreator:
> Could not find
> datasource  location:
>
file:/C:/Programming/Tomcat5.5/webapps/mcgWebapps/WEB-INF/classes/META-INF/hivemodule.xml,
> line 6, column 52
> 1<?xml version="1.0"?> 2<module
> id="com.nuromobile.accounting.hibernate"
> version="1.0.0"> 3
> 4
> 5 <service-point id="SessionCreator"> 6
> <create-instance
> class="DefaultSessionCreator" /> 7 </service-point>
> 8 <service-point
> id="SessionOwner"> 9 <invoke-factory
> model="threaded"> 10 <construct
> class="DefaultSessionOwner" /> 11 </invoke-factory>
> org.apache.hivemind.ApplicationRuntimeException 
> Unable to instantiate
> instance of class
>
com.nuromobile.accounting.hibernate.DefaultSessionCreator:
> Could not find datasource  location:
>
file:/C:/Programming/Tomcat5.5/webapps/mcgWebapps/WEB-INF/classes/META-INF/hivemodule.xml,
> line 6, column 52
> 1<?xml version="1.0"?> 2<module
> id="com.nuromobile.accounting.hibernate"
> version="1.0.0"> 3
> 4
> 5 <service-point id="SessionCreator"> 6
> <create-instance
> class="DefaultSessionCreator" /> 7 </service-point>
> 8 <service-point
> id="SessionOwner"> 9 <invoke-factory
> model="threaded"> 10 <construct
> class="DefaultSessionOwner" /> 11 </invoke-factory>
> org.hibernate.HibernateException  Could not find
> datasource  messages:
> 
>    - Could not find datasource
>    - Cannot create resource instance
> 
>  throwableCount: 2  throwables:
> 
>    - org.hibernate.HibernateException: Could not
> find datasource
>    - javax.naming.NamingException: Cannot create
> resource instance
> 
>       javax.naming.NamingException  Cannot create
> resource instance  Stack
> Trace:
> 
>    -
>
org.apache.naming.factory.ResourceFactory.getObjectInstance(
>    ResourceFactory.java:142)
>    -
>
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
> 
>    -
>
org.apache.naming.NamingContext.lookup(NamingContext.java:792)
>    -
>
org.apache.naming.NamingContext.lookup(NamingContext.java:139)
>    -
>
org.apache.naming.NamingContext.lookup(NamingContext.java:780)
>    -
>
org.apache.naming.NamingContext.lookup(NamingContext.java:139)
>    -
>
org.apache.naming.NamingContext.lookup(NamingContext.java:780)
>    -
>
org.apache.naming.NamingContext.lookup(NamingContext.java:139)
>    -
>
org.apache.naming.NamingContext.lookup(NamingContext.java:780)
>    -
>
org.apache.naming.NamingContext.lookup(NamingContext.java:152)
>    -
>
org.apache.naming.SelectorContext.lookup(SelectorContext.java:136)
>    -
>
javax.naming.InitialContext.lookup(InitialContext.java:351)
>    -
>
org.hibernate.connection.DatasourceConnectionProvider.configure(
>    DatasourceConnectionProvider.java:52)
>    -
>   
>
org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider
>    (ConnectionProviderFactory.java:124)
>    -
>   
>
org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider
>    (ConnectionProviderFactory.java:56)
>    -
>
org.hibernate.cfg.SettingsFactory.createConnectionProvider(
>    SettingsFactory.java:397)
>    -
>
org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
> 
>    -
>
org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
> 
>    -
> org.hibernate.cfg.Configuration.buildSessionFactory(
>    Configuration.java:1216)
>    -
>
com.nuromobile.accounting.hibernate.DefaultSessionCreator.<init>(
>    DefaultSessionCreator.java:24)
>    -
>
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>    Method)
>    -
>
sun.reflect.NativeConstructorAccessorImpl.newInstance(
>    NativeConstructorAccessorImpl.java:39)
>    -
>
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
>    DelegatingConstructorAccessorImpl.java:27)
>    -
>
java.lang.reflect.Constructor.newInstance(Constructor.java:494)
>    - java.lang.Class.newInstance0(Class.java:350)
>    - java.lang.Class.newInstance(Class.java:303)
>    -
>
org.apache.hivemind.util.InstanceCreationUtils.createInstance(
>    InstanceCreationUtils.java:54)
>    -
>   
>
org.apache.hivemind.impl.CreateClassServiceConstructor.constructCoreServiceImplementation
>    (CreateClassServiceConstructor.java:35)
>    -
>   
>
org.apache.hivemind.impl.servicemodel.AbstractServiceModelImpl.constructCoreServiceImplementation
>    (AbstractServiceModelImpl.java:107)
>    -
>   
>
org.apache.hivemind.impl.servicemodel.AbstractServiceModelImpl.constructNewServiceImplementation
>    (AbstractServiceModelImpl.java:157)
>    -
>   
>
org.apache.hivemind.impl.servicemodel.AbstractServiceModelImpl.constructServiceImplementation
>    (AbstractServiceModelImpl.java:139)
>    -
>   
>
org.apache.hivemind.impl.servicemodel.SingletonServiceModel.getActualServiceImplementation
>    (SingletonServiceModel.java:68)
>    -
>
$SessionCreator_10f96499be7._service($SessionCreator_10f96499be7.java)
> 
>    -
>
$SessionCreator_10f96499be7.createSession($SessionCreator_10f96499be7.java)
> 
>    -
>
$SessionCreator_10f96499be6.createSession($SessionCreator_10f96499be6.java)
> 
>    -
>
com.nuromobile.accounting.hibernate.DefaultSessionOwner.getSession(
>    DefaultSessionOwner.java:17)
>    -
>
$SessionOwner_10f96499be0.getSession($SessionOwner_10f96499be0.java)
> 
>    -
>
$SessionOwner_10f96499be1.getSession($SessionOwner_10f96499be1.java)
> 
>    -
>
com.nuromobile.accounting.views.SuperView.getNumberOfResults(
>    SuperView.java:94)
>    -
>
com.nuromobile.accounting.views.SuperView.access$0(SuperView.java:92)
> 
>    -
>
com.nuromobile.accounting.views.SuperView$1.getRowCount(
>    SuperView.java:44)
>    -
>   
>
org.apache.tapestry.contrib.table.model.common.BasicTableModelWrap.getRowCount
> 
=== message truncated ===


Home page :
  http://uk.geocities.com/matmsh/index.html


		
___________________________________________________________ 
The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: DB-Connection

Posted by Fabian Dittrich <fa...@gmail.com>.
I tried to put the context.xml file in META-INF

The file is like:
<?xml version="1.0" encoding="UTF-8"?>

<Context>

    <Resource name="jdbc/bankDataSource" auth="Container"
        type=" javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver"
        url="jdbc:mysql://localhost/MCG" username="root"
        password="" maxActive="20" defaultAutoCommit="false"
        timeBetweenEvictionRunsMillis="60000" />

</Context>

I get following error:

An exception has occurred.

You may continue by
*restarting<http://localhost:8080/mcgWebapps/app?service=restart>
* the session.

 org.apache.hivemind.ApplicationRuntimeException  Unable to construct
service com.nuromobile.accounting.hibernate.SessionCreator: Unable to
instantiate instance of class
com.nuromobile.accounting.hibernate.DefaultSessionCreator: Could not find
datasource  location:
file:/C:/Programming/Tomcat5.5/webapps/mcgWebapps/WEB-INF/classes/META-INF/hivemodule.xml,
line 6, column 52
1<?xml version="1.0"?> 2<module id="com.nuromobile.accounting.hibernate"
version="1.0.0"> 3
4
5 <service-point id="SessionCreator"> 6 <create-instance
class="DefaultSessionCreator" /> 7 </service-point> 8 <service-point
id="SessionOwner"> 9 <invoke-factory model="threaded"> 10 <construct
class="DefaultSessionOwner" /> 11 </invoke-factory>
org.apache.hivemind.ApplicationRuntimeException  Unable to instantiate
instance of class com.nuromobile.accounting.hibernate.DefaultSessionCreator:
Could not find datasource  location:
file:/C:/Programming/Tomcat5.5/webapps/mcgWebapps/WEB-INF/classes/META-INF/hivemodule.xml,
line 6, column 52
1<?xml version="1.0"?> 2<module id="com.nuromobile.accounting.hibernate"
version="1.0.0"> 3
4
5 <service-point id="SessionCreator"> 6 <create-instance
class="DefaultSessionCreator" /> 7 </service-point> 8 <service-point
id="SessionOwner"> 9 <invoke-factory model="threaded"> 10 <construct
class="DefaultSessionOwner" /> 11 </invoke-factory>
org.hibernate.HibernateException  Could not find datasource  messages:

   - Could not find datasource
   - Cannot create resource instance

 throwableCount: 2  throwables:

   - org.hibernate.HibernateException: Could not find datasource
   - javax.naming.NamingException: Cannot create resource instance

      javax.naming.NamingException  Cannot create resource instance  Stack
Trace:

   - org.apache.naming.factory.ResourceFactory.getObjectInstance(
   ResourceFactory.java:142)
   - javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)

   - org.apache.naming.NamingContext.lookup(NamingContext.java:792)
   - org.apache.naming.NamingContext.lookup(NamingContext.java:139)
   - org.apache.naming.NamingContext.lookup(NamingContext.java:780)
   - org.apache.naming.NamingContext.lookup(NamingContext.java:139)
   - org.apache.naming.NamingContext.lookup(NamingContext.java:780)
   - org.apache.naming.NamingContext.lookup(NamingContext.java:139)
   - org.apache.naming.NamingContext.lookup(NamingContext.java:780)
   - org.apache.naming.NamingContext.lookup(NamingContext.java:152)
   - org.apache.naming.SelectorContext.lookup(SelectorContext.java:136)
   - javax.naming.InitialContext.lookup(InitialContext.java:351)
   - org.hibernate.connection.DatasourceConnectionProvider.configure(
   DatasourceConnectionProvider.java:52)
   -
   org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider
   (ConnectionProviderFactory.java:124)
   -
   org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider
   (ConnectionProviderFactory.java:56)
   - org.hibernate.cfg.SettingsFactory.createConnectionProvider(
   SettingsFactory.java:397)
   - org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)

   - org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)

   - org.hibernate.cfg.Configuration.buildSessionFactory(
   Configuration.java:1216)
   - com.nuromobile.accounting.hibernate.DefaultSessionCreator.<init>(
   DefaultSessionCreator.java:24)
   - sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
   Method)
   - sun.reflect.NativeConstructorAccessorImpl.newInstance(
   NativeConstructorAccessorImpl.java:39)
   - sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
   DelegatingConstructorAccessorImpl.java:27)
   - java.lang.reflect.Constructor.newInstance(Constructor.java:494)
   - java.lang.Class.newInstance0(Class.java:350)
   - java.lang.Class.newInstance(Class.java:303)
   - org.apache.hivemind.util.InstanceCreationUtils.createInstance(
   InstanceCreationUtils.java:54)
   -
   org.apache.hivemind.impl.CreateClassServiceConstructor.constructCoreServiceImplementation
   (CreateClassServiceConstructor.java:35)
   -
   org.apache.hivemind.impl.servicemodel.AbstractServiceModelImpl.constructCoreServiceImplementation
   (AbstractServiceModelImpl.java:107)
   -
   org.apache.hivemind.impl.servicemodel.AbstractServiceModelImpl.constructNewServiceImplementation
   (AbstractServiceModelImpl.java:157)
   -
   org.apache.hivemind.impl.servicemodel.AbstractServiceModelImpl.constructServiceImplementation
   (AbstractServiceModelImpl.java:139)
   -
   org.apache.hivemind.impl.servicemodel.SingletonServiceModel.getActualServiceImplementation
   (SingletonServiceModel.java:68)
   - $SessionCreator_10f96499be7._service($SessionCreator_10f96499be7.java)

   - $SessionCreator_10f96499be7.createSession($SessionCreator_10f96499be7.java)

   - $SessionCreator_10f96499be6.createSession($SessionCreator_10f96499be6.java)

   - com.nuromobile.accounting.hibernate.DefaultSessionOwner.getSession(
   DefaultSessionOwner.java:17)
   - $SessionOwner_10f96499be0.getSession($SessionOwner_10f96499be0.java)

   - $SessionOwner_10f96499be1.getSession($SessionOwner_10f96499be1.java)

   - com.nuromobile.accounting.views.SuperView.getNumberOfResults(
   SuperView.java:94)
   - com.nuromobile.accounting.views.SuperView.access$0(SuperView.java:92)

   - com.nuromobile.accounting.views.SuperView$1.getRowCount(
   SuperView.java:44)
   -
   org.apache.tapestry.contrib.table.model.common.BasicTableModelWrap.getRowCount
   (BasicTableModelWrap.java:59)
   -
   org.apache.tapestry.contrib.table.model.common.AbstractTableModel.getPageCount
   (AbstractTableModel.java:73)
   -
   org.apache.tapestry.contrib.table.components.TableView.validateValues(
   TableView.java:470)
   -
   org.apache.tapestry.contrib.table.components.TableView.renderComponent
   (TableView.java:497)
   - org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)

   - org.apache.tapestry.AbstractComponent.renderBody(
   AbstractComponent.java:434)
   - org.apache.tapestry.components.RenderBody.renderComponent(
   RenderBody.java:44)
   - org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)

   - org.apache.tapestry.AbstractComponent.renderBody(
   AbstractComponent.java:434)
   - org.apache.tapestry.html.Shell.renderComponent(Shell.java:115)
   - org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)

   - org.apache.tapestry.BaseComponent.renderComponent(BaseComponent.java:92)

   - org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)

   - org.apache.tapestry.BaseComponent.renderComponent(BaseComponent.java:92)

   - org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)

   - org.apache.tapestry.AbstractPage.renderPage(AbstractPage.java:275)
   - org.apache.tapestry.engine.RequestCycle.renderPage(RequestCycle.java:366)

   -
   org.apache.tapestry.services.impl.ResponseRendererImpl.renderResponse(
   ResponseRendererImpl.java:71)
   - $ResponseRenderer_10f96499ac8.renderResponse($ResponseRenderer_10f96499ac8.java)

   - org.apache.tapestry.engine.PageService.service(PageService.java:68)
   - $IEngineService_10f96499b37.service($IEngineService_10f96499b37.java)

   - org.apache.tapestry.services.impl.EngineServiceOuterProxy.service(
   EngineServiceOuterProxy.java:66)
   - org.apache.tapestry.engine.AbstractEngine.service(
   AbstractEngine.java:248)
   - org.apache.tapestry.services.impl.InvokeEngineTerminator.service(
   InvokeEngineTerminator.java:60)
   - $WebRequestServicer_10f96499b10.service($WebRequestServicer_10f96499b10.java)

   - org.apache.tapestry.services.impl.DisableCachingFilter.service(
   DisableCachingFilter.java:48)
   - $WebRequestServicerFilter_10f96499b12.service($WebRequestServicerFilter_10f96499b12.java)

   - $WebRequestServicer_10f96499b14.service($WebRequestServicer_10f96499b14.java)

   - $WebRequestServicer_10f96499b0c.service($WebRequestServicer_10f96499b0c.java)

   -
   org.apache.tapestry.services.impl.WebRequestServicerPipelineBridge.service
   (WebRequestServicerPipelineBridge.java:56)
   - $ServletRequestServicer_10f96499af2.service($ServletRequestServicer_10f96499af2.java)

   - org.apache.tapestry.request.DecodedRequestInjector.service(
   DecodedRequestInjector.java:55)
   - $ServletRequestServicerFilter_10f96499aee.service($ServletRequestServicerFilter_10f96499aee.java)

   - $ServletRequestServicer_10f96499af4.service($ServletRequestServicer_10f96499af4.java)

   - org.apache.tapestry.multipart.MultipartDecoderFilter.service(
   MultipartDecoderFilter.java:52)
   - $ServletRequestServicerFilter_10f96499aec.service($ServletRequestServicerFilter_10f96499aec.java)

   - $ServletRequestServicer_10f96499af4.service($ServletRequestServicer_10f96499af4.java)

   - org.apache.tapestry.services.impl.SetupRequestEncoding.service(
   SetupRequestEncoding.java:53)
   - $ServletRequestServicerFilter_10f96499af0.service($ServletRequestServicerFilter_10f96499af0.java)

   - $ServletRequestServicer_10f96499af4.service($ServletRequestServicer_10f96499af4.java)

   - $ServletRequestServicer_10f96499ae6.service($ServletRequestServicer_10f96499ae6.java)

   - org.apache.tapestry.ApplicationServlet.doService(
   ApplicationServlet.java:123)
   - org.apache.tapestry.ApplicationServlet.doGet(ApplicationServlet.java:79)

   - javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
   - javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   - org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
   ApplicationFilterChain.java:252)
   - org.apache.catalina.core.ApplicationFilterChain.doFilter(
   ApplicationFilterChain.java:173)
   - org.apache.catalina.core.StandardWrapperValve.invoke(
   StandardWrapperValve.java:213)
   - org.apache.catalina.core.StandardContextValve.invoke(
   StandardContextValve.java:178)
   - org.apache.catalina.core.StandardHostValve.invoke(
   StandardHostValve.java:126)
   - org.apache.catalina.valves.ErrorReportValve.invoke(
   ErrorReportValve.java:105)
   - org.apache.catalina.core.StandardEngineValve.invoke(
   StandardEngineValve.java:107)
   - org.apache.catalina.connector.CoyoteAdapter.service(
   CoyoteAdapter.java:148)
   - org.apache.coyote.http11.Http11Processor.process(
   Http11Processor.java:869)
   -
   org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection
   (Http11BaseProtocol.java:664)
   - org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
   PoolTcpEndpoint.java:527)
   - org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(
   LeaderFollowerWorkerThread.java:80)
   - org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(
   ThreadPool.java:684)
   - java.lang.Thread.run(Thread.java:595)




2006/12/18, Barry Books <tr...@gmail.com>:
>
> I switched to injecting connections with Hivemind and I would say it's
> well worth the effort. I could never figure out how to test code when
> using the Tomcat database connections but with the Hivemind method you
> can just get a connection and add it to the objects you want to test.
>
> There is an example in the tapestry-examples/TimeTracker application.
> It's a bit difficult to setup the first time and involves Hivemind and
> Java Proxies, but in the end it's well worth the effort. I also create
> a separate Eclipse project called TestDB that can create test database
> connections the in my test code I do this
>
>         private static Repository repository;
>         @BeforeClass
>         public static void setUpBeforeClass() throws Exception {
>                 repository = Repository.newTestInstance(
> TestConnection.getConnection());
>         }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: DB-Connection

Posted by Mike Grundvig <mi...@electrotank.com>.
I'm with you Barry. I've had much better luck getting DB connections out of 
the web app configuration and into a more neutral location. Something that 
allows me to run the services and test code from the command line. This 
leads to much better developer productivity overall.

Michael Grundvig
Electrotank, Inc
http://www.electrotank.com


----- Original Message ----- 
From: "Barry Books" <tr...@gmail.com>
To: "Tapestry users" <us...@tapestry.apache.org>
Sent: Monday, December 18, 2006 9:31 AM
Subject: Re: DB-Connection


>I switched to injecting connections with Hivemind and I would say it's
> well worth the effort. I could never figure out how to test code when
> using the Tomcat database connections but with the Hivemind method you
> can just get a connection and add it to the objects you want to test.
>
> There is an example in the tapestry-examples/TimeTracker application.
> It's a bit difficult to setup the first time and involves Hivemind and
> Java Proxies, but in the end it's well worth the effort. I also create
> a separate Eclipse project called TestDB that can create test database
> connections the in my test code I do this
>
> private static Repository repository;
> @BeforeClass
> public static void setUpBeforeClass() throws Exception {
> repository = Repository.newTestInstance(TestConnection.getConnection());
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: DB-Connection

Posted by Barry Books <tr...@gmail.com>.
I switched to injecting connections with Hivemind and I would say it's
well worth the effort. I could never figure out how to test code when
using the Tomcat database connections but with the Hivemind method you
can just get a connection and add it to the objects you want to test.

There is an example in the tapestry-examples/TimeTracker application.
It's a bit difficult to setup the first time and involves Hivemind and
Java Proxies, but in the end it's well worth the effort. I also create
a separate Eclipse project called TestDB that can create test database
connections the in my test code I do this

	private static Repository repository;
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		repository = Repository.newTestInstance(TestConnection.getConnection());
	}

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: DB-Connection

Posted by Shing Hing Man <ma...@yahoo.com>.
If you are using Tomcat 5.5.*, have you tried the
following ?
http://wiki.apache.org/tomcat/UsingDataSources

It works for me.

Shing


--- Fabian Dittrich <fa...@gmail.com> wrote:

> Hi tapestry-users,
> 
> before i used a file in conf/catalina/localhost/ to
> configure my
> db-connection there in an xml file, like this:
> 
> <Context
> docBase="c:/workspace/MCG/context"
> path="/MCG"
> reloadable="true">
> 
> 
>     <Resource name="jdbc/bankDataSource"
> auth="Container"
>         type="javax.sql.DataSource"
> driverClassName="com.mysql.jdbc.Driver "
> 
>         url="jdbc:mysql://localhost/MCG"
> username="root"
>         password="" maxActive="20"
> defaultAutoCommit="false"
>         timeBetweenEvictionRunsMillis="60000" />
> </Context>
> 
> 
> Now i want to deploy my app directly into
> Tomcat/webapps
> 
> Anyone knows where to put the settings for the
> db-connection now?
> 
> Thanks for any advice
> 
> Fabian
> 


Home page :
  http://uk.geocities.com/matmsh/index.html


	
	
		
___________________________________________________________ 
All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine 
http://uk.docs.yahoo.com/nowyoucan.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org