tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: HOWTO OpenEJB and HSqlDB
Date Sat, 02 Dec 2006 22:57:52 GMT
Hi Per, the data you've posted helps quite a bit.  I think I have  
your answer....

On Dec 2, 2006, at 12:55 AM, Per Newgro wrote:

> I get the following exception
> javax.naming.NameNotFoundException: Name "java:/APPLDB" not found.
>         at
> org.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:184)
>         at org.openejb.core.ivm.naming.IvmContext.lookup 
> (IvmContext.java:147)
>         at javax.naming.InitialContext.lookup(InitialContext.java:351)
>
> if i do the following:
> DataSource db = (DataSource) myInitialContext.lookup("java:/APPLDB");

...

> file: openejb.conf
> ...
> <Connector id="APPLDB">
...
>     JdbcDriver   org.hsqldb.jdbcDriver
>     JdbcUrl      jdbc:hsqldb:file:conf/default.hsql_database.conf
>     UserName     sa
>     Password
> </Connector>
>
> <Connector id="APPLDBnoTx">
...
>     JdbcDriver   org.hsqldb.jdbcDriver
>     JdbcUrl      jdbc:hsqldb:file:conf/default.hsql_database.conf
>     UserName     sa
>     Password
> </Connector>
> ...

Data sources configured in your openejb.conf... Check.

>
>
> file: openejb-jar.xml
> <?xml version="1.0"?>
> <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1">
>   <ejb-deployment ejb-name="ExportDatabaseUC" deployment- 
> id="ExportDatabaseUC"
>                                    container-id="Default Stateful  
> Container">
>     <resource-link res-ref-name="APPLDB" res-id="APPLDB"/>
>     <resource-link res-ref-name="APPLDBnoTx" res-id="APPLDBnoTx"/>
>   </ejb-deployment>
> </openejb-jar>

Resource refs mapped to configured openejb.conf data sources... Check.
...
>
> file: ejb-jar.xml
> <ejb-jar>
>   <description></description>
>   <enterprise-beans>
>     <session>
>       <ejb-name>ExportDatabaseUC</ejb-name>
>       <home>my.common.ejb.UseCaseHome</home>
>       <remote>my.common.ejb.UseCaseRemote</remote>
>       <ejb-class>my.misc.backup.ejb.ExportDatabaseUcEJB</ejb-class>
>       <session-type>Stateful</session-type>
>       <transaction-type>Bean</transaction-type>
>     </session>
>   </enterprise-beans>
> </ejb-jar>

Resource refs in your ejb-jar.xml file... ERROR ERROR :)

You've got everything you need except you'll want to add the ejb spec  
required resource refs to your ejb-jar.xml file like so:

       <session>
          ...
             <resource-ref>
                 <res-ref-name>APPLDB</res-ref-name>
                 <res-type>javax.sql.DataSource</res-type>
                 <res-auth>Container</res-auth>
             </resource-ref>
             <resource-ref>
                 <res-ref-name>APPLDBnoTx</res-ref-name>
                 <res-type>javax.sql.DataSource</res-type>
                 <res-auth>Container</res-auth>
             </resource-ref>
       </session>

Then you'll be able to look them up from that bean via "java:comp/env/ 
APPLDB" and "java:comp/env/APPLDBnoTx"

On a slightly different note, I'm curious why you'd have two  
connectors with the exact same configuration.

-David





Mime
View raw message