geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: Geronimo 2.2 + Spring + Hibernate and a Geronimo managed DB Pool with XA driver
Date Fri, 16 Jul 2010 06:28:24 GMT

On Jul 15, 2010, at 9:17 PM, Ivan wrote:

> I think that you might need to define the resource reference in your ejb deployment plan,
or server will not map the resource to the bean scope naming context. Or you could directly
lookup it by the global naming if the portable application is not your concern.

There are several pieces in this picture that you don't indicate how they relate.  If you
have code like:

new InitialContext().lookup("java:comp/env/foo")

in a javaee component such as ejb, servlet, or app client, then you have to indicate that
geronimo should put something in the jndi context for that component: the ejb-jar.xml, web.xml,
application-client.xml, or use a class-level @Resource annotation.  You can also use an @Resource
annotation on a field and geronimo will do the lookup for you.

If you are looking up a datasource, then in the geronimo plan for your app you need to include
a dependency on the deployed datasource module (in your example

           <dep:dependency>
           <dep:groupId>console.dbpool</dep:groupId>
           <dep:artifactId>jdbc_testmydb</dep:artifactId>
           <dep:version>1.0</dep:version>
           <dep:type>car</dep:type>
           </dep:dependency>

If the "jdbc/testmydb" part of the lookup matches the name element in the connector plan,
then you don't need any other info.  If it doesn't, you also need a resource--ref in the geronimo
plan to match up what you are looking up with what is defined.  I'd advise naming the datasource
jdbc/testmydb so you don't need this mapping.

The jndi lookup will also work in any object reached in the same thread from a javaee component.
 If you are trying to do this kind of lookup in a spring bean, and it is only called from
a javaee comonent, and in the same thread, the lookup should work.

You can also directly look up the datasource in global jndi without any configuration using
new InitialContext().lookup("jca:/default/wakapeek-persist-ear/JCAManagedConnectionFactory/testmydb")

hope this helps
david jencks


> 
> 2010/7/16 Billy Vandory <billy_vandory@yahoo.com>
> 
> I'm still having a problem with this.  I've determined it's not spring, it's
> most likely just a configuration issue.  The problem is trying to get a
> lookup to a global database pool in geronimo.  In an SL-EJB I have:
> 
> InitialContext ctx = new InitialContext();
> DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/testmydb");
> Connection con = ds.getConnection();
> 
> and my deployment plan for the db looks like (copied from geronimo's show
> plan button):
> 
> <connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2">
>    <dep:environment
> xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2">
>        <dep:moduleId>
>            <dep:groupId>console.dbpool</dep:groupId>
>            <dep:artifactId>jdbc_testmydb</dep:artifactId>
>            <dep:version>1.0</dep:version>
>            <dep:type>car</dep:type>
>        </dep:moduleId>
>        <dep:dependencies>
>            <dep:dependency>
>                <dep:groupId>postgresql</dep:groupId>
>                <dep:artifactId>postgresql-8.2</dep:artifactId>
>                <dep:version>508.jdbc3</dep:version>
>                <dep:type>jar</dep:type>
>            </dep:dependency>
>        </dep:dependencies>
>    </dep:environment>
>    <resourceadapter>
>        <outbound-resourceadapter>
>            <connection-definition>
> 
> <connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
>                <connectiondefinition-instance>
>                    <name>testmydb</name>
>                    <config-property-setting
> name="DatabaseName">walmart0192</config-property-setting>
>                    <config-property-setting
> name="Password"></config-property-setting>
>                    <config-property-setting
> name="UserName">itmgr</config-property-setting>
>                    <config-property-setting
> name="ServerName">192.168.0.10</config-property-setting>
>                    <config-property-setting name="PrepareThreshold"/>
>                    <connectionmanager>
>                        <local-transaction/>
>                        <single-pool>
>                            <max-size>10</max-size>
>                            <min-size>0</min-size>
>                            <match-one/>
>                        </single-pool>
>                    </connectionmanager>
>                </connectiondefinition-instance>
>            </connection-definition>
>        </outbound-resourceadapter>
>    </resourceadapter>
> </connector>
> 
> but i always get the exception:
> 
> 80041:  2010-07-15 21:30:06,442 ERROR [CategoryEJB]
> javax.naming.NotContextException: jdbc/testmydb
> 
> Note that I am not running a web app, just an EJB backend, so I am not
> configuring anything in web.xml.  is the configuration in web.xml required?
> I tried it and its the same result, but I would like to rule this out, that
> web.xml resource-ref config is not required if not running in a web app.
> 
> The JNDI name under geronimo's JNDI viewer is: (resource adapters)
> console.dbpool/testmydb/1.0/car
> 
> also shows:
> jca:/default/wakapeek-persist-ear/JCAManagedConnectionFactory/testmydb
> 
> In the geronimo deployment plan i have a connector defined:
> 
> <app:module>
>  <app:connector>tranql-connector-postgresql-local-1.2.rar</app:connector>
>  <app:alt-dd>testmydb.xml</app:alt-dd>
> </app:module>
> 
> Using dbpool in the geronimo console, i can query this database just fine.'
> 
> Any ideas?  Thanks alot.
> Billy
> 
> 
> 
> --
> View this message in context: http://apache-geronimo.328035.n3.nabble.com/Geronimo-2-2-Spring-Hibernate-and-a-Geronimo-managed-DB-Pool-with-XA-driver-tp874759p971182.html
> Sent from the Users mailing list archive at Nabble.com.
> 
> 
> 
> -- 
> Ivan


Mime
View raw message