Re: "Could not auto-map to resource" problem when using EJB annotations only
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
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 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
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 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
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 > > > > 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. > > > >jdbc/__mes > >javax.sql.DataSource > >Container > >Shareable > > > > > > 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 tag inside the application.xml. > > I couldn't find any hint about the 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. > > 1 in web console -> DB Manager Portlet create DB: RexDB 2 Run the following SQL: CREATE TABLE RexTable (EMPNO NUMERIC(4) PRIMARY KEY NOT NULL, ENAME VARCHAR(10)); INSERT INTO RexTable VALUES (,'JONES'); INSERT INTO RexTable VALUES (,'SMITH'); 3 -> Database Pools portlet -> Using the Geronimo database pool wizard Name of Database Pool : RexDS Database Type: Derby embeded -> select the driver jar & input Database Name: RexDB EMPEar.ear Description: Binary data
Re: "Could not auto-map to resource" problem when using EJB annotations only
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. > >jdbc/__mes >javax.sql.DataSource >Container >Shareable > > > 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 tag inside the application.xml. I couldn't find any hint about the 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
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. jdbc/__mes javax.sql.DataSource Container Shareable HTH Rex 2009/5/4 fmeili > > > > 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": > >jdbc/MyDataSource >javax.sql.DataSource >Container >Shareable > > Also this page tell me to insert the following code into the > "geronimo-web.xml" file: > > >MyWebApp > > > >console.dbpool >jdbc___mes > > > >/MyWebApp > >jdbc/MyDataSource >jdbc/__mes > > > 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: > > > > > mes.suite > > > >console.dbpool >jdbc___mes > > > > > > 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: > > >jdbc/__mes >javax.sql.DataSource >Container >Shareable > > > 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
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": jdbc/MyDataSource javax.sql.DataSource Container Shareable Also this page tell me to insert the following code into the "geronimo-web.xml" file: MyWebApp console.dbpool jdbc___mes /MyWebApp jdbc/MyDataSource jdbc/__mes 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: mes.suite console.dbpool jdbc___mes 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: jdbc/__mes javax.sql.DataSource Container Shareable 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
On Apr 30, 2009, at 6:51 AM, fmeili wrote: Hi all, I try to deploy an EAR with some (skinny) WAR's and some EJB's. All EJB's use the @Resource tag for Database access. I always get a deployment error, that the resource could not auto-map. Instead the error message tell me to use a Geronimo deployment plan. After looking deeper in the Deployment plan mechanism of Geronimo I'm completely confused. I found that I need an "openejb-jar.xml" and use the Tag in it. This only works, if I have also a standard "ejb-jar.xml". But does this mean, that I have to really write all the "old pre JEE5" deployment descriptors for all my EJB's to deploy the EAR to Geronimo? You don't have to do that. Is there a way to tell Geronimo the name of a JDBC resource globally - maybe in the "geronimo-application.xml" - I haven't found a hint about this? I tried Geronimo 2.1.4 and 2.2-SNAPSHOT. 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 Thanks in advance for an answer, greetings, Frank -- View this message in context: http://www.nabble.com/%22Could-not-auto-map-to-resource%22-problem-when-using-EJB-annotations-only-tp23316686s134p23316686.html Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.