Looking for best way to have Cargo inject two kinds of resources

View: New views
3 Messages — Rating Filter:   Alert me  

Looking for best way to have Cargo inject two kinds of resources

by Vogelsang, Jeff :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hello,

 

I am trying to get the Cargo 1.0 Maven 2 plugin to generate the following two resources for at Tomcat6x container:

 

1.) Oracle with Connection Pooling

 

<Resource name="THEDS"

         type="oracle.jdbc.pool.OracleDataSource"

         factory="oracle.jdbc.pool.OracleDataSourceFactory"

         url="jdbc:oracle:thin:@localhost:1521:xe"

         driverClassName="oracle.jdbc.OracleDriver"

         userName="username"

         password="password"

         auth="Container"

         maxActive="100"

         maxIdle="30"

         maxWait="10000"

         logAbandoned="true"

         removeAbandoned="true"

         removeAbandonedTimeout="60" />

 

2.) Oracle without Connection Pooling

     

<Resource name='THEDS'

        type='javax.sql.DataSource'

        url=’jdbc:oracle:thin:@localhost:1521:xe’

        driverClassName='oracle.jdbc.OracleDriver'

        username='username'

        password='password'

        auth='Container' />

 

With Cargo 1.0 and the Maven2 Cargo plugin, I cannot figure out how to create either of these resources with either cargo.resource.resource or cargo.datasource.datasource.

 

Can anyone lend a hand?

 

Thanks,

 

Jeff


Re: Looking for best way to have Cargo inject two kinds of resources

by Alexander Brill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jul 6, 2009 at 6:12 PM, Vogelsang, Jeff <jeffvogelsang@...> wrote:

Hello,

 

I am trying to get the Cargo 1.0 Maven 2 plugin to generate the following two resources for at Tomcat6x container:

 

1.) Oracle with Connection Pooling

 

<Resource name="THEDS"

         type="oracle.jdbc.pool.OracleDataSource"

         factory="oracle.jdbc.pool.OracleDataSourceFactory"

         url="jdbc:oracle:thin:@localhost:1521:xe"

         driverClassName="oracle.jdbc.OracleDriver"

         userName="username"

         password="password"

         auth="Container"

         maxActive="100"

         maxIdle="30"

         maxWait="10000"

         logAbandoned="true"

         removeAbandoned="true"

         removeAbandonedTimeout="60" />

 

2.) Oracle without Connection Pooling

     

<Resource name='THEDS'

        type='javax.sql.DataSource'

        url=’jdbc:oracle:thin:@localhost:1521:xe’

        driverClassName='oracle.jdbc.OracleDriver'

        username='username'

        password='password'

        auth='Container' />

 

With Cargo 1.0 and the Maven2 Cargo plugin, I cannot figure out how to create either of these resources with either cargo.resource.resource or cargo.datasource.datasource.

 

Can anyone lend a hand?

 

Thanks,

 

Jeff


<configuration>
  <resources>
    <resource>
      <name>someDataSource</name>
      <type>javax.sql.DataSource</type>
      <parameters>
         <url>jdbc...</url>
         <maxWait>500</maxWait>
         ...
       </parameters>
     </resource>
  </resources>
</configuration>


--
Alexander Brill
http://brill.no

RE: Looking for best way to have Cargo inject two kinds of resources

by Vogelsang, Jeff :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hello,

 

I think I have things working with Cargo 1.0 / Maven2 now based on feedback I got from the mailing list. Thanks for assist folks!

 

I discovered several things through trial and error:

 

1.) Using cargo.datasource.datasource in configuration->properties portion of the Cargo config is a bit limiting. If you choose the default type=javax.sql.DataSource, then you are forced to use Tomcat's basic connection pool data source factory. Currently, Cargo does not let you configure your own datasource type and factory through this facility. If you specify your own type it doesn’t work, and if you specify your own factory it’s replaced with Tomcat’s.

 

2.) Per 1, it would be nice to be able to specify a datasource and provide your own type and factory as configurable parameters.

 

3.) When supplying cargo.datasource.username, Cargo will actually emit the attribute "user" rather than username. This causes Oracle driver connections to fail as the scenario including the Tomcat datasource factory and Oracle driver needs to get a username attribute, not a user attribute.

 

4.) I can easily get the datasource I need by specifying it as a resource and supplying the correct parameters. When specifying the datasource as a resource, supplying <auth>Container</auth> as part of the resource specification will fail as this is injected by Cargo by default.

 

For now I am going to specify the datasource as a directly specified resource. Include below are my trials and results for folks to examine.

 

Again, thanks!

 

Jeff

 

 

Cargo Config that Doesn't Work:

                                                                                                                                                               

<cargo.datasource.datasource.eis>

                cargo.datasource.driver=oracle.jdbc.OracleDriver|

                cargo.datasource.url=$jdbc:oracle:thin:@localhost:1521:xe|

                cargo.datasource.jndi=THE_DATASOURCE|

                cargo.datasource.username=USERNAME|

                cargo.datasource.password=USERNAME

</cargo.datasource.datasource.eis>

                               

Produces:

                               

<?xml version="1.0" encoding="UTF-8"?>

 

<Context>

  <Resource name="THE_DATASOURCE" type="javax.sql.DataSource" auth="Container" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" user="USERNAME" password="PASSWORD" url="jdbc:oracle:thin:@localhost:1521:xe" driverClassName="oracle.jdbc.OracleDriver"/>

  <Transaction factory="org.objectweb.jotm.UserTransactionFactory"/>

</Context>                                                                                                                                                       

 

----

 

Cargo Config that Does Work:

 

<cargo.datasource.datasource>

                cargo.datasource.driver=oracle.jdbc.OracleDriver|

                cargo.datasource.url=$jdbc:oracle:thin:@localhost:1521:xe|

                cargo.datasource.jndi=THE_DATASOURCE|

                cargo.datasource.username=USERNAME|

                cargo.datasource.password=USERNAME|

                cargo.datasource.properties=username=USERNAME

</cargo.datasource.datasource>

 

Produces:

 

<?xml version="1.0" encoding="UTF-8"?>

 

<Context>

  <Resource name="THE_DATASOURCE" type="javax.sql.DataSource" auth="Container" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" user="USERNAME" password="PASSWORD" url="jdbc:oracle:thin:@localhost:1521:xe" driverClassName="oracle.jdbc.OracleDriver" username="USERNAME"/>

  <Transaction factory="org.objectweb.jotm.UserTransactionFactory"/>

</Context>

 

----

 

Cargo Config that Does Work:

 

<resource>

                <name>THE_DATASOURCE</name>

                <type>javax.sql.DataSource</type>

                <parameters>

                                <url>jdbc:oracle:thin:@localhost:1521:xe</url>

                                <driverClassName>oracle.jdbc.OracleDriver</driverClassName>

                                <username>USERNAME</username>

                                <password>PASSWORD</password>

                                <maxActive>100</maxActive>

                                <maxIdle>30</maxIdle>

                                <maxWait>10000</maxWait>

                </parameters>

</resource>

 

Produces:

 

<?xml version="1.0" encoding="UTF-8"?>

 

<Context>

  <Transaction factory="org.objectweb.jotm.UserTransactionFactory"/>

  <Resource name="THE_DATASOURCE" type="javax.sql.DataSource" auth="Container" driverClassName="oracle.jdbc.OracleDriver" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" maxActive="100" maxIdle="30" maxWait="10000" password="PASSWORD" url="jdbc:oracle:thin:@localhost:1521:xe" username="USERNAME"/>

</Context>

 

----

 

Cargo Config that Does Work:

 

<resource>

                <name>THE_DATASOURCE</name>

                <type>oracle.jdbc.pool.OracleDataSource</type>

                <parameters>

                                <class>oracle.jdbc.OracleDriver</class>

                                <factory>oracle.jdbc.pool.OracleDataSourceFactory</factory>

                                <url>jdbc:oracle:thin:@localhost:1521:xe</url>

                                <user>USERNAME</user>

                                <password>PASSWORD</password>

                                <maxActive>100</maxActive>

                                <maxIdle>30</maxIdle>

                                <maxWait>10000</maxWait>

                                <logAbandoned>true</logAbandoned>

                                <removeAbandoned>true</removeAbandoned>

                                <removeAbandonedTimeout>60</removeAbandonedTimeout>

                </parameters>

</resource>

 

Produces:

 

<?xml version="1.0" encoding="UTF-8"?>

 

<Context>

  <Transaction factory="org.objectweb.jotm.UserTransactionFactory"/>

  <Resource name="THE_DATASOURCE" type="oracle.jdbc.pool.OracleDataSource" auth="Container" class="oracle.jdbc.OracleDriver" factory="oracle.jdbc.pool.OracleDataSourceFactory" logAbandoned="true" maxActive="100" maxIdle="30" maxWait="10000" password="PASSWORD" removeAbandoned="true" removeAbandonedTimeout="60" url="jdbc:oracle:thin:@localhost:1521:xe" user="USERNAME"/>

</Context>

 

From: Alexander Brill [mailto:alex@...]
Sent: Wednesday, July 08, 2009 6:48 AM
To: user@...
Subject: Re: [cargo-user] Looking for best way to have Cargo inject two kinds of resources

 

On Mon, Jul 6, 2009 at 6:12 PM, Vogelsang, Jeff <jeffvogelsang@...> wrote:

Hello,

 

I am trying to get the Cargo 1.0 Maven 2 plugin to generate the following two resources for at Tomcat6x container:

 

1.) Oracle with Connection Pooling

 

<Resource name="THEDS"

         type="oracle.jdbc.pool.OracleDataSource"

         factory="oracle.jdbc.pool.OracleDataSourceFactory"

         url="jdbc:oracle:thin:@localhost:1521:xe"

         driverClassName="oracle.jdbc.OracleDriver"

         userName="username"

         password="password"

         auth="Container"

         maxActive="100"

         maxIdle="30"

         maxWait="10000"

         logAbandoned="true"

         removeAbandoned="true"

         removeAbandonedTimeout="60" />

 

2.) Oracle without Connection Pooling

     

<Resource name='THEDS'

        type='javax.sql.DataSource'

        url=’jdbc:oracle:thin:@localhost:1521:xe’

        driverClassName='oracle.jdbc.OracleDriver'

        username='username'

        password='password'

        auth='Container' />

 

With Cargo 1.0 and the Maven2 Cargo plugin, I cannot figure out how to create either of these resources with either cargo.resource.resource or cargo.datasource.datasource.

 

Can anyone lend a hand?

 

Thanks,

 

Jeff


<configuration>
  <resources>
    <resource>
      <name>someDataSource</name>
      <type>javax.sql.DataSource</type>
      <parameters>
         <url>jdbc...</url>
         <maxWait>500</maxWait>
         ...
       </parameters>
     </resource>
  </resources>
</configuration>


--
Alexander Brill
http://brill.no