> From: David Blevins <[email protected]>
> If you want to do things the portable way, your bean has to declare a
> reference to the resource via xml or annotation:
>
> http://openejb.apache.org/3.0/resource-ref-for-datasource.html
>
> This doc is still a work in progress, but has some info on Java EE and JNDI:
>
> http://openejb.apache.org/3.0/basics-getting-things.html
I'm confused.
- Re: link #1 above. The example code is NOT passing parameters to the "new
InitialContext()" call as explained to do for JUnit testing elsewhere. From
link #2, I understand this to be necessary if I want to make use of the
"java:/comp/env..." naming used throughout my code base. What I don't
understand is how do I use a parameter-less constructor call in JUnit and get
OpenEJB to load up when I do so?
- If that is not possible, then what tricks do you use that allows the code to
work in the container when deployed (JBoss in my case), but will still work
with
OpenEJB in JUnit?
Still trying to get some sort of xml configuration to work for 'a more portable
way', I've stubbed out the following ejb-jar.xml. It loads w/o errors, but I
can still only do lookups using "openejb:Resource/WTSHARE" for my datasource
and
the simple class name for the EJBs (i.e. just "AdvisorListFacadeLocal" not
"java:comp/env/AdvisorListFacade" as desired). Given this xml, I can now do
two
different lookups on my EJB, the one identified in the xml below, and the
auto-loaded name set by OpenEJB.
ic.lookup("AdvisorListBeanLocal"); // via XML
ic.lookup("AdvisorListFacadeLocal");// via auto-load by OpenEJB
<?xml version="1.0"?>
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>AdvisorListBean</ejb-name>
<business-local>com.dstsystems.walletshare.ejb.facade.AdvisorListFacadeLocal</business-local>
<ejb-class>com.dstsystems.walletshare.ejb.jdbc.AdvisorListFacade</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
<resource-ref>
<res-ref-name>WTSHARE</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Application</res-auth>
</resource-ref>
</session>
</enterprise-beans>
</ejb-jar>
Where am I going wrong?