You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Rex Wang <rw...@gmail.com> on 2009/05/04 11:10:31 UTC

Re: "Could not auto-map to resource" problem when using EJB annotations only

hi frank

This should be add to the application.xml(not geronimo-application.xml), coz
it is NOT Geronimo specific. It is the JEE specific.
<resource-ref>
   <res-ref-name>jdbc/__mes</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
   <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>

HTH

Rex

2009/5/4 fmeili <fr...@gmx.de>

>
>
>
> djencks wrote:
> >
> >
> > On Apr 30, 2009, at 6:51 AM, fmeili wrote:
> >
> > So..... geronimo is assembled out of plugins (e.g. your app becomes a
> > plugin once deployed).  The plugins form a directed acyclic graph
> > (each plugin has a bunch of parents, and you can't have circular
> > dependencies).  When the deployer tries to figure out what datasource
> > you're asking for it looks only in the directed acyclic subgraph of
> > ancestors of your app.  (this lets you deploy lots of distinct
> > datasources with the same "name" in different plugins and still be
> > able to refer to them individually without specifying the exact plugin
> > they come from everywhere you want a datasource).
> >
> > So...
> > - deploy a datasource e.g. using the console and note what the
> > artifact name is for the resulting plugin
> > - add a dependency on that datasource plugin into the ear or ejb plan
> > (geronimo-application.xml or openejb-jar.xml)
> >
> > As long as the name in the @Resource annotation matches the name in
> > the connector plan that's all that's necessary.
> >
> > thanks
> > david jencks
> >
> >
>
> Hi David,
>
> thanks a lot for your explanation. I've tried to deploy it, as you
> described, but it didn't work.
>
> I don't know where my mistake is. I've tried it in the following way:
>
> 1. Using the WebConsole, I've created a database pool using the database
> pool wizard. The name of the pool is "jdbc/__mes". The database is
> accessible successfully (test-db-ping works).
>
> 2. Now the database pool with the name "jdbc/__mes" is listed in the
> "Database Pools" page in Geronimos WebConosle. If I follow the link "Usage"
> for this pool, I see a lot of hints how to use this pool - but I can't
> bring
> it to work.
>
> 3. The "Usage" page tell me to include the following section into my
> "web.xml":
>  <resource-ref>
>    <res-ref-name>jdbc/MyDataSource</res-ref-name>
>    <res-type>javax.sql.DataSource</res-type>
>    <res-auth>Container</res-auth>
>    <res-sharing-scope>Shareable</res-sharing-scope>
>  </resource-ref>
> Also this page tell me to insert the following code into the
> "geronimo-web.xml" file:
>  <environment>
>        <moduleId>
>            <artifactId>MyWebApp</artifactId>
>        </moduleId>
>        <dependencies>
>            <dependency>
>                <groupId>console.dbpool</groupId>
>                <artifactId>jdbc___mes</artifactId>
>            </dependency>
>        </dependencies>
>    </environment>
>    <context-root>/MyWebApp</context-root>
>    <resource-ref>
>        <ref-name>jdbc/MyDataSource</ref-name>
>        <resource-link>jdbc/__mes</resource-link>
>    </resource-ref>
>
> As fas as I understand you, it is not neccessary to do this in the web.xml
> and geronimo-web.xml files. Instead I may define this in the
> geronimo-web.xml.
> As you wrote, I've tried to use add a dependency in the
> geronimo-application.xml - this is the result:
> <?xml version="1.0" encoding="UTF-8"?>
> <application>
>  <environment>
>    <moduleId>
>      <artifactId>mes.suite</artifactId>
>    </moduleId>
>    <dependencies>
>      <dependency>
>        <groupId>console.dbpool</groupId>
>        <artifactId>jdbc___mes</artifactId>
>      </dependency>
>    </dependencies>
>  </environment>
> </application>
>
> The @Resource annotation has a "name" this attribute: "jdbc/__mes".
>
> But I still got this deployment error. Also I've tried to insert the
> following section in the geronimo-application.xml, but it didn't help:
>
> <resource-ref>
>    <res-ref-name>jdbc/__mes</res-ref-name>
>    <res-type>javax.sql.DataSource</res-type>
>    <res-auth>Container</res-auth>
>    <res-sharing-scope>Shareable</res-sharing-scope>
> </resource-ref>
>
> I don't know, what my mistake is.
>
> Do I need to add something to the "application.xml"?
> What do I need to add to the "geronimo-web.xml" to make jdbc connection
> available for all web and ejb modules included in the ear?
>
> Thanks,
>  Frank
>
> --
> View this message in context:
> http://www.nabble.com/%22Could-not-auto-map-to-resource%22-problem-when-using-EJB-annotations-only-tp23316686s134p23364735.html
> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>
>

Re: "Could not auto-map to resource" problem when using EJB annotations only

Posted by fmeili <fr...@gmx.de>.


Rex Wang-2 wrote:
> 
> yes, Frank
> 
> attachment is the improved demo based on your requirement and David's
> suggestion. I have tested it.
> 
> HTH
> 
> Rex
>  
> 

Hi Rex,

thanks a lot for your work and help. This works great! So I'm simply able to
define it in the geronimo-application.xml. Now I'm able to deploy the same
EAR in different application server implementations - great! I didn't find
this hint in the Geronimo documentation.

Thanks and Greetings,
 Frank:jumping:
-- 
View this message in context: http://www.nabble.com/%22Could-not-auto-map-to-resource%22-problem-when-using-EJB-annotations-only-tp23316686s134p23408531.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: "Could not auto-map to resource" problem when using EJB annotations only

Posted by Rex Wang <rw...@gmail.com>.
yes, Frank

attachment is the improved demo based on your requirement and David's
suggestion. I have tested it.

HTH

Rex

2009/5/6 David Jencks <da...@yahoo.com>

>
> On May 5, 2009, at 12:42 AM, fmeili wrote:
>
>
>>
>>
>> Rex Wang-2 wrote:
>>
>>>
>>> Hi Frank, sorry for the confusing, it can not be added to the
>>> application.xml, but should be added to the web.xml / ejb-jar.xml...
>>>
>>> here is an example in attachment.
>>>
>>> HTH
>>>
>>> rex.
>>>
>>>
>> Hi Rex,
>>
>> thanks for your answer. But this, I think, is the problem. My EAR consits
>> out of 40 EJB's and 25 WAR's and all are using the @Resource injection for
>> the database. Til now I don't have descriptors for the EJB's (no
>> "ejb-jar.xml") - I thought they are no longer neccessary in JEE5. And the
>> deployment descriptors of the WAR's ("web.xml") only contains the
>> servlet-mappings. (This EAR file can successfully deployed in JBoss and in
>> GlassFish without modifications.)
>>
>> To be able to deploy this in Geronimo do I really need to add 40 new
>> "openejb-jar.xml", 40 new "ejb-jar.xml" and 25 new "geronimo-web.xml"
>> files
>> - and also change 25 "web.xml" files to place the <resource-ref> tag? Is
>> there no way to just use injection without specifying it in all
>> descriptors?
>> Maybe there is a way to define a jdbc resource globally in Geronimo to use
>> in with injection?
>>
>
> I think you should be able to avoid geronimo plans for each module.
>
> You need to
>
> 1. make sure that the name specified in the annotations or dd resource-ref
> is the same as the datasource name you specify when you deploy the
> connection pool.
> 2. make the connection pool "visible" to your application by adding its id
> as a dependency to the geronimo plan for your application.
>
> This should be enough to make the auto-map work.
>
> hope this helps
> david jencks
>
>
>
>
>>
>> Thanks,
>> Frank
>> --
>> View this message in context:
>> http://www.nabble.com/%22Could-not-auto-map-to-resource%22-problem-when-using-EJB-annotations-only-tp23316686s134p23382575.html
>> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>>
>>
>

Re: "Could not auto-map to resource" problem when using EJB annotations only

Posted by David Jencks <da...@yahoo.com>.
On May 5, 2009, at 12:42 AM, fmeili wrote:

>
>
>
> Rex Wang-2 wrote:
>>
>> Hi Frank, sorry for the confusing, it can not be added to the
>> application.xml, but should be added to the web.xml / ejb-jar.xml...
>>
>> here is an example in attachment.
>>
>> HTH
>>
>> rex.
>>
>
> Hi Rex,
>
> thanks for your answer. But this, I think, is the problem. My EAR  
> consits
> out of 40 EJB's and 25 WAR's and all are using the @Resource  
> injection for
> the database. Til now I don't have descriptors for the EJB's (no
> "ejb-jar.xml") - I thought they are no longer neccessary in JEE5.  
> And the
> deployment descriptors of the WAR's ("web.xml") only contains the
> servlet-mappings. (This EAR file can successfully deployed in JBoss  
> and in
> GlassFish without modifications.)
>
> To be able to deploy this in Geronimo do I really need to add 40 new
> "openejb-jar.xml", 40 new "ejb-jar.xml" and 25 new "geronimo- 
> web.xml" files
> - and also change 25 "web.xml" files to place the <resource-ref>  
> tag? Is
> there no way to just use injection without specifying it in all  
> descriptors?
> Maybe there is a way to define a jdbc resource globally in Geronimo  
> to use
> in with injection?

I think you should be able to avoid geronimo plans for each module.

You need to

1. make sure that the name specified in the annotations or dd resource- 
ref is the same as the datasource name you specify when you deploy the  
connection pool.
2. make the connection pool "visible" to your application by adding  
its id as a dependency to the geronimo plan for your application.

This should be enough to make the auto-map work.

hope this helps
david jencks


>
>
> Thanks,
> Frank
> -- 
> View this message in context: http://www.nabble.com/%22Could-not-auto-map-to-resource%22-problem-when-using-EJB-annotations-only-tp23316686s134p23382575.html
> Sent from the Apache Geronimo - Users mailing list archive at  
> Nabble.com.
>


Re: "Could not auto-map to resource" problem when using EJB annotations only

Posted by fmeili <fr...@gmx.de>.


Rex Wang-2 wrote:
> 
> Hi Frank, sorry for the confusing, it can not be added to the
> application.xml, but should be added to the web.xml / ejb-jar.xml...
> 
> here is an example in attachment.
> 
> HTH
> 
> rex.
> 

Hi Rex,

thanks for your answer. But this, I think, is the problem. My EAR consits
out of 40 EJB's and 25 WAR's and all are using the @Resource injection for
the database. Til now I don't have descriptors for the EJB's (no
"ejb-jar.xml") - I thought they are no longer neccessary in JEE5. And the
deployment descriptors of the WAR's ("web.xml") only contains the
servlet-mappings. (This EAR file can successfully deployed in JBoss and in
GlassFish without modifications.)

To be able to deploy this in Geronimo do I really need to add 40 new
"openejb-jar.xml", 40 new "ejb-jar.xml" and 25 new "geronimo-web.xml" files
- and also change 25 "web.xml" files to place the <resource-ref> tag? Is
there no way to just use injection without specifying it in all descriptors?
Maybe there is a way to define a jdbc resource globally in Geronimo to use
in with injection?

Thanks,
 Frank
-- 
View this message in context: http://www.nabble.com/%22Could-not-auto-map-to-resource%22-problem-when-using-EJB-annotations-only-tp23316686s134p23382575.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: "Could not auto-map to resource" problem when using EJB annotations only

Posted by Rex Wang <rw...@gmail.com>.
Hi Frank, sorry for the confusing, it can not be added to the
application.xml, but should be added to the web.xml / ejb-jar.xml...

here is an example in attachment.

HTH

rex.


2009/5/4 fmeili <fr...@gmx.de>

>
>
>
> Rex Wang-2 wrote:
> >
> > hi frank
> >
> > This should be add to the application.xml(not geronimo-application.xml),
> > coz
> > it is NOT Geronimo specific. It is the JEE specific.
> > <resource-ref>
> >    <res-ref-name>jdbc/__mes</res-ref-name>
> >    <res-type>javax.sql.DataSource</res-type>
> >    <res-auth>Container</res-auth>
> >    <res-sharing-scope>Shareable</res-sharing-scope>
> > </resource-ref>
> >
> > HTH
> >
> > Rex
> >
>
>
> Hi Rex,
>
> thanks for the answer. But when I add this to the "application.xml" I get
> an
> error, that this element is not allowed here. After looking to the
> http://java.sun.com/xml/ns/javaee/application_5.xsd I couldn't find any
> hint
> about the <resource-ref> tag inside the application.xml.
>
> I couldn't find any hint about the <resource-ref> inside an application.xml
> even not in the JaveEE5 specification.
>
> Have you tried this?
>
> Thanks,
>  Frank
>
> --
> View this message in context:
> http://www.nabble.com/%22Could-not-auto-map-to-resource%22-problem-when-using-EJB-annotations-only-tp23316686s134p23368822.html
> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>
>

Re: "Could not auto-map to resource" problem when using EJB annotations only

Posted by fmeili <fr...@gmx.de>.


Rex Wang-2 wrote:
> 
> hi frank
> 
> This should be add to the application.xml(not geronimo-application.xml),
> coz
> it is NOT Geronimo specific. It is the JEE specific.
> <resource-ref>
>    <res-ref-name>jdbc/__mes</res-ref-name>
>    <res-type>javax.sql.DataSource</res-type>
>    <res-auth>Container</res-auth>
>    <res-sharing-scope>Shareable</res-sharing-scope>
> </resource-ref>
> 
> HTH
> 
> Rex
> 


Hi Rex,

thanks for the answer. But when I add this to the "application.xml" I get an
error, that this element is not allowed here. After looking to the 
http://java.sun.com/xml/ns/javaee/application_5.xsd I couldn't find any hint
about the <resource-ref> tag inside the application.xml.

I couldn't find any hint about the <resource-ref> inside an application.xml
even not in the JaveEE5 specification.

Have you tried this?

Thanks,
 Frank

-- 
View this message in context: http://www.nabble.com/%22Could-not-auto-map-to-resource%22-problem-when-using-EJB-annotations-only-tp23316686s134p23368822.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.