Skip to main content

JdbcRealm not working. Glassfish v3 and MySQL

2 replies [Last post]
hacland
Offline
Joined: 2007-12-07
Points: 0

Hi,

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

My web.xml:

Genki
*****.Genki

OnlySupers
****.OnlySupers

OnlyRegulars
*****.OnlyRegulars

Genki
/app/Genki

OnlySupers
/app/supers/OnlySupers

OnlyRegulars
/app/regulars/OnlyRegulars

30

index.jsp

SuperUserConstraint

superuser

/app/supers/*

superuser

RegularUserConstraint

regularuser

/app/regulars/*

regularuser
superuser

BASIC
client_access

regularuser

superuser

sun-web.xml:

/ClientsDemo

regularuser
regularuser

superuser
superuser

Keep a copy of the generated servlet class' java code.

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 was edited by: hacland

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Shing Wai Chan

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@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:
>
>
>
> Genki
> *****.Genki
>

>
> OnlySupers
> com.aclandinternet.clients.OnlySupers
>

>
> OnlyRegulars
> *****.OnlyRegulars
>

>
> Genki
> /app/Genki
>

>
> OnlySupers
> /app/supers/OnlySupers
>

>
> OnlyRegulars
> /app/regulars/OnlyRegulars
>

>
>
> 30
>

>

>
> index.jsp
>

>
> SuperUserConstraint
>
> superuser
>
> /app/supers/*
>

>
>
> superuser
>

>

>
> RegularUserConstraint
>
> regularuser
>
> /app/regulars/*
>

>
>
> regularuser
> superuser
>

>

>
> BASIC
> client_access
>

>
>
> regularuser
>

>
>
> superuser
>

>

>
> sun-web.xml:
>
>
> /ClientsDemo
>
> regularuser
> regularuser
>

>
> superuser
> superuser
>

>
>
>
> Keep a copy of the generated servlet class' java code.
>
>

>

>
> 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@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

CasMeiron

Hi,

I think the key is to investigate your mysql tables.

Look my example:

*Table USER*
USERNAME varchar(40) NO PRI (null)
LASTSEEN datetime YES (null)
CREATED datetime YES (null)
EMAIL varchar(100) NO (null)
PASSWORD longblob NO (null)

*T**able USER_ROLE*
ID bigint(20) NO PRI (null) auto_increment
NAME varchar(255) NO (null)
USERNAME varchar(40) YES MUL (null)

Now follow my auth-realm description:

classname="com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm"
name="redirect-realm">

Follow the snippet of my web.xml



admin



user



sip

and my sun-web.xml:


admin

AdminPrincipal admin


user

UserPrincipal user


sip

SipPrincipal sip

This setup works correctly, so you should verify your tables design and the
auth description.

Best Regards.

-------------------------------
Paulo Reis

On Wed, Sep 1, 2010 at 1:36 PM, 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:
>
> > 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">
>
> Genki
> *****.Genki
>

>
> OnlySupers
> com.aclandinternet.clients.OnlySupers
>

>
> OnlyRegulars
> *****.OnlyRegulars
>

>
> Genki
> /app/Genki
>

>
> OnlySupers
> /app/supers/OnlySupers
>

>
> OnlyRegulars
> /app/regulars/OnlyRegulars
>

>
>
> 30
>

>

>
> index.jsp
>

>
> SuperUserConstraint
>
> superuser
>
> /app/supers/*
>

>
>
> superuser
>

>

>
> RegularUserConstraint
>
> regularuser
>
> /app/regulars/*
>

>
>
> regularuser
> superuser
>

>

>
> BASIC
> client_access
>

>
>
> regularuser
>

>
>
> superuser
>

>

>
> sun-web.xml:
>
>
> /ClientsDemo
>
> regularuser
> regularuser
>

>
> superuser
> superuser
>

>
>
>
> Keep a copy of the generated servlet class' java
> code.

>
>

>

>
> 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@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
[att1.html]