Hi Daniel,
I had not clear that I had to define previously a Datasource in tomee.xml,
now I see your example and I did and that works!
Thanks!

El vie, 19 jul 2024 a la(s) 12:45 p.m., Daniel Dias (d...@apache.org)
escribió:

> Hello Fernando,
>
> you can share the project ?
>
> If not, in tomee repository have an exemple of tomee realm [1]
>
> https://github.com/apache/tomee/tree/main/examples/realm-in-tomee/
>
> On 2024/07/19 14:52:25 Fernando wrote:
> > Hi all!,
> > I don't know if my problem must be sent the list, I apologize in advance,
> > but I think that maybe there some problem in my configuration of Apache
> > Tomee, and maybe you could give some help.
> > Recently I added Jdbc Realm to application and this work but when I try
> to
> > execute some jpa query I obtain nothing.
> > I Believe that all in the connection is ok, I put all in the file
> > context.xml of application:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <Context path="">
> >     <Resource name="jdbc/Corral"
> >               auth="Container"
> >               type="javax.sql.DataSource"
> >               driverClassName="org.postgresql.Driver"
> >               url="jdbc:postgresql://localhost:5432/CoopCorralitoWeb"
> >               username="myuser"
> >               password="mypassword"
> >               maxTotal="20" maxIdle="10" maxWaitMillis="-1"/>
> >
> >     <Realm  className="org.apache.catalina.realm.JDBCRealm"
> >              driverName="org.postgresql.Driver"
> >              connectionURL="jdbc:postgresql://localhost:5432/CoopCorral"
> >              connectionName="myuser" connectionPassword="mypassword"
> >              userTable="cliente" userNameCol="username"
> > userCredCol="password"
> >              userRoleTable="clienterol" roleNameCol="rol">
> >           <CredentialHandler
> > className="org.apache.catalina.realm.MessageDigestCredentialHandler"
> > algorithm="SHA-256" />
> >           </Realm>
> > </Context>
> >
> > Also I enabled logs of Apache Tomee to see was happening:
> >
> > 19-Jul-2024 11:34:02.286 DETALLADO [http-nio-8080-exec-15]
> > org.apache.catalina.authenticator.FormAuthenticator.doAuthenticate
> > Authenticating username '01652'
> > 19-Jul-2024 11:34:02.286 DETALLADO [http-nio-8080-exec-15]
> > sun.reflect.DelegatingMethodAccessorImpl.invoke Intentando autentica al
> > usuario [01652] con el reino [org.apache.catalina.realm.JDBCRealm]
> > 19-Jul-2024 11:34:02.286 DETALLADO [http-nio-8080-exec-15]
> > sun.reflect.DelegatingMethodAccessorImpl.invoke Usuario autenticado
> [01652]
> > con reino [org.apache.catalina.realm.JDBCRealm]
> > 19-Jul-2024 11:34:02.286 DETALLADO [http-nio-8080-exec-15]
> > org.apache.catalina.authenticator.FormAuthenticator.doAuthenticate
> > Authentication of '01652' was successful
> > 19-Jul-2024 11:34:02.286 DETALLADO [http-nio-8080-exec-15]
> > org.apache.catalina.authenticator.AuthenticatorBase.register
> Authenticated
> > '01652' with type 'FORM'
> > 19-Jul-2024 11:34:02.286 DETALLADO [http-nio-8080-exec-15]
> > org.apache.catalina.authenticator.AuthenticatorBase.changeSessionID
> Session
> > ID changed on authentication from [C5A2BDB72274F71B59C2DDF4C2362B68] to
> > [3F66ED486C51317146EEF8B63CBB3DEB]
> > 19-Jul-2024 11:34:02.286 DETALLADO [http-nio-8080-exec-15]
> > org.apache.catalina.authenticator.FormAuthenticator.doAuthenticate
> > Redirecting to original '/'
> > 19-Jul-2024 11:34:02.286 DETALLADO [http-nio-8080-exec-15]
> > org.apache.catalina.authenticator.AuthenticatorBase.invoke Failed
> > authenticate() test
> > 19-Jul-2024 11:34:02.302 DETALLADO [http-nio-8080-exec-17]
> > org.apache.catalina.authenticator.AuthenticatorBase.invoke Security
> > checking request GET /
> > 19-Jul-2024 11:34:02.302 DETALLADO [http-nio-8080-exec-17]
> > org.apache.catalina.authenticator.AuthenticatorBase.invoke We have cached
> > auth type FORM for principal GenericPrincipal[01652(usuario,)]
> > 19-Jul-2024 11:34:02.302 DETALLADO [http-nio-8080-exec-17]
> > org.apache.catalina.authenticator.AuthenticatorBase.invoke Calling
> > hasUserDataPermission()
> > 19-Jul-2024 11:34:02.302 DETALLADO [http-nio-8080-exec-17]
> > org.apache.catalina.authenticator.AuthenticatorBase.invoke Calling
> > authenticate()
> > 19-Jul-2024 11:34:02.302 DETALLADO [http-nio-8080-exec-17]
> > org.apache.catalina.authenticator.FormAuthenticator.doAuthenticate
> Restore
> > request from session '3F66ED486C51317146EEF8B63CBB3DEB'
> > 19-Jul-2024 11:34:02.302 DETALLADO [http-nio-8080-exec-17]
> > org.apache.catalina.authenticator.FormAuthenticator.doAuthenticate
> Proceed
> > to restored request
> > 19-Jul-2024 11:34:02.302 DETALLADO [http-nio-8080-exec-17]
> > org.apache.catalina.authenticator.AuthenticatorBase.invoke Calling
> > accessControl()
> > 19-Jul-2024 11:34:02.302 DETALLADO [http-nio-8080-exec-17]
> > org.apache.catalina.authenticator.AuthenticatorBase.invoke Successfully
> > passed all security constraints
> >
> > But, when I execute to some queries these not returning values and
> neither
> > any error :
> >
> > [EL Fine]: 2024-07-19
> >
> 11:34:02.788--ServerSession(23048368)--Connection(142695858)--Thread(Thread[http-nio-8080-exec-17,5,main])--SELECT
> > ID, ADMIN, CUIT, DOMICILIO, LOCALIDAD, MAIL, NOMBRE, PASSWORD, TELEFONO,
> > USERNAME FROM cliente
> >
> > Of course Table has values and user and password of connection are
> correct.
> > Any Idea where I can found the problem?
> > Regards!
> >
>

Reply via email to