2 Replies Latest reply on Jan 29, 2007 12:17 PM by Grigoriy Zaspa

    How to connect my EJB to firebird database?

    Grigoriy Zaspa Newbie

      Hello,

      Can anybody explain me how I can connect an EJB from my application to Firebird database? I copied firebird-ds.xml and jaybird-2.1.1.rar to deploy folder, corrected firebird-ds.xml. What should I do to use this new datasource in my EJB?

        • 1. Re: How to connect my EJB to firebird database?
          Andrew Dale Newbie

          Hi,

          You need to configure a persistence.xml file and then pack it in the META-INF dir of the ejb jar. The persistence.xml will look somethjing like so:

          <?xml version="1.0" encoding="UTF-8"?>
          <persistence>
           <persistence-unit name="myPU">
           <jta-data-source>java:/<you firebird ds name></jta-data-source>
           <class><managed class name></class>
           <properties>
           <property name="hibernate.dialect" value="org.hibernate.dialect.FirebirdDialect"/>
           <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
           </properties>
           </persistence-unit>
          </persistence>


          You can then inject an EntityManager with the @PersistenceContext annotation within a Session bean.

          Cheers,

          Andy

          • 2. Re: How to connect my EJB to firebird database?
            Grigoriy Zaspa Newbie

            I do about that and try to do the simplest way. My persistence.xml is
            <?xml version="1.0" encoding="UTF-8"?>
            <persistence-unit name="order" transaction-type="JTA">
            <jta-data-source>java:/FIrebirdDS</jta-data-source>
            </persistence-unit>

            My EJB begins with:
            @Stateless
            @RemoteBinding(jndiBinding="ejb/Person")
            public class PersonBean implements Person {

            //@PersistenceContext EntityManager em;

            When I deploy my .ear with this EJB, I get an error message in JBoss console with the last part:
            --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
            ObjectName: jboss.jca:name=FIrebirdDS,service=DataSourceBinding
            State: NOTYETINSTALLED
            Depends On Me:
            persistence.units:ear=EJB3Test.ear,jar=EJB3Test.jar,unitName=order
            persistence.units:ear=EJB3Test.ear,jar=EJB3Test.jar,unitName=order
            persistence.units:ear=EJB3Test.ear,jar=EJB3Test.jar,unitName=order

            But nevertheless .ear is deployed and I can reach my PersonBean EJB from a remote client on JNDI name and call it's business method. But as soon as I uncomment
            //@PersistenceContext EntityManager em;
            and redeploy my .ear, I cannot reach PersonBean EJB any more -
            Object ref = context.lookup("ejb/Person"); in my client generates NameNotFoundException