« Return to Thread: Getting "Name jdbc is not bound in this Context" when using cargo-maven2-plugin to define a datasource for Tomcat5x container

Re: Getting "Name jdbc is not bound in this Context" when using cargo-maven2-plugin to define a datasource for Tomcat5x container

by Paul Spencer-3 :: Rate this Message:

Reply to Author | View in Thread

Wendy,
I have gotten it working using the configuration described below.  This
might also work for Archiva

1) Create context.xml and copy it into META-INF using the webResource
configuration of the war plugin for this.
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-war-plugin</artifactId>
             <configuration>
               <webResources>
                 <resource>
                   <directory>src/test/resources</directory>
                   <targetPath>META-INF</targetPath>
                   <includes>
                     <include>context.xml</include>
                   </includes>
                 </resource>
               </webResources>
             </configuration>
           </plugin>

2) Place the datasource definition(s) and the realm definition in
context.xml.  Note: The realm definition is limited to the MemoryRealm
because resouces can not be configured in server.xml :(  Also their is
no datasource configuration in the cargo plugin.

    <?xml version='1.0' encoding='utf-8'?>
    <Context reloadable="true">
      <Realm className="org.apache.catalina.realm.MemoryRealm" />
      <Resource name='datasource.name' auth='Container'
        type='javax.sql.DataSource' username='foo'
        password='bar driverClassName='ca.edbc.jdbc.EdbcDriver'
        url='jdbc:edbc://testsvr.foo.com/db_dev' />
    </Context>

3) Add the user configuration to the cargo plugin.  This configuration
may need to mimic any user and role configuration stored the the database.



***
* Complete Plugin configuration
***
           <plugin>
             <groupId>org.codehaus.cargo</groupId>
             <artifactId>cargo-maven2-plugin</artifactId>
             <version>0.3.1</version>
             <configuration>
               <container>
                 <containerId>tomcat5x</containerId>
                 <home>${cargo.tomcat5x.home}</home>
                 <log>${project.build.directory}/tomcat5x.log</log>
                 <output>${project.build.directory}/tomcat5x.out</output>
                 <logLevel>debug</logLevel>
               </container>
               <configuration>
                 <deployables>
                   <deployable>
                     <properties>
                       <context>myApp</context>
                     </properties>
                   </deployable>
                 </deployables>
                 <home>${project.build.directory}/tomcat5x</home>
                 <properties>
                   <cargo.logging>high</cargo.logging>
                   <cargo.servlet.users>
                     manager:manager:manager,employee|
                     employee:employee:employee
                   </cargo.servlet.users>
                   <cargo.servlet.port>8080</cargo.servlet.port>
                 </properties>
               </configuration>
               <wait>false</wait>
             </configuration>
             <executions>
               <execution>
                 <id>start-container</id>
                 <phase>pre-integration-test</phase>
                 <goals>
                   <goal>start</goal>
                 </goals>
               </execution>
               <execution>
                 <id>stop-container</id>
                 <phase>post-integration-test</phase>
                 <goals>
                   <goal>stop</goal>
                 </goals>
               </execution>
             </executions>
           </plugin>


I see <Resouurce> configuration in server.xml as an enhancement for
Cargo and the Maven plugin for the following reasons:
1) This will allow the configuration of a Realm that is backed by a
database.
2) Allow the application's context.xml use <ResourceLink>
3) Minimize the need, if not remove the need, for maintaining production
and testing version of context.xml

Paul Spencer



Wendy Smoak wrote:

> On 6/2/07, Paul Spencer <paulsp@...> wrote:
>
>> The plugin is 0.3.1.  The plugin uses Cargo version 0.9.
>
> Thanks, I forgot that the plugin is versioned independently.
>
>> How did you resolve the issue with Archiva and three datasources?
>
> In the email you replied to, I wrote, "I didn't even try to configure
> that."  A trip through the archives indicates that there's limited
> support for data sources, and the docs seem to imply that there can be
> only one.
>
> My guess is that it's going to require some additional work in Cargo,
> which I'd like to do but am having trouble finding time for at the
> moment.  We do need to make it easy to test Archiva on Tomcat, though,
> so maybe it will float up the priority list.
>


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

 « Return to Thread: Getting "Name jdbc is not bound in this Context" when using cargo-maven2-plugin to define a datasource for Tomcat5x container