users@glassfish.java.net

JdbcRealm not working. Glassfish v3 and MySQL

From: <glassfish_at_javadesktop.org>
Date: Wed, 01 Sep 2010 09:36:13 PDT

Hi,

I having been trying for two days to get my webapp on glassfish v3 to authenticate to a mysql database.

My web.xml:

<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>
        <servlet-name>Genki</servlet-name>
        <servlet-class>*****.Genki</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>OnlySupers</servlet-name>
        <servlet-class>com.aclandinternet.clients.OnlySupers</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>OnlyRegulars</servlet-name>
        <servlet-class>*****.OnlyRegulars</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Genki</servlet-name>
        <url-pattern>/app/Genki</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>OnlySupers</servlet-name>
        <url-pattern>/app/supers/OnlySupers</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>OnlyRegulars</servlet-name>
        <url-pattern>/app/regulars/OnlyRegulars</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    <security-constraint>
        <display-name>SuperUserConstraint</display-name>
        <web-resource-collection>
            <web-resource-name>superuser</web-resource-name>
            <description/>
            <url-pattern>/app/supers/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <description/>
            <role-name>superuser</role-name>
        </auth-constraint>
    </security-constraint>
    <security-constraint>
        <display-name>RegularUserConstraint</display-name>
        <web-resource-collection>
            <web-resource-name>regularuser</web-resource-name>
            <description/>
            <url-pattern>/app/regulars/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <description/>
            <role-name>regularuser</role-name>
            <role-name>superuser</role-name>
        </auth-constraint>
    </security-constraint>
    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>client_access</realm-name>
    </login-config>
    <security-role>
        <description/>
        <role-name>regularuser</role-name>
    </security-role>
    <security-role>
        <description/>
        <role-name>superuser</role-name>
    </security-role>
</web-app>

sun-web.xml:

<sun-web-app error-url="">
  <context-root>/ClientsDemo</context-root>
  <security-role-mapping>
    <role-name>regularuser</role-name>
    <group-name>regularuser</group-name>
  </security-role-mapping>
  <security-role-mapping>
    <role-name>superuser</role-name>
    <group-name>superuser</group-name>
  </security-role-mapping>
  <class-loader delegate="true"/>
  <jsp-config>
    <property name="keepgenerated" value="true">
      <description>Keep a copy of the generated servlet class' java code.</description>
    </property>
  </jsp-config>
</sun-web-app>

and on glassfish the realm is set to:

com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm

and I have mysql-connector-java-5.1.13-bin.jar in /glassfish/domains/domain1/lib/ext

I have experimented with disabling mysql so that the ping doesn't work from glassfish admin and the same problem persists which I take to mean that the error is not with the database or the mappings from the realm.

Nothing shows in the logs and this is getting really frustrating so I would really appreciate some help,

thanks in advance
[Message sent by forum member 'hacland']

http://forums.java.net/jive/thread.jspa?messageID=481597