You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Jaime Geovane Marcondes <ja...@gmail.com> on 2008/06/18 16:34:55 UTC
LocalInitialContextFactory - DataSource JNDI
Hello!
OpenEJB is amazing to boost the development of EJB3.0.
I tried to configure OpenEJB to run in Local Mode, for debugging
purposes. When it runs, the log shows:
javax.naming.NameNotFoundException: Name "jdbc_SecurityDS" not found
I then tried to configure in ejb-jar.xml, but it didn't work.
But the log shows:
2008-06-18 11:22:57,671 - INFO - Creating Resource(id=jdbc_SecurityDS)
And then:
2008-06-18 11:22:58,125 - DEBUG - finished invoking method getMovement with
exception java.sql.SQLException: Name "jdbc_SecurityDS" not found.
My openejb.conf:
<openejb>
<Resource id="jdbc/SecurityDS" type="DataSource">
JdbcDriver oracle.jdbc.driver.OracleDriver
JdbcUrl jdbc:oracle:thin:@xxx.xx.xx.xxx:9921:source
UserName sec_usr
Password sec_usr
</Resource>
<Deployments dir="C:\projects\Services\classes\" />
<Deployments jar="C:\temp\deploy\Services.jar" />
</openejb>
My ejb-jar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>AccountService</ejb-name>
<remote>
acme.com.accountservices.both.iface.AccountServices
</remote>
<ejb-class>
acme.com.accountservices.server.ejb.AccountServicesBean
</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<resource-ref>
<res-ref-name>jdbc/SegurancaDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<auth-type>Container</auth-type>
</resource-ref>
</session>
</enterprise-beans>
</ejb-jar>
Thank's for help!
--
View this message in context: http://www.nabble.com/LocalInitialContextFactory---DataSource-JNDI-tp17984063p17984063.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: LocalInitialContextFactory - DataSource JNDI
Posted by David Blevins <da...@visi.com>.
On Jun 18, 2008, at 7:34 AM, Jaime Geovane Marcondes wrote:
>
> Hello!
>
> OpenEJB is amazing to boost the development of EJB3.0.
Quite a lot of effort goes into making things as easy as possible, so
we definitely appreciate the positive feedback! Thank you!
> I tried to configure OpenEJB to run in Local Mode, for debugging
> purposes. When it runs, the log shows:
>
> javax.naming.NameNotFoundException: Name "jdbc_SecurityDS" not
> found
>
> I then tried to configure in ejb-jar.xml, but it didn't work.
> But the log shows:
>
> 2008-06-18 11:22:57,671 - INFO - Creating
> Resource(id=jdbc_SecurityDS)
>
> And then:
> 2008-06-18 11:22:58,125 - DEBUG - finished invoking method
> getMovement with
> exception java.sql.SQLException: Name "jdbc_SecurityDS" not found.
>
> My openejb.conf:
> <openejb>
> <Resource id="jdbc/SecurityDS" type="DataSource">
> JdbcDriver oracle.jdbc.driver.OracleDriver
> JdbcUrl jdbc:oracle:thin:@xxx.xx.xx.xxx:9921:source
> UserName sec_usr
> Password sec_usr
> </Resource>
>
>
> <Deployments dir="C:\projects\Services\classes\" />
> <Deployments jar="C:\temp\deploy\Services.jar" />
> </openejb>
>
>
> My ejb-jar.xml:
> <?xml version="1.0" encoding="UTF-8"?>
> <ejb-jar>
> <enterprise-beans>
> <session>
> <ejb-name>AccountService</ejb-name>
> <remote>
> acme.com.accountservices.both.iface.AccountServices
> </remote>
> <ejb-class>
> acme.com.accountservices.server.ejb.AccountServicesBean
> </ejb-class>
> <session-type>Stateless</session-type>
> <transaction-type>Container</transaction-type>
> <resource-ref>
> <res-ref-name>jdbc/SegurancaDS</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <auth-type>Container</auth-type>
> </resource-ref>
> </session>
> </enterprise-beans>
> </ejb-jar>
With a resource-ref like that in your ejb-jar.xml, you should be able
to lookup the DataSource from inside the AccountServicesBean like so:
DataSource sequrancaDs = (DataSource) new
InitialContext().lookup("java:comp/env/jdbc/SegurancaDs");
If that doesn't work, post your log output and the full stack trace
and we probably figure out what's going on.
-David