5 Replies Latest reply on Jun 23, 2003 9:54 AM by jfradkin

    Exception in main: WazaguaDS not bound

    jfradkin Newbie

      I swear I had this workin, so I have no idea what I did to break it. I also noticed I could not seem to get another example working that was similiuar so may be something configuration rather then code.

      I am lost I wish I understood this better. It sure looks ike the console says the datasource is in JNDI? Am I looking it up wrong? Configuring something wrong?
      I thought i had it working (originally I did not have the client classes from Jboss client so I wasa getting class needs define errors). WHen I figured that out I had it working from the examples in the forum . I went and made my EJB from based on the tutorial on Jboss IDE. I got it working ok but when I went to add the database part (was working, did not change the code at all. All it did was do a JNDI lookup on the data source) it no longer works. Sorry to ask such dumb questions, but I spent a deal of time reading and trying to see the issue, maybe some one with more experience could take a glance at the error and the datasource file in deploy and give me some idea what is wrong. I just want to get it working from a client befor I try it as a bean.

      Thanx Joel

      The code is :
      Context ctx = new InitialContext();
      DataSource ds = (DataSource)ctx.lookup("java:/WazaguaDS");

      here is my mssql-ds.xml

      <local-tx-datasource>
      <jndi-name>WazaguaDS</jndi-name>
      <connection-url>jdbc:microsoft:sqlserver://192.168.123.110:1433;DatabaseName=wazagua;SelectMethod=cursor</connection-url>
      <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
      <min-pool-size>10</min-pool-size>
      <max-pool-size>100</max-pool-size>
      <user-name>user</user-name>
      password
      </local-tx-datasource>


      I can even look in cosole under JNDI and see:
      java:

      SecurityProxyFactory
      org.jboss.security.SubjectSecurityProxyFactory


      DefaultJMSProvider
      org.jboss.jms.jndi.JBossMQProvider


      comp
      javax.naming.Context


      WazaguaDS
      org.jboss.resource.adapter.jdbc.WrapperDataSource


      JmsXA
      org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl

        • 1. Re: Exception in main: WazaguaDS not bound
          jfradkin Newbie

          Just to confuse me even more it works fine from the bean deployed in an ear file.

          Argh, can I run this as a plain jain class ?

          Thank you again

          Joel

          • 2. Re: Exception in main: WazaguaDS not bound
            Jon Barnett Master

            You cannot access a datasource from outside the JVM (from a remote client). From a JNDI perspective, the name is bound in an area not visible to external clients. The datasource in any case, manufactures JDBC compatible connections that cannot be used in a proxied sense outside the JVM in which it is created.

            See http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t= for more details from David Jencks.

            • 3. Re: Exception in main: WazaguaDS not bound
              jfradkin Newbie

              Ok so for the java challanged I can not write a class in eclipse that is running Jboss to test my data base stuff.

              I can use the other connection method:

              Class.forName(driver);
              Connection con1 = DriverManager.getConnection(url, username, password);
              Statement stmt = con1.createStatement();

              to test my database functions without having to recompile and deploy to a bean.

              My intent is to use in a bean so in production it will use a pooled connection.

              Sorry for being so uninformed I did a great deal of reading but some of this stuff is just not communicating in a way I understand (no offense, I am just not up to speed yet).

              I swear I had it cranked up the other day but maybe I was hullucinating, for sure I don realy understand the terminology. At the risk of sounding like a total NewB (which I am); what is a VM as it applies to Jboss development? If I understand it at all I think you mean at a minimum it has to be a jar (war, ear) in the deploy directory, but is not a class in eclipse even when Jboss is started using the IDE. Also if I understand what I have read that the proper usage is to get the code happy in a bean that has a close in a finnally and that under normal access opens , does its processing and closes the data connection.
              I appreciate the feedback as I continue to learn what make this environment tick.
              Joel

              • 4. Re: Exception in main: WazaguaDS not bound
                Jon Barnett Master

                OK. Big questions here.

                The Java Virtual Machine (JVM) is the runtime environment for a Java program. So when you start JBoss you are essentially executing:
                java -cp run.jar:/j2sdk14/lib/tools.jar -server org.jboss.Main

                The java command creates a JVM, in which org.jboss.Main can run - and then executes the program from the org.jboss.Main entry point. This bootstraps the JBoss microkernel that runs within this JVM. For SUN JDK installations, the -server tells the JVM to support server type operations, rather than client type operations.

                JBoss is among other things, an EJB container - that is an environment in which EJBs can exist. JBoss also has an embedded servlet container (Jetty or Tomcat), in which servlets and JSPs can exist. It's the Russian dolls analogy. JBoss also has a JNDI service (which you are trying to use to locate resources such as a datasource, an EJB and so on). All these survive with the JVM created by the initial java command.

                Now I'm not too familiar with Eclipse. It may be possible to run JBoss within the same JVM in which Eclipse is running. But I would have thought that things would get very crowded in the one JVM and possible to create crashes.

                I would expect Eclipse to spawn JBoss in it's own JVM - so you would have two JVMs - one running JBoss and one running Eclipse if this happens. Probably your test client would run in it's own JVM so if anything went wrong you wouldn't risk clobbering your IDE's runtime environment.

                So, anything running under the JBoss microkernel will be able to access JNDI names for datasources. Things from any other JVM will not. Note, that a servlet running within the embedded servlet container (Jetty or Tomcat) will be able to access the datasources so this might help you for your testing/experimentation (as well as EJBs of course).

                If you use CMP entity beans, the container will normally take care of connections. In BMP entity beans, and session beans, you take care of connections. In the cases where you have the responsibility, it is good practice to close the connection before you leave the method in which you opened the connection - closing the connection only returns the connection to the pool. As connections from a connection pool are a shared resource, it is best practice to only have the connection open as long as you need it and no more. This ensures that a connection is available for the maximum amount of time.

                Hope that helps somewhat but is by no means an authorative answer.

                • 5. Re: Exception in main: WazaguaDS not bound
                  jfradkin Newbie

                  Many thanks for the explanation. I think I get it. At least it is working in an ear (since this is in the JVM with JNDI services available). Since my ultimate plan is to deploy in that manner I will just develop useing non data source conection and then test it in the bean once i hvae it working. I have several books to read, my problem is I may be dense an example in my own environment is worth a million words to me. Luckily there is much help via this forum and reading old messages has allready helped me a huge amount. My thanks to all of those who tae the time to answer and provide light to those of us still in the dark. Only example I was iunterested in looking at that I did not get running was Turbine. I did get Velocity going in eclipse and J2ee bean in eclipse (thanx to the Jboss IDE tutorial). Thanks again

                  Joel