geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Olivier Voutat" <olivier.vou...@gmail.com>
Subject Re: Using Firebird through Jaybird in a JEE application in Geronimo
Date Mon, 20 Feb 2006 00:55:29 GMT
Like this so:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_15" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>AgendaWeb</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    <servlet>
        <servlet-name>Controle</servlet-name>
        <servlet-class>br.cefetrn.olivier.servlet.ControladorServlet
</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Controle</servlet-name>
        <url-pattern>/control</url-pattern>
    </servlet-mapping>
    <ejb-ref>
        <ejb-ref-name>Agenda</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <home>br.cefetrn.olivier.ejb.AgendaHome</home>
        <remote>br.cefetrn.olivier.ejb.Agenda</remote>
        <ejb-link>Agenda</ejb-link>
    </ejb-ref>
</web-app>

Question: It is more eficient to use a Database Pool or Entity-Beans ?

Best Regards
Olivier

On 2/19/06, Aaron Mulder <ammulder@alumni.princeton.edu> wrote:
>
> The way you're trying to call the EJB is normally used for application
> clients.  For a web application, you should declare an ejb-ref in your
> web.xml, and include an ejb-link in the ejb-ref that points to the
> name of the EJB.
>
> Thanks,
>     Aaron
>
> On 2/19/06, Olivier Voutat <olivier.voutat@gmail.com> wrote:
> > Thanks again Aaron, I included that lines and now the deploy works
> > BUT....(there is always a BUT) now I have another problem. When I call
> the
> > Agenda ejb it is saying that it is not there....Don't know why since it
> > worked before...
> >
> > javax.naming.NameNotFoundException: Agenda
> >
> > my ejb-jar.xml:
> >
> > <session id="Session_Agenda">
> >          <description><![CDATA[A session bean named
> Agenda]]></description>
> >          <display-name>Agenda</display-name>
> >
> >          <ejb-name>Agenda</ejb-name>
> >
> >          <home>br.cefetrn.olivier.ejb.AgendaHome</home>
> >          <remote>br.cefetrn.olivier.ejb.Agenda </remote>
> >
> > <ejb-class>br.cefetrn.olivier.ejb.AgendaBean</ejb-class>
> >          <session-type>Stateless</session-type>
> >          <transaction-type>Container</transaction-type>
> >          <resource-ref>
> >                 <res-ref-name>MyDatabase</res-ref-name>
> >                <res-type>javax.sql.DataSource</res-type>
> >                <res-auth>Container</res-auth>
> >
> > <res-sharing-scope>Shareable</res-sharing-scope>
> >          </resource-ref>
> >       </session>
> >
> > My servlet which calls the bean:
> >         Properties p = new Properties();
> >         p.put("java.naming.factory.initial",
> >
> > "org.openejb.client.RemoteInitialContextFactory");
> >
> >         p.put("java.naming.provider.url",
> >             "localhost:4201");
> >
> >         p.put("java.naming.security.principal",
> >             "system");
> >
> >         p.put("java.naming.security.credentials",
> >             "manager");
> >
> >          //-----Obtem o contexto inicial JNDI----------
> >         InitialContext ctx = new InitialContext(p);
> >
> >          // ------Pega a referencia do objeto home--------
> >         Object obj = ctx.lookup("Agenda");
> >         // tried too Object obj = ctx.lookup("java:comp/Agenda");
> >
> >         AgendaHome home = (AgendaHome)obj;
> >         Agenda agenda = home.create();
> >
> > And a doubt that I have. For a Database pool beeing really useful, it
> should
> > be used by a ejb ? I think that because if u call it in a simple class,
> that
> > one will receive all the requests from all the ejbs and the Database
> Pool
> > won't be so practical.
> >
> > Olivier Voutat
> >
> >
> > On 2/19/06, Aaron Mulder <ammulder@alumni.princeton.edu> wrote:
> > > You left out the namespace and configId and other stuff that has to go
> > > in the first openejb-jar element.  There's an example with everything
> > > you might need here:
> > >
> > > http://chariotsolutions.com/geronimo/ejb-overview.html
> > >
> > > Of that, you probably just need the xmlns and configId for now.
> > >
> > > Thanks,
> > >     Aaron
> > >
> > > On 2/19/06, Olivier Voutat < olivier.voutat@gmail.com> wrote:
> > > > So, I created my openejb-jar.xml in the same folder (META-INF) that
> my
> > > > ejb-jar.xml was, like this:
> > > >
> > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > <openejb-jar>
> > > >     <enterprise-beans>
> > > >         <session>
> > > >             <ejb-name>Agenda</ejb-name>
> > > >             <resource-ref>
> > > >                 <ref-name>MyDatabase</ref-name>
> > > >
> > <resource-link>AgendaEJB</resource-link>
> > > >             </resource-ref>
> > > >         </session>
> > > >     </enterprise-beans>
> > > > </openejb-jar>
> > > >
> > > > But when I try to deploy Geronimo says:
> > > >
> > > > Currently a Geronimo deployment plan is required for an EJB module.
> > Please
> > > > provide a plan as a deployer argument or packaged in the EJB JAR at
> > > > META-INF/openejb- jar.xml
> > > >
> > > > ???
> > > >
> > > > Olivier
> > > >
> > > >
> > > > On 2/18/06, Aaron Mulder <ammulder@alumni.princeton.edu> wrote:
> > > > > The openejb-jar.xml file goes in META-INF/ of the EJB JAR next to
> > > > ejb-jar.xml.
> > > > >
> > > > > The header block and a variety of possible content is here:
> > > > >
> > > > > http://chariotsolutions.com/geronimo/ejb.html
> > > > >
> > > > > But if you didn't have this file before, you probably don't need
> much
> > > > > but the header, footer, and the bits I gave in the example.  In
> > > > > particular, you don't need to list a particular EJB there if you
> don't
> > > > > have any special settings for it.
> > > > >
> > > > > Thanks,
> > > > >     Aaron
> > > > >
> > > > > On 2/18/06, Olivier Voutat < olivier.voutat@gmail.com> wrote:
> > > > > > Thanks Aaron but I have a last little question, I never used
> until
> > now
> > > > this
> > > > > > openejb-jar.xml...
> > > > > >
> > > > > > I only have application.xml, geronimo-application.xml in the
EAR
> and
> > the
> > > > > > ejb-jar.xml in the EJB module.
> > > > > >
> > > > > > There is someplace else where I can put it or I must create
this
> > > > > > openejb-jar.xml ? If so could you give me an example of how
it
> > should
> > > > look
> > > > > > like.
> > > > > >
> > > > > > Best Regards,
> > > > > > Olivier Voutat
> > > > > >
> > > > > >
> > > > > > On 2/18/06, Aaron Mulder < ammulder@alumni.princeton.edu>
wrote:
> > > > > > >
> > > > > > > In ejb-jar.xml you add a resource-ref entry in the section
> where
> > you
> > > > > > > declare your bean, so it looks like this:
> > > > > > >
> > > > > > > <ejb-jar ...>
> > > > > > >   <enterprise-beans>
> > > > > > >     <session>
> > > > > > >       <ejb-name>Foo</ejb-name>
> > > > > > >       ...
> > > > > > >       <resource-ref>
> > > > > > >         <res-ref-name>MyDatabase</res-ref-name>
> > > > > > >         <res-type>javax.sql.DataSource</res-type>
> > > > > > >         <res-auth>Container</res-auth>
> > > > > > >
> > > > <res-sharing-scope>Shareable</res-sharing-scope>
> > > > > > >       </resource-ref>
> > > > > > >     </session>
> > > > > > >   </enterprise-beans>
> > > > > > > </ejb-jar>
> > > > > > >
> > > > > > > Then in your openejb-jar.xml you add a section to point
that
> to a
> > > > > > > specific database pool (where ref-name matches res-ref-name
in
> > > > > > > ejb-jar.xml , and resource-link matches the name of the
> database
> > pool
> > > > > > > as you configured it in the console):
> > > > > > >
> > > > > > > <openejb-jar ...>
> > > > > > >   <enterprise-beans>
> > > > > > >     <session>
> > > > > > >       <ejb-name>Foo</ejb-name>
> > > > > > >       ...
> > > > > > >       <resource-ref>
> > > > > > >         <ref-name>MyDatabase</ref-name>
> > > > > > >
> > <resource-link>PostgreSQLPool</resource-link>
> > > > > > >       </resource-ref>
> > > > > > >     </session>
> > > > > > >   </enterprise-beans>
> > > > > > > </openejb-jar>
> > > > > > >
> > > > > > > Finally, in your EJB code, you look up the data source
in JNDI
> > like
> > > > > > > this, where the JNDI name is "java:comp/env/" plus the
> > res-ref-name
> > > > > > > you used in ejb-jar.xml:
> > > > > > >
> > > > > > > Context ctx = new InitialContext();
> > > > > > > Object obj = ctx.lookup("java:comp/env/MyDatabase");
> > > > > > > DataSource ds = (DataSource)obj;
> > > > > > > Connection con = ds.getConnection();
> > > > > > >
> > > > > > > If you want to access the database pool from a web component
> like
> > a
> > > > > > > servlet, you have to add a similar resource reference to
> web.xml
> > and a
> > > > > > > similar block to resolve it to a database pool to
> geronimo-web.xml
> > and
> > > > > > > the code would look the same.
> > > > > > >
> > > > > > > Thanks,
> > > > > > >     Aaron
> > > > > > >
> > > > > > > On 2/17/06, Olivier Voutat < olivier.voutat@gmail.com>
wrote:
> > > > > > > > Thanks Aaron,
> > > > > > > >
> > > > > > > > This worked perfectly, but now I have a little problem....u
> made
> > me
> > > > get
> > > > > > > > curious about using a database pool... u see I'm a
student
> of
> > > > computer
> > > > > > > > sciences in Brazil and we use Java as our main programming
> > language.
> > > > Our
> > > > > > > > teacher uses JBoss, and since I knew Geronimo now
I call it
> > JBosta
> > > > > > (meaning
> > > > > > > > Jshit, sorry the word)...
> > > > > > > >
> > > > > > > > I easily create the database pool but how should I
configure
> my
> > ejb
> > > > to
> > > > > > be
> > > > > > > > able to use it ?
> > > > > > > >
> > > > > > > > David, the tip that Aaron gaved me is very easy to
use and
> works
> > > > > > perfectly
> > > > > > > > for Jaybird for simple connections.
> > > > > > > >
> > > > > > > >  Olivier
> > > > > > > >
> > > > > > > >
> > > > > > > > On 2/17/06, Aaron Mulder < ammulder@alumni.princeton.edu>
> wrote:
> > > > > > > > > Ah, I see...  If you don't want to use the connection
pool
> > then
> > > > the
> > > > > > > > > technique is a little different.  You need a
<dependency>
> > element
> > > > in
> > > > > > > > > the Geronimo deployment plan for your J2EE module
(e.g.
> > > > > > > > > geronimo-web.xml for a web app).
> > > > > > > > >
> > > > > > > > > If you want to know exactly what the dependency
element
> should
> > > > look
> > > > > > > > > like you can go through the database pool screen
in the
> > console
> > > > just
> > > > > > > > > like you did and then after you test it hit "Show
Plan"
> > instead of
> > > > > > > > > deploying the pool, and just take the <depenency>
element
> from
> > out
> > > > of
> > > > > > > > > that plan, and put it in the plan for your J2EE
module
> > instead.
> > > > It's
> > > > > > > > > not necessary to go through the console this
way, but
> it'll
> > give
> > > > you
> > > > > > > > > somethign to copy and paste exactly.  :)  Anyway,
it'll be
> > > > something
> > > > > > > > > like this, depending on exactly where you put
it in the
> > > > repository:
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > >
> > > >
> > <dependency><url>something/jaybird-full/2.0.1/jar</uri></dependency>
> > > > > > > > >
> > > > > > > > > Thanks,
> > > > > > > > >     Aaron
> > > > > > > > >
> > > > > > > > > On 2/17/06, Olivier Voutat < olivier.voutat@gmail.com>
> wrote:
> > > > > > > > > > Hi again,
> > > > > > > > > >
> > > > > > > > > >  For those who doesn't know, I'm trying
to establish a
> > > > connection
> > > > > > > > between my
> > > > > > > > > > J2EE application and Firebird Database using
> > > > > > Jaybird-2.0.1JDK_1.5.zip
> > > > > > > > > >
> > > > > > > >
> > > > > >
> > > >
> > http://firebird.sourceforge.net/index.php?op=files&id=jaybird
> > > > > > > > > >
> > > > > > > > > >  (yeah,yeah, I know that Geronimo is only
certified for
> J2EE
> > 1.4
> > > > but
> > > > > > so
> > > > > > > > far
> > > > > > > > > > it hasn't be a big issue).
> > > > > > > > > >
> > > > > > > > > >  Extra information: The application that
I'm testing
> already
> > > > worked
> > > > > > > > under
> > > > > > > > > > Geronimo using a connection to Firebird
through unixODBC
> > without
> > > > a
> > > > > > > > database
> > > > > > > > > > pool.
> > > > > > > > > >
> > > > > > > > > >  Thanks everybody who replied. Didn't understand
very
> well
> > your
> > > > .rar
> > > > > > > > issue
> > > > > > > > > > David, but anyway here is my situation:
> > > > > > > > > >
> > > > > > > > > >  I wasn't trying to create a database pool
to do a
> > connection
> > > > (it is
> > > > > > > > really
> > > > > > > > > > necessary ?).
> > > > > > > > > >  I was trying to make the jaybird-full-2.0.1.jaravaliable
> > to my
> > > > > > J2EE.
> > > > > > > > > >
> > > > > > > > > >  Current situation, I created a database
pool connection
> > with
> > > > the
> > > > > > > > Database
> > > > > > > > > > Type "Other".
> > > > > > > > > >  In the next config page I put:
> > > > > > > > > >
> > > > > > > > > >  JDBC Driver Class: org.firebirdsql.jdbc.FBDriver
> > > > > > > > > > Driver JAR: jaybird-full-2.0.1.jar (deployed
in the
> > repository
> > > > > > trough
> > > > > > > > the
> > > > > > > > > > common libraries page)
> > > > > > > > > > JDBC Connect URL:
> > > > > > > > > >
> > > > > > > >
> > > > > >
> > > >
> > jdbc:firebirdsql:localhost/3050:/firebirdData/mydatabase.fdb
> > > > > > > > > >  DB User Name: *******
> > > > > > > > > >  DB Password: *******
> > > > > > > > > >
> > > > > > > > > >  After that I did a "Test Connection" and
no problem
> alert
> > was
> > > > given
> > > > > > so
> > > > > > > > I
> > > > > > > > > > deployed it.
> > > > > > > > > >
> > > > > > > > > >  Deployed my application and it stills gives
me the
> message
> > > > > > > > > > ClassNotFoundException...
> > > > > > > > > >
> > > > > > > > > >  Olivier Voutat
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On 2/17/06, David Jencks < david_jencks@yahoo.com>
> wrote:
> > > > > > > > > > >
> > > > > > > > > > > On Feb 16, 2006, at 6:22 PM, Olivier
Voutat wrote:
> > > > > > > > > > >
> > > > > > > > > > > > I'm not getting how to install
the driver to make
> this
> > one
> > > > > > > > > > > > avaliable to my applications in
Geronimo. Tried many
> > ways,
> > > > and
> > > > > > > > > > > > can't find a way that makes it
works. Didn't find
> any
> > > > documents
> > > > > > > > > > > > about it neither.
> > > > > > > > > > > >
> > > > > > > > > > > > Can somebody help me about it
?
> > > > > > > > > > >
> > > > > > > > > > > I tried deploying the latest rar from
the downloads,
> but
> > it
> > > > has a
> > > > > > > > > > > problem in ra.xml (see firebird issue
1433327).  I
> fixed
> > the
> > > > > > problem
> > > > > > > > > > > in firebird cvs, so if you build the
rar yourself it
> will
> > > > work.
> > > > > > > > > > > (I'll also send you a copy privately).
 If you want to
> use
> > > > > > something
> > > > > > > > > > > closer to the current release, you
need to change in
> > ra.xml
> > > > > > > > > > >
> > > > > > > > > > >        <credential-
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > >
> > > > interface>javax.resource.security.PasswordCredential
> > > > > > </credential-
> > > > > > > > > > > interface>
> > > > > > > > > > > to
> > > > > > > > > > >        <credential-
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > >
> > > > > >
> > > >
> > interface>javax.resource.spi.security.PasswordCredential
> > > > > > </credential-
> > > > > > > > > > > interface>
> > > > > > > > > > >
> > > > > > > > > > > and repack the rar.
> > > > > > > > > > >
> > > > > > > > > > > Anyway, after obtaining a correct rar,
you can modify
> the
> > plan
> > > > I
> > > > > > will
> > > > > > > > > > > also send privately to suit your environment
and
> deploy to
> > a
> > > > > > running
> > > > > > > > > > > server using
> > > > > > > > > > >
> > > > > > > > > > > java -jar target/geronimo- 1.1-SNAPSHOT
> /bin/deployer.jar
> > > > --user
> > > > > > system
> > > > > > > > > > > --password manager deploy jaybird-2.1.0.rar
> > jaybird-plan.xml
> > > > > > > > > > >
> > > > > > > > > > > This deployed OK for me but I don't
have a firebird
> > > > installation
> > > > > > > > > > > handy so I don't know if there are
other
> problems.  Please
> > let
> > > > me
> > > > > > > > > > > know of your progress, I would like
there to be a wiki
> > page on
> > > > > > using
> > > > > > > > > > > firebird/jaybird with Geronimo.
> > > > > > > > > > >
> > > > > > > > > > > If anyone else would like a copy of
the plan I can
> perhaps
> > get
> > > > > > > > > > > started on the wiki page and attach
it there.
> > > > > > > > > > >
> > > > > > > > > > > thanks
> > > > > > > > > > > david jencks
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Olivier
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > Olivier & Cidiane Voutat
> > > > > > > > > > Rua Praia de Muri�, 9188
> > > > > > > > > > Cep 59092-390 / Natal - RN
> > > > > > > > > > Tel: (84) 3219-0427 Cel: (84) 9977-3917
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > >
> > > > > > > > Olivier & Cidiane Voutat
> > > > > > > > Rua Praia de Muri�, 9188
> > > > > > > > Cep 59092-390 / Natal - RN
> > > > > > > > Tel: (84) 3219-0427 Cel: (84) 9977-3917
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Olivier & Cidiane Voutat
> > > > > > Rua Praia de Muri�, 9188
> > > > > >
> > > > > > Cep 59092-390 / Natal - RN
> > > > > > Tel: (84) 3219-0427 Cel: (84) 9977-3917
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Olivier & Cidiane Voutat
> > > > Rua Praia de Muriú, 9188
> > > >
> > > > Cep 59092-390 / Natal - RN
> > > > Tel: (84) 3219-0427 Cel: (84) 9977-3917
> > >
> >
> >
> >
> > --
> >
> > Olivier & Cidiane Voutat
> > Rua Praia de Muriú, 9188
> > Cep 59092-390 / Natal - RN
> > Tel: (84) 3219-0427 Cel: (84) 9977-3917
>



--
Olivier & Cidiane Voutat
Rua Praia de Muriú, 9188
Cep 59092-390 / Natal - RN
Tel: (84) 3219-0427 Cel: (84) 9977-3917
Mime
View raw message