5 Replies Latest reply on Feb 9, 2007 9:47 PM by changemylife

    look Database not effect (Urgent). Please!

    changemylife

      Hi all !
      I am using jboss-4.0.5.GA. I install MySQL and JBoss Server on the same machine. When I install JBoss server, I select mysql, so I need only copy driver "mysql-connector-java-3.1.14-bin.jar" to ..\server\lib and don't need edit file hsqldb-ds.xml (inside ..\server\default\deploy). Am I right?
      When I restart server, I see some messages:
      ...
      11:15:39,632 INFO [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=QuocThaiDS' to JNDI name 'java:QuocThaiDS
      ...
      My ejb-jar.xml:
      ----
      <res-ref-name>jdbc/QuocThaiDS</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      ----
      login-config.xml:
      ----
      <application-policy name="DB-Domain">

      <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
      <module-option name="dsJndiName">java:QuocThaiDS</module-option>
      <module-option name="principalsQuery">
      select passwd from Users where username=?</module-option>
      <module-option name="rolesQuery">
      select Role, 'Roles' from Roles where username=?</module-option>
      </login-module>

      </application-policy>
      ----
      jboss.xml:
      ----
      ...
      <security-domain>DB-Domain</security-domain>
      <enterprise-beans>

      <ejb-name>Hello</ejb-name>
      <resource-ref>
      <res-ref-name>jdbc/QuocThaiDS</res-ref-name>
      <jndi-name>java:QuocThaiDS</jndi-name>
      </resource-ref>

      </enterprise-beans>
      ...
      ----
      But, on the other machine, I lookup:
      DataSource ds = (DataSource) ctx.lookup("java:/comp/env/jdbc/QuocThaiDS");
      I received some messages: comp not bound.
      Have any ideals ? Thanks.

        • 1. Re: look Database not effect (Urgent). Please!
          jaikiran

           

          But, on the other machine, I lookup:


          You mean, you have deployed the datasource on one machine and looking it up from another(remote) machine?



          • 2. Re: look Database not effect (Urgent). Please!
            changemylife

            Hi all !
            Yes! And it's wrong (I read some documents today). The main problem is inside my jboss.xml, all things not effect (and DatabaseServerLoginModule not effect).
            JBoss server and mySql installed on the same machine (ex: hostname is "violon"), on the other machine (ex: hostname is "abc"). And on the "abc", I write the client app to transfer username and password to server. (I deployed my bean on "violon").
            Please guide to me !
            Thanks.

            • 3. Re: look Database not effect (Urgent). Please!
              changemylife

              Hello world !
              Today, I try all things again but I also failure.
              When I install JBoss server, I selected mysql and DataSource name is: DefaultDS, and I created "mydatabase" that include Users and Roles. My code on the client have contents:
              -----
              LoginContext lc = new LoginContext("userTest", new MyCallbackHandler());
              lc.login();
              .....
              props.put("java.naming.provider.url","jnp://violon:1099");
              InitialContext ctx = new InitialContext(props);
              Operates obj = (Operates)ctx.lookup("OperatesBean/remote");
              ...... and here, I do two methods that correlative each role
              -----
              But after I enter username and passwd, on the server don't check informations of the specify person that I entered (username and passwd). This is mean, the DatabaseServerLoginModule that I declare inside file "login-config.xml" not effect. And when, any informations that I enter can call two methods ! I am sure that JBoss server bound DataSource beacause when I run Server, I saw the fragment message:
              -----
              11:15:39,632 INFO [WrapperDataSourceService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS '
              -----
              My auth.config on the client has contents:
              -----
              userTest {
              org.jboss.security.ClientLoginModule required;
              };
              -----
              My ejb-jar.xml has contents:
              -----
              <enterprise-beans>

              <ejb-name>Operates</ejb-name>
              <resource-ref>
              <res-ref-name>DefaultDS</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
              </resource-ref>

              </enterprise-beans>
              .....here, I declared roles and permissions
              -----
              My jboss.xml has:
              -----
              <security-domain>DB-Domain</security-domain>
              <enterprise-beans>

              <ejb-name>Operates</ejb-name>
              <resource-ref>
              <res-ref-name>DefaultDS</res-ref-name>
              <jndi-name>java:/DefaultDS</jndi-name>
              </resource-ref>

              </enterprise-beans>
              -----
              And the login-config.xml:
              -----
              <application-policy name="DB-Domain">

              <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
              <module-option name="dsJndiName">java:/DefaultDS</module-option>
              <module-option name="principalsQuery">
              select passwd from Users where username=?</module-option>
              <module-option name="rolesQuery">
              select Role, 'Roles' from Roles where username=?</module-option>
              </login-module>

              </application-policy>
              -----
              I don't know that why server not recognize all things that I declare inside jboss.xml and login-config.xml ?

              • 4. Re: look Database not effect (Urgent). Please!
                peterj

                In jboss-web.xml, the security domain entry should read:

                <security-domain>java:/jaas/DB-Domian</security-domain>


                By the way, your posts would be easier to read if code was offset using the [ code ] tags.

                • 5. Re: look Database not effect (Urgent). Please!
                  changemylife

                  Hi!
                  Previous, I tested the UsersRolesLoginModule inside the jboss.xml. I also

                  <security-domain>java:/jaas/DB-Domian</security-domain>
                  but not effect. Then, I try used
                  DB-Domain
                  , all things ok.
                  Now, I also by your way is
                  <security-domain>java:/jaas/DB-Domian</security-domain>
                  and
                  <security-domain>DB-Domain</security-domain>
                  but not effect !
                  I don't use web server. I write a simple bean and deploy it on the "Violon"(hostname) machine. And write the client on the "abc" machine. I am using Eclipse to edit my project. When I use Eclipse to packing my bean to .jar file. Have two cases:
                  1. File ejb-jar.xml inside META-INF, two files "jboss.xml" and "login-config.xml" outside META-INF. Any informations (username and passwd) that I enter can able call any method on the my bean.
                  2. Three file: "ejb-jar.xml", "jboss.xml" and "login.config.xml" inside META-INF, I received some messages:
                  Exception in thread "main" javax.ejb.EJBAccessException: Authentication failure

                  .....
                  Caused by: javax.security.auth.login.LoginException: Missing users.properties file.

                  ....
                  althought I entered username and passwd correct with my database (Users and Roles tables).
                  have any ideals ? Thanks.