1 Reply Latest reply on Nov 13, 2007 9:28 AM by maximuszen

    Exception sending context initialized event to listener inst

    maximuszen

      Can you help me understand this error? I'm not using Java Server Faces? My code is a hack. I'm missing things conceptually because I'm just putting together some code from whatever I can get my hands on.

      Windows XP, Java SDK 1.5, JBoss 4.2.2

      Here is my code:

      default/conf/login-config.xml

      <application-policy name = "zzz">

      <login-module code = "org.jboss.security.auth.spi.DatabaseServerLoginModule"
      flag = "required">
      <module-option name = "unauthenticatedIdentity">guest</module-option>
      <module-option name = "dsJndiName">java:/PostgresDS</module-option>
      <module-option name = "principalsQuery">SELECT password FROM xuser WHERE username=?</module-option>
      <module-option name = "rolesQuery">SELECT name, 'Roles' FROM role WHERE id = ANY
      ( SELECT role_id FROM user_role WHERE user_id =
      ( SELECT id FROM xuser WHERE username = ? ) )
      </module-option>
      </login-module>

      </application-policy>


      default/conf/auth.conf(I removed this) and
      the VM argument -Djava.security.auth.login.config=auth.conf

      zzz{
      // jBoss ClientLoginModule
      org.jboss.security.auth.spi.DatabaseServerLoginModule required
      ;
      };

      LoginServlet


      public class Login extends Command {
      public String perform(HttpServletRequest request) {
      String username = request.getParameter("u");
      String password = request.getParameter("p");
      UsernamePasswordHandler handler = new UsernamePasswordHandler(username,password);
      Subject subj = null;
      try {
      LoginContext lc = new LoginContext("zzz",handler);
      lc.login();
      } catch (LoginException e1) {
      return error;
      }
      subj = lc.getSubject();
      Log.info("subj = "+subj);
      return ok;
      }
      }
      web.xml in application

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.5"
      xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

      <servlet-name>Security</servlet-name>
      <servlet-class>servlet.Security</servlet-class>


      <servlet-mapping>
      <servlet-name>Security</servlet-name>
      <url-pattern>/s</url-pattern>
      </servlet-mapping>

      <welcome-file-list>
      <welcome-file>index.jsp</welcome-file>
      </welcome-file-list>
      <security-constraint>
      <web-resource-collection>
      <web-resource-name>login</web-resource-name>
      <url-pattern>/s</url-pattern>
      <http-method>GET</http-method>
      <http-method>POST</http-method>
      </web-resource-collection>
      <user-data-constraint>
      <transport-guarantee>CONFIDENTIAL</transport-guarantee>
      </user-data-constraint>
      </security-constraint>
      <login-config>
      <auth-method>BASIC</auth-method>
      <realm-name>zzz</realm-name>
      </login-config>


      The World Street Journal posted a article about how Asian women are flocking to Korea because of the skills of plastic surgeons there. One of my relatives whose in grade school there told me a joke: Why is my wife so beautiful but my son so ugly? (I have a right to make fun of my own people. :)