You may like to take a look at the following blog:
http://blogs.sun.com/swchan/entry/jdbcrealm_in_glassfish_with_mysql
Shing Wai Chan
On 9/1/10 9:36 AM, glassfish_at_javadesktop.org wrote:
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>