You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Stuart Easterling <st...@gmail.com> on 2014/04/22 21:49:13 UTC

Tomee + custom DataSource resource factory

Greetings all, this may be a straightforward question, but I'm unable to
find a solution. Basically I need to define a DataSource with a custom
resource factory.

According to this thread:

http://openejb.979440.n4.nabble.com/Getting-Started-TomEE-Plus-and-Custom-Resources-td4662031.html

in Tomee:

>ObjectFactory have to be defined in context.xml. tomee.xml
>doesnt define jndi factories but directly objects

But when I add the Resource in META-INF/context.xml or in conf/context.xml
I get the following warning:

WARNING: Property "factory" not supported by "0-myAppName/my/resource/name"

The Resource declaration looks like this:

<Resource name="my/resource/name" auth="Container"
              type="javax.sql.DataSource"
               factory="the.factory.class"
               customParam="customParamValue"
          />

I imagine the answer is an obvious one, but I've done a google search,
searched the mail archive, and reviewed the documentation and haven't found
a clear answer on how to proceed. I am running Tomee 1.6.0.

Many thanks in advance to anyone who can help ! : )

Best,
Stuart

Re: Tomee + custom DataSource resource factory

Posted by Andy Gumbrecht <ag...@tomitribe.com>.
That would be cool! Let me know when you have something, even rough (I 
can polish).

It would be nice to get some docs online and an example.

On 30/04/2014 20:10, Stuart Easterling wrote:
> it'll be worth
> posting a working example in a config file for the benefit of others at
> least. : ) Will update when I have that, just been a bit swamped this past
> week.....

-- 
   Andy Gumbrecht

   http://www.tomitribe.com
   agumbrecht@tomitribe.com
   https://twitter.com/AndyGeeDe

   TomEE treibt Tomitribe! | http://tomee.apache.org


Re: Tomee + custom DataSource resource factory

Posted by Stuart Easterling <st...@gmail.com>.
Hi Andy, thanks for checking in. The next step is that I should try a
couple more variants, following Romain's suggestion. I've got it working
fine by instantiating the DataSource in app code, but it'll be worth
posting a working example in a config file for the benefit of others at
least. : ) Will update when I have that, just been a bit swamped this past
week.....
Best,
Stuart


On Mon, Apr 28, 2014 at 9:41 AM, agumbrecht <ag...@tomitribe.com>wrote:

> Hi Stuart,
>
> Did you get a resolution to your issue, or do you need some more
> information
> to get to your target?
>
> Andy.
>
>
>
> -----
>     --
>     Andy Gumbrecht
>
>     http://www.tomitribe.com
>     agumbrecht@tomitribe.com
>     https://twitter.com/AndyGeeDe
>
>     TomEE treibt Tomitribe ! | http://tomee.apache.org
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Tomee-custom-DataSource-resource-factory-tp4668956p4669011.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: Tomee + custom DataSource resource factory

Posted by agumbrecht <ag...@tomitribe.com>.
Hi Stuart,

Did you get a resolution to your issue, or do you need some more information
to get to your target?

Andy.



-----
    -- 
    Andy Gumbrecht

    http://www.tomitribe.com
    agumbrecht@tomitribe.com
    https://twitter.com/AndyGeeDe

    TomEE treibt Tomitribe ! | http://tomee.apache.org
--
View this message in context: http://openejb.979440.n4.nabble.com/Tomee-custom-DataSource-resource-factory-tp4668956p4669011.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Tomee + custom DataSource resource factory

Posted by Stuart Easterling <st...@gmail.com>.
OK -- I will test (no time today, but I will : ) and report back. Thanks
again.
Best,
Stuart


On Tue, Apr 22, 2014 at 3:21 PM, Romain Manni-Bucau
<rm...@gmail.com>wrote:

> resources.xml is design to work with all types but should work with
> ObjectFactory using factory-method="getObject" as additional
> attribute.
>
> Another workaround could be to not set type to DataSource but a
> subtype of DataSource if you know the impl type.
>
>
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
> 2014-04-23 0:11 GMT+02:00 Stuart Easterling <st...@gmail.com>:
> > Hi, many thanks for the suggestion. : ) So I've reviewed everything I can
> > find on Resource declarations in tomee.xml and resources.xml (and tried
> > various tests), and what's not entirely clear (to me) is: is creating a
> > DataSource using a custom javax.naming.spi.ObjectFactory supported...? I
> am
> > trying to do the following (this is the Tomcat impl):
> >
> >
> http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html#Adding%20Custom%20Resource%20Factories
> >
> > I've reviewed the following:
> >
> > http://tomee.apache.org/containers-and-resources.html
> > http://tomee.apache.org/configuring-datasources.html
> >
> http://tomee.apache.org/examples-trunk/resources-declared-in-webapp/README.html
> >
> http://rmannibucau.wordpress.com/2013/11/05/openejbtomee-resources-how-does-it-work/
> >
> > But it's not clear that a Resource declaration in tomee.xml has an
> > attribute that takes a subclass of javax.naming.spi.ObjectFactory?
> >
> > (Also is some of the above documentation out-of-date as far as the latest
> > attributes, etc....? Is there something more up-to-date I'm
> > overlooking....?)
> >
> > (And in the interim I am just instantiating / configuring my custom
> > DataSource in application code, but still curious how this might be
> doable.
> > : )
> >
> > Best,
> > Stuart
> >
> >
> >
> >
> > On Tue, Apr 22, 2014 at 1:20 PM, Romain Manni-Bucau
> > <rm...@gmail.com>wrote:
> >
> >> Hi
> >>
> >> Did you try using resources.xml or tomee.xml? Basically context.xml
> >> datasources are converted to tomee datasources to get pooling etc by
> >> default. Using resources.xml you can define whatever you want so it
> >> should match your need.
> >>
> >>
> >> Romain Manni-Bucau
> >> Twitter: @rmannibucau
> >> Blog: http://rmannibucau.wordpress.com/
> >> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> >> Github: https://github.com/rmannibucau
> >>
> >>
> >> 2014-04-22 21:49 GMT+02:00 Stuart Easterling <
> stuart.easterling@gmail.com
> >> >:
> >> > Greetings all, this may be a straightforward question, but I'm unable
> to
> >> > find a solution. Basically I need to define a DataSource with a custom
> >> > resource factory.
> >> >
> >> > According to this thread:
> >> >
> >> >
> >>
> http://openejb.979440.n4.nabble.com/Getting-Started-TomEE-Plus-and-Custom-Resources-td4662031.html
> >> >
> >> > in Tomee:
> >> >
> >> >>ObjectFactory have to be defined in context.xml. tomee.xml
> >> >>doesnt define jndi factories but directly objects
> >> >
> >> > But when I add the Resource in META-INF/context.xml or in
> >> conf/context.xml
> >> > I get the following warning:
> >> >
> >> > WARNING: Property "factory" not supported by
> >> "0-myAppName/my/resource/name"
> >> >
> >> > The Resource declaration looks like this:
> >> >
> >> > <Resource name="my/resource/name" auth="Container"
> >> >               type="javax.sql.DataSource"
> >> >                factory="the.factory.class"
> >> >                customParam="customParamValue"
> >> >           />
> >> >
> >> > I imagine the answer is an obvious one, but I've done a google search,
> >> > searched the mail archive, and reviewed the documentation and haven't
> >> found
> >> > a clear answer on how to proceed. I am running Tomee 1.6.0.
> >> >
> >> > Many thanks in advance to anyone who can help ! : )
> >> >
> >> > Best,
> >> > Stuart
> >>
>

Re: Tomee + custom DataSource resource factory

Posted by Romain Manni-Bucau <rm...@gmail.com>.
resources.xml is design to work with all types but should work with
ObjectFactory using factory-method="getObject" as additional
attribute.

Another workaround could be to not set type to DataSource but a
subtype of DataSource if you know the impl type.




Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-04-23 0:11 GMT+02:00 Stuart Easterling <st...@gmail.com>:
> Hi, many thanks for the suggestion. : ) So I've reviewed everything I can
> find on Resource declarations in tomee.xml and resources.xml (and tried
> various tests), and what's not entirely clear (to me) is: is creating a
> DataSource using a custom javax.naming.spi.ObjectFactory supported...? I am
> trying to do the following (this is the Tomcat impl):
>
> http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html#Adding%20Custom%20Resource%20Factories
>
> I've reviewed the following:
>
> http://tomee.apache.org/containers-and-resources.html
> http://tomee.apache.org/configuring-datasources.html
> http://tomee.apache.org/examples-trunk/resources-declared-in-webapp/README.html
> http://rmannibucau.wordpress.com/2013/11/05/openejbtomee-resources-how-does-it-work/
>
> But it's not clear that a Resource declaration in tomee.xml has an
> attribute that takes a subclass of javax.naming.spi.ObjectFactory?
>
> (Also is some of the above documentation out-of-date as far as the latest
> attributes, etc....? Is there something more up-to-date I'm
> overlooking....?)
>
> (And in the interim I am just instantiating / configuring my custom
> DataSource in application code, but still curious how this might be doable.
> : )
>
> Best,
> Stuart
>
>
>
>
> On Tue, Apr 22, 2014 at 1:20 PM, Romain Manni-Bucau
> <rm...@gmail.com>wrote:
>
>> Hi
>>
>> Did you try using resources.xml or tomee.xml? Basically context.xml
>> datasources are converted to tomee datasources to get pooling etc by
>> default. Using resources.xml you can define whatever you want so it
>> should match your need.
>>
>>
>> Romain Manni-Bucau
>> Twitter: @rmannibucau
>> Blog: http://rmannibucau.wordpress.com/
>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> Github: https://github.com/rmannibucau
>>
>>
>> 2014-04-22 21:49 GMT+02:00 Stuart Easterling <stuart.easterling@gmail.com
>> >:
>> > Greetings all, this may be a straightforward question, but I'm unable to
>> > find a solution. Basically I need to define a DataSource with a custom
>> > resource factory.
>> >
>> > According to this thread:
>> >
>> >
>> http://openejb.979440.n4.nabble.com/Getting-Started-TomEE-Plus-and-Custom-Resources-td4662031.html
>> >
>> > in Tomee:
>> >
>> >>ObjectFactory have to be defined in context.xml. tomee.xml
>> >>doesnt define jndi factories but directly objects
>> >
>> > But when I add the Resource in META-INF/context.xml or in
>> conf/context.xml
>> > I get the following warning:
>> >
>> > WARNING: Property "factory" not supported by
>> "0-myAppName/my/resource/name"
>> >
>> > The Resource declaration looks like this:
>> >
>> > <Resource name="my/resource/name" auth="Container"
>> >               type="javax.sql.DataSource"
>> >                factory="the.factory.class"
>> >                customParam="customParamValue"
>> >           />
>> >
>> > I imagine the answer is an obvious one, but I've done a google search,
>> > searched the mail archive, and reviewed the documentation and haven't
>> found
>> > a clear answer on how to proceed. I am running Tomee 1.6.0.
>> >
>> > Many thanks in advance to anyone who can help ! : )
>> >
>> > Best,
>> > Stuart
>>

Re: Tomee + custom DataSource resource factory

Posted by Stuart Easterling <st...@gmail.com>.
Hi, many thanks for the suggestion. : ) So I've reviewed everything I can
find on Resource declarations in tomee.xml and resources.xml (and tried
various tests), and what's not entirely clear (to me) is: is creating a
DataSource using a custom javax.naming.spi.ObjectFactory supported...? I am
trying to do the following (this is the Tomcat impl):

http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html#Adding%20Custom%20Resource%20Factories

I've reviewed the following:

http://tomee.apache.org/containers-and-resources.html
http://tomee.apache.org/configuring-datasources.html
http://tomee.apache.org/examples-trunk/resources-declared-in-webapp/README.html
http://rmannibucau.wordpress.com/2013/11/05/openejbtomee-resources-how-does-it-work/

But it's not clear that a Resource declaration in tomee.xml has an
attribute that takes a subclass of javax.naming.spi.ObjectFactory?

(Also is some of the above documentation out-of-date as far as the latest
attributes, etc....? Is there something more up-to-date I'm
overlooking....?)

(And in the interim I am just instantiating / configuring my custom
DataSource in application code, but still curious how this might be doable.
: )

Best,
Stuart




On Tue, Apr 22, 2014 at 1:20 PM, Romain Manni-Bucau
<rm...@gmail.com>wrote:

> Hi
>
> Did you try using resources.xml or tomee.xml? Basically context.xml
> datasources are converted to tomee datasources to get pooling etc by
> default. Using resources.xml you can define whatever you want so it
> should match your need.
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
> 2014-04-22 21:49 GMT+02:00 Stuart Easterling <stuart.easterling@gmail.com
> >:
> > Greetings all, this may be a straightforward question, but I'm unable to
> > find a solution. Basically I need to define a DataSource with a custom
> > resource factory.
> >
> > According to this thread:
> >
> >
> http://openejb.979440.n4.nabble.com/Getting-Started-TomEE-Plus-and-Custom-Resources-td4662031.html
> >
> > in Tomee:
> >
> >>ObjectFactory have to be defined in context.xml. tomee.xml
> >>doesnt define jndi factories but directly objects
> >
> > But when I add the Resource in META-INF/context.xml or in
> conf/context.xml
> > I get the following warning:
> >
> > WARNING: Property "factory" not supported by
> "0-myAppName/my/resource/name"
> >
> > The Resource declaration looks like this:
> >
> > <Resource name="my/resource/name" auth="Container"
> >               type="javax.sql.DataSource"
> >                factory="the.factory.class"
> >                customParam="customParamValue"
> >           />
> >
> > I imagine the answer is an obvious one, but I've done a google search,
> > searched the mail archive, and reviewed the documentation and haven't
> found
> > a clear answer on how to proceed. I am running Tomee 1.6.0.
> >
> > Many thanks in advance to anyone who can help ! : )
> >
> > Best,
> > Stuart
>

Re: Tomee + custom DataSource resource factory

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

Did you try using resources.xml or tomee.xml? Basically context.xml
datasources are converted to tomee datasources to get pooling etc by
default. Using resources.xml you can define whatever you want so it
should match your need.


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-04-22 21:49 GMT+02:00 Stuart Easterling <st...@gmail.com>:
> Greetings all, this may be a straightforward question, but I'm unable to
> find a solution. Basically I need to define a DataSource with a custom
> resource factory.
>
> According to this thread:
>
> http://openejb.979440.n4.nabble.com/Getting-Started-TomEE-Plus-and-Custom-Resources-td4662031.html
>
> in Tomee:
>
>>ObjectFactory have to be defined in context.xml. tomee.xml
>>doesnt define jndi factories but directly objects
>
> But when I add the Resource in META-INF/context.xml or in conf/context.xml
> I get the following warning:
>
> WARNING: Property "factory" not supported by "0-myAppName/my/resource/name"
>
> The Resource declaration looks like this:
>
> <Resource name="my/resource/name" auth="Container"
>               type="javax.sql.DataSource"
>                factory="the.factory.class"
>                customParam="customParamValue"
>           />
>
> I imagine the answer is an obvious one, but I've done a google search,
> searched the mail archive, and reviewed the documentation and haven't found
> a clear answer on how to proceed. I am running Tomee 1.6.0.
>
> Many thanks in advance to anyone who can help ! : )
>
> Best,
> Stuart