1 2 Previous Next 16 Replies Latest reply on Apr 14, 2002 5:02 PM by barry burnereau

    Oracle and Jboss 2.4.4

    barry burnereau Newbie

      Hi

      I'm using Jboss 2.4.4 and I try to access to a Oracle 8.1 database. I have the classes12.jar (the jar files containing the JDBS classes to connect to Oracle databases). (this file is in /lib/ext)
      But I don't really understand how to configure jboss.jcml

      Is somebody who use this driver could post me all his Jboss.jcml and give me the JNDI of the pool.

      Thank you very much

        • 1. Re: Oracle and Jboss 2.4.4
          barry burnereau Newbie

          I ve forgotten to say that I use Session Bean (bmp).

          • 2. Re: Oracle and Jboss 2.4.4
            Lars Bergmann Newbie

            see http://main.jboss.org/thread.jsp?forum=46&thread=11234

            jndi is "java:/OracleProLounge". we use the datasource (not the resource adapter).

            lars

            • 3. Re: Oracle and Jboss 2.4.4
              barry burnereau Newbie

              what the use of jbosspool-jdbc.rar ?
              Do I need it to connect to oracle ?
              could/should I remove it

              Thank you for your help

              • 4. Re: Oracle and Jboss 2.4.4
                barry burnereau Newbie

                And I still have a problem:
                This is the default Jboss.jcml file:

                org.hsqldb.jdbcDriver



                1476
                true
                default
                false



                DefaultDS
                org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl

                jdbc:hsqldb:hsql://localhost:1476
                1200000
                sa
                10

                false
                false
                false
                true
                120000
                1800000
                false
                false
                1.0
                0


                when Jboss Start, I have:
                [INFO,DefaultDS] Starting
                [INFO,DefaultDS] XA Connection pool DefaultDS bound to java:/DefaultDS
                [INFO,DefaultDS] Started

                but if I try:
                Properties props = new Properties();
                props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                props.put(Context.PROVIDER_URL, "localhost:1099");
                try {
                Context ctx = new InitialContext(props);
                ctx.lookup(java:/DefaultDS);
                }
                ...

                I have:
                javax.naming.NameNotFoundException: DefaultDS not bound

                • 5. Re: Oracle and Jboss 2.4.4
                  Lars Bergmann Newbie


                  > when Jboss Start, I have:
                  > [INFO,DefaultDS] Starting
                  > [INFO,DefaultDS] XA Connection pool DefaultDS bound
                  > to java:/DefaultDS
                  > [INFO,DefaultDS] Started

                  that´s good.

                  > but if I try:
                  > Properties props = new Properties();
                  > props.put(Context.INITIAL_CONTEXT_FACTORY,
                  > "org.jnp.interfaces.NamingContextFactory");
                  > props.put(Context.PROVIDER_URL, "localhost:1099");
                  > try {
                  > Context ctx = new InitialContext(props);
                  > ctx.lookup(java:/DefaultDS);
                  > }

                  what´s this? is this client code (that would not work)?

                  lars

                  • 6. Re: Oracle and Jboss 2.4.4
                    barry burnereau Newbie

                    yes that's an example of the client code

                    • 7. Re: Oracle and Jboss 2.4.4
                      Lars Bergmann Newbie

                      > yes that's an example of the client code

                      hmm, you cannot use it this way: the java:/* namespace is bound to the vm. this is how you look up the datasource within the _server_.

                      what´s the point for looking up a datasource on the client (that would not work anyway)?

                      lars

                      • 8. Re: Oracle and Jboss 2.4.4
                        barry burnereau Newbie

                        I ve not really understand what you mean:
                        ctx.lookup(DefaultDS);
                        or
                        ctx.lookup(/DefaultDS);

                        I have the same problem

                        How should I do get the context ?

                        • 9. Re: Oracle and Jboss 2.4.4
                          Lars Bergmann Newbie


                          my question is _where_ do you want to look up the datasource? server (ejb) or client (eg webclient) ?

                          • 10. Re: Oracle and Jboss 2.4.4
                            barry burnereau Newbie

                            I've tried from the client (inside a JSP, in tomcat, just to try and inside an EJB)

                            I've the same error each time

                            • 11. Re: Oracle and Jboss 2.4.4
                              Lars Bergmann Newbie


                              -> inside a JSP, in tomcat,

                              this does not work (and makes no sense)

                              -> inside an EJB, within the same jboss instance that created and bound the datasource

                              this should work? do you have the same not-bound-error here?

                              lars

                              • 12. Re: Oracle and Jboss 2.4.4
                                barry burnereau Newbie

                                In fact, if i do the lookup in an EJB it works
                                but, I use an object with a static method it does not work
                                Ex:
                                public class DS {
                                public static DataSource getDS(String cle) {
                                Properties props = new Properties();
                                props.put(Context.INITIAL_CONTEXT_FACTORY,
                                "org.jnp.interfaces.NamingContextFactory");
                                props.put(Context.PROVIDER_URL, "localhost:1099");
                                Context ctx = new InitialContext(props);
                                ctx.lookup(cle);
                                ...
                                }
                                }
                                In the EJB I have:
                                DataSource ds = DS.getDS("java:/DefaultDS);

                                And the error is (on the client side):
                                java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
                                java.rmi.ServerException: Exception occurred; nested exception is:
                                javax.ejb.EJBException: null
                                Embedded Exception
                                org.jboss.pool.jdbc.xa.XAPoolDataSource

                                • 13. Re: Oracle and Jboss 2.4.4
                                  Lars Bergmann Newbie

                                  > In fact, if i do the lookup in an EJB it works

                                  here we go

                                  > And the error is (on the client side):
                                  > java.rmi.ServerException: RemoteException occurred in
                                  > server thread; nested exception is:
                                  > java.rmi.ServerException: Exception occurred; nested
                                  > exception is:
                                  > javax.ejb.EJBException: null
                                  > Embedded Exception
                                  > org.jboss.pool.jdbc.xa.XAPoolDataSource

                                  as i said in my previous post: you _cannot_ look up a remote datasource in the client. this does not work (and makes no sense). you access remote business objects (i.e. ejb) from your client (you do not access any remote resources directly).

                                  lars

                                  • 14. Re: Oracle and Jboss 2.4.4
                                    barry burnereau Newbie

                                    Ok for the client

                                    But the Object DS and the getDS() static method is call in the EJB

                                    The error i ve put is the error I have in the client when the ejb call the DS.getDS() method

                                    Client -> EJB -> DS.getDS() -> Error

                                    In the EJB the DS.getDS() is in a try catch, but no error is not caught, and in the getDS() I have a try catch and no error is caught.

                                    When I debug, the error comes inside a class of JBOSS and after the properties.put(Context.PROVIDER_URL, "localhost:1099")


                                    I put my test code, it will be easier:
                                    test client:
                                    public class jndi {

                                    public static void main(String[] args) {

                                    Properties props = new Properties();
                                    props.put(
                                    Context.INITIAL_CONTEXT_FACTORY,
                                    "org.jnp.interfaces.NamingContextFactory");
                                    props.put(Context.PROVIDER_URL, "localhost:1099");

                                    try {
                                    Context ctx = new InitialContext(props);
                                    FirstHome home = (FirstHome) ctx.lookup("ejb/First");
                                    First bean = home.create();
                                    String time = bean.getTime();
                                    }
                                    catch (Exception e) {
                                    System.out.println(e);
                                    }

                                    }
                                    }

                                    EJB:
                                    public class FirstEJB implements SessionBean {


                                    public String getTime() {

                                    obj.test();

                                    return "Time is : " + new Date().toString();
                                    }

                                    public void ejbCreate() {
                                    }
                                    public void ejbPassivate() {
                                    }
                                    public void ejbActivate() {
                                    }
                                    public void ejbRemove() {
                                    }
                                    public void setSessionContext(SessionContext context) {
                                    }
                                    }

                                    And the obj class:
                                    public class obj {

                                    public static void test() {

                                    try {
                                    Properties props = new Properties();
                                    props.put(
                                    Context.INITIAL_CONTEXT_FACTORY,
                                    "org.jnp.interfaces.NamingContextFactory");
                                    props.put(Context.PROVIDER_URL, "localhost:1099");

                                    Context ctx = new InitialContext(props);
                                    ctx.lookup("java:/DefaultDS");
                                    System.out.println("toto");
                                    }
                                    catch (NamingException e) {
                                    System.out.println(e);
                                    }
                                    }
                                    }
                                    I never add the "toto" in the output of JBOSS.
                                    and when I debug, the program never goes after props.put(Context.PROVIDER_URL, "localhost:1099");

                                    1 2 Previous Next