10 Replies Latest reply on Mar 18, 2009 10:03 AM by wolfgangknauf

    how to configure jaas with jboss 5.0.1

    bjpenn

      hello everybody, i am very new in jboss 5.0.1 (jboss in general) and i need to know wich steps i should folow to configure my jaas authentication of my application.
      thanks in advance.

        • 1. Re: how to configure jaas with jboss 5.0.1
          bjpenn

          i am using realm

          • 2. Re: how to configure jaas with jboss 5.0.1
            peterj
            • 3. Re: how to configure jaas with jboss 5.0.1
              bjpenn

              Well my problem is my application can authenticate but the authorization is not correct, cause i get the jsp page wich tells i cant acces to the jsp due to no having authorization. So this is the steps i made:

              1-First i changed my jboss-web.xml :

              <?xml version="1.0" encoding="UTF-8" ?>
              - <jboss-web>
               <security-domain>java:/jaas/smsJAAS</security-domain>
               <context-root>/jtk_SENIC</context-root>
               </jboss-web>


              2-i set another application-policy in the file /server/default/conf/login-config.xml:

              <?xml version="1.0" ?>
              - <!-- The XML based JAAS login configuration read by the
              org.jboss.security.auth.login.XMLLoginConfig mbean. Add
              an application-policy element for each security domain.
              
              The outline of the application-policy is:
              <application-policy name="security-domain-name">
               <authentication>
               <login-module code="login.module1.class.name" flag="control_flag">
               <module-option name = "option1-name">option1-value</module-option>
               <module-option name = "option2-name">option2-value</module-option>
               ...
               </login-module>
              
               <login-module code="login.module2.class.name" flag="control_flag">
               ...
               </login-module>
               ...
               </authentication>
              </application-policy>
              
              $Id: login-config.xml 76444 2008-07-29 23:50:53Z sguilhen@redhat.com $
              $Revision: 76444 $
              
               -->
              - <policy>
              - <!-- Used by clients within the application server VM such as
               mbeans and servlets that access EJBs.
              
               -->
              - <application-policy name="smsJAAS">
              - <authentication>
              - <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
               <module-option name="unauthenticatedIdentity">guest</module-option>
               <module-option name="dsJndiName">java:/smsactjndi</module-option>
               <module-option name="principalsQuery">SELECT contrasena FROM usuarios_v WHERE nomusuario=?</module-option>
               <module-option name="rolesQuery">SELECT nomgrupous, 'Roles' FROM usuarios_v WHERE nomusuario=?</module-option>
               </login-module>
               </authentication>
               </application-policy>
              - <application-policy name="client-login">
              - <authentication>
              - <login-module code="org.jboss.security.ClientLoginModule" flag="required">
              - <!-- Any existing security context will be restored on logout
               -->
               <module-option name="restore-login-identity">true</module-option>
               </login-module>
               </authentication>
               </application-policy>
              - <!-- Security domains for testing new jca framework
               -->
              - <application-policy name="HsqlDbRealm">
              - <authentication>
              - <login-module code="org.jboss.resource.security.ConfiguredIdentityLoginModule" flag="required">
               <module-option name="principal">sa</module-option>
               <module-option name="userName">sa</module-option>
               <module-option name="password" />
               <module-option name="managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option>
               </login-module>
               </authentication>
               </application-policy>
              - <application-policy name="JmsXARealm">
              - <authentication>
              - <login-module code="org.jboss.resource.security.ConfiguredIdentityLoginModule" flag="required">
               <module-option name="principal">guest</module-option>
               <module-option name="userName">guest</module-option>
               <module-option name="password">guest</module-option>
               <module-option name="managedConnectionFactoryName">jboss.jca:service=TxCM,name=JmsXA</module-option>
               </login-module>
               </authentication>
               </application-policy>
              - <!-- A template configuration for the jmx-console web application. This
               defaults to the UsersRolesLoginModule the same as other and should be
               changed to a stronger authentication mechanism as required.
              
               -->
              - <application-policy name="jmx-console">
              - <authentication>
              - <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
               <module-option name="usersProperties">props/jmx-console-users.properties</module-option>
               <module-option name="rolesProperties">props/jmx-console-roles.properties</module-option>
               </login-module>
               </authentication>
               </application-policy>
              - <!-- A template configuration for the web-console web application. This
               defaults to the UsersRolesLoginModule the same as other and should be
               changed to a stronger authentication mechanism as required.
              
               -->
              - <application-policy name="web-console">
              - <authentication>
              - <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
               <module-option name="usersProperties">web-console-users.properties</module-option>
               <module-option name="rolesProperties">web-console-roles.properties</module-option>
               </login-module>
               </authentication>
               </application-policy>
              - <!-- A template configuration for the JBossWS security domain.
               This defaults to the UsersRolesLoginModule the same as other and should be
               changed to a stronger authentication mechanism as required.
              
               -->
              - <application-policy name="JBossWS">
              - <authentication>
              - <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
               <module-option name="usersProperties">props/jbossws-users.properties</module-option>
               <module-option name="rolesProperties">props/jbossws-roles.properties</module-option>
               <module-option name="unauthenticatedIdentity">anonymous</module-option>
               </login-module>
               </authentication>
               </application-policy>
              - <!-- The default login configuration used by any security domain that
               does not have a application-policy entry with a matching name
              
               -->
              - <application-policy name="other">
              - <!-- A simple server login module, which can be used when the number
               of users is relatively small. It uses two properties files:
               users.properties, which holds users (key) and their password (value).
               roles.properties, which holds users (key) and a comma-separated list of
               their roles (value).
               The unauthenticatedIdentity property defines the name of the principal
               that will be used when a null username and password are presented as is
               the case for an unuathenticated web client or MDB. If you want to
               allow such users to be authenticated add the property, e.g.,
               unauthenticatedIdentity="nobody"
              
               -->
              - <authentication>
               <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required" />
               </authentication>
               </application-policy>
               </policy>



              3- configuring my web xml with security constraints:


              <?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">
              - <!-- Nombre de la unidad de persistencia para JToolkitFW
               -->
              - <context-param>
               <param-name>com.sun.faces.verifyObjects</param-name>
               <param-value>false</param-value>
               </context-param>
              - <context-param>
               <param-name>com.sun.faces.validateXml</param-name>
               <param-value>true</param-value>
               </context-param>
              - <context-param>
               <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
               <param-value>client</param-value>
               </context-param>
              - <context-param>
               <param-name>com.sun.faces.verifyObjects</param-name>
               <param-value>false</param-value>
               </context-param>
              - <context-param>
               <param-name>com.sun.faces.validateXml</param-name>
               <param-value>true</param-value>
               </context-param>
              - <context-param>
               <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
               <param-value>client</param-value>
               </context-param>
              - <env-entry>
               <env-entry-name>jndi_pool</env-entry-name>
               <env-entry-type>java.lang.String</env-entry-type>
               <env-entry-value>jndi/smsact</env-entry-value>
               </env-entry>
              - <servlet>
               <servlet-name>Faces Servlet</servlet-name>
               <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
               <load-on-startup>1</load-on-startup>
              - <security-role-ref>
               <description />
               <role-name>suscriptores</role-name>
               <role-link>suscriptores</role-link>
               </security-role-ref>
              - <security-role-ref>
               <description />
               <role-name>promotores</role-name>
               <role-link>promotores</role-link>
               </security-role-ref>
              - <security-role-ref>
               <description />
               <role-name>mensajes</role-name>
               <role-link>mensajes</role-link>
               </security-role-ref>
              - <security-role-ref>
               <description />
               <role-name>categorias</role-name>
               <role-link>categorias</role-link>
               </security-role-ref>
              - <security-role-ref>
               <description />
               <role-name>envio_directo</role-name>
               <role-link>envio_directo</role-link>
               </security-role-ref>
              - <security-role-ref>
               <description />
               <role-name>perfiles</role-name>
               <role-link>perfiles</role-link>
               </security-role-ref>
              - <security-role-ref>
               <description>adming</description>
               <role-name>adming</role-name>
               <role-link>adming</role-link>
               </security-role-ref>
               </servlet>
              - <!-- #Security constraints
               -->
              - <error-page>
               <error-code>403</error-code>
               <location>/error/acceso_denegado.jsp</location>
               </error-page>
              - <security-constraint>
               <display-name>principal</display-name>
              - <web-resource-collection>
               <web-resource-name>principal</web-resource-name>
               <description />
               <url-pattern>/faces/principal.jsp</url-pattern>
               <http-method>GET</http-method>
               <http-method>POST</http-method>
               <http-method>HEAD</http-method>
               <http-method>PUT</http-method>
               <http-method>OPTIONS</http-method>
               <http-method>TRACE</http-method>
               <http-method>DELETE</http-method>
               </web-resource-collection>
              - <auth-constraint>
               <role-name>mensajes</role-name>
               <role-name>suscriptores</role-name>
               <role-name>promotores</role-name>
               <role-name>categorias</role-name>
               <role-name>envio_directo</role-name>
               <role-name>perfiles</role-name>
               <role-name>adming</role-name>
               </auth-constraint>
               </security-constraint>
              - <!-- #Roles
               -->
              - <security-constraint>
               <display-name>grabador de suscriptores</display-name>
              - <web-resource-collection>
               <web-resource-name>categ_susc</web-resource-name>
               <description />
               <url-pattern>/faces/categ_susc.jsp</url-pattern>
               <http-method>GET</http-method>
               <http-method>POST</http-method>
               <http-method>HEAD</http-method>
               <http-method>PUT</http-method>
               <http-method>OPTIONS</http-method>
               <http-method>TRACE</http-method>
               <http-method>DELETE</http-method>
               </web-resource-collection>
              - <web-resource-collection>
               <web-resource-name>suscriptores</web-resource-name>
               <description />
               <url-pattern>/faces/suscriptores.jsp</url-pattern>
               <http-method>GET</http-method>
               <http-method>POST</http-method>
               <http-method>HEAD</http-method>
               <http-method>PUT</http-method>
               <http-method>OPTIONS</http-method>
               <http-method>TRACE</http-method>
               <http-method>DELETE</http-method>
               </web-resource-collection>
              - <auth-constraint>
               <description />
               <role-name>suscriptores</role-name>
               </auth-constraint>
               </security-constraint>
              - <security-constraint>
               <display-name>grabador de mensajes</display-name>
              - <web-resource-collection>
               <web-resource-name>mensajes</web-resource-name>
               <description />
               <url-pattern>/faces/mensajes.jsp</url-pattern>
               <http-method>GET</http-method>
               <http-method>POST</http-method>
               <http-method>HEAD</http-method>
               <http-method>PUT</http-method>
               <http-method>OPTIONS</http-method>
               <http-method>TRACE</http-method>
               <http-method>DELETE</http-method>
               </web-resource-collection>
              - <auth-constraint>
               <description />
               <role-name>mensajes</role-name>
               </auth-constraint>
               </security-constraint>
              - <security-constraint>
               <display-name>envio directo</display-name>
              - <web-resource-collection>
               <web-resource-name>envio_directo</web-resource-name>
               <description />
               <url-pattern>/faces/envio_directo.jsp</url-pattern>
               <http-method>GET</http-method>
               <http-method>POST</http-method>
               <http-method>HEAD</http-method>
               <http-method>PUT</http-method>
               <http-method>OPTIONS</http-method>
               <http-method>TRACE</http-method>
               <http-method>DELETE</http-method>
               </web-resource-collection>
              - <auth-constraint>
               <description />
               <role-name>envio_directo</role-name>
               </auth-constraint>
               </security-constraint>
              - <security-constraint>
               <display-name>promotores</display-name>
              - <web-resource-collection>
               <web-resource-name>promotores</web-resource-name>
               <description />
               <url-pattern>/faces/promotores.jsp</url-pattern>
               <http-method>GET</http-method>
               <http-method>POST</http-method>
               <http-method>HEAD</http-method>
               <http-method>PUT</http-method>
               <http-method>OPTIONS</http-method>
               <http-method>TRACE</http-method>
               <http-method>DELETE</http-method>
               </web-resource-collection>
              - <auth-constraint>
               <description />
               <role-name>promotores</role-name>
               </auth-constraint>
               </security-constraint>
              - <security-constraint>
               <display-name>categorias</display-name>
              - <web-resource-collection>
               <web-resource-name>categorias</web-resource-name>
               <description />
               <url-pattern>/faces/categorias.jsp</url-pattern>
               <http-method>GET</http-method>
               <http-method>POST</http-method>
               <http-method>HEAD</http-method>
               <http-method>PUT</http-method>
               <http-method>OPTIONS</http-method>
               <http-method>TRACE</http-method>
               <http-method>DELETE</http-method>
               </web-resource-collection>
              - <auth-constraint>
               <description />
               <role-name>categorias</role-name>
               </auth-constraint>
               </security-constraint>
              - <security-constraint>
               <display-name>perfiles</display-name>
              - <web-resource-collection>
               <web-resource-name>perfiles</web-resource-name>
               <description />
               <url-pattern>/faces/grupos.jsp</url-pattern>
               <url-pattern>/faces/idiomas.jsp</url-pattern>
               <url-pattern>/faces/entidades.jsp</url-pattern>
               <url-pattern>/faces/sol_informacion.jsp</url-pattern>
               <url-pattern>/faces/usuarios.jsp</url-pattern>
               <http-method>GET</http-method>
               <http-method>POST</http-method>
               <http-method>HEAD</http-method>
               <http-method>PUT</http-method>
               <http-method>OPTIONS</http-method>
               <http-method>TRACE</http-method>
               <http-method>DELETE</http-method>
               </web-resource-collection>
              - <auth-constraint>
               <description />
               <role-name>perfiles</role-name>
               </auth-constraint>
               </security-constraint>
              - <security-constraint>
               <display-name>adming</display-name>
              - <web-resource-collection>
               <web-resource-name>entidades</web-resource-name>
               <description />
               <url-pattern>/faces/entidadest.jsp</url-pattern>
               <http-method>GET</http-method>
               <http-method>POST</http-method>
               <http-method>HEAD</http-method>
               <http-method>PUT</http-method>
               <http-method>OPTIONS</http-method>
               <http-method>TRACE</http-method>
               <http-method>DELETE</http-method>
               </web-resource-collection>
              - <web-resource-collection>
               <web-resource-name>usuariost</web-resource-name>
               <description />
               <url-pattern>/faces/usuariost.jsp</url-pattern>
               <http-method>GET</http-method>
               <http-method>POST</http-method>
               <http-method>HEAD</http-method>
               <http-method>PUT</http-method>
               <http-method>OPTIONS</http-method>
               <http-method>TRACE</http-method>
               <http-method>DELETE</http-method>
               </web-resource-collection>
              - <auth-constraint>
               <description />
               <role-name>adming</role-name>
               </auth-constraint>
               </security-constraint>
              - <login-config>
               <auth-method>FORM</auth-method>
               <realm-name>smsJAAS</realm-name>
              - <form-login-config>
               <form-login-page>/login/login.jsp</form-login-page>
               <form-error-page>/login/login.jsp?error=true</form-error-page>
               </form-login-config>
               </login-config>
              - <servlet-mapping>
               <servlet-name>Faces Servlet</servlet-name>
               <url-pattern>/faces/*</url-pattern>
               </servlet-mapping>
              - <session-config>
               <session-timeout>30</session-timeout>
               </session-config>
              - <welcome-file-list>
               <welcome-file>faces/principal.jsp</welcome-file>
               </welcome-file-list>
              - <security-role>
               <description>Administracion de mensajes</description>
               <role-name>mensajes</role-name>
               </security-role>
              - <security-role>
               <description>Administracion de suscriptores</description>
               <role-name>suscriptores</role-name>
               </security-role>
              - <security-role>
               <description>Administracion de los promotores</description>
               <role-name>promotores</role-name>
               </security-role>
              - <security-role>
               <description>Administracion de las categorias</description>
               <role-name>categorias</role-name>
               </security-role>
              - <security-role>
               <description>Acceso al envio directo</description>
               <role-name>envio_directo</role-name>
               </security-role>
              - <security-role>
               <description>Acceso a la administracion de perfiles</description>
               <role-name>perfiles</role-name>
               </security-role>
              - <security-role>
               <description>Opciones de administrador general</description>
               <role-name>adming</role-name>
               </security-role>
               </web-app>


              what am i doing wrong?? am i forgeting about something?. thank you all in advance.

              • 4. Re: how to configure jaas with jboss 5.0.1
                bjpenn

                Well i found an error , it looks like my application is looking for hibernate drivers,even if i dont use it, so my question is: i am using toplink instead of hibernate, in wich file configure this detail

                • 5. Re: how to configure jaas with jboss 5.0.1
                  bjpenn

                  this is the error message that jboss return:

                  org.apache.jasper.JasperException: java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence cannot be cast to javax.persistence.spi.PersistenceProvider
                   org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:515)
                   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
                   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
                   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
                   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                   com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
                   com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
                   com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
                   org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
                   org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:196)
                   com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
                   com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                   com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
                   javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
                   org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                  
                  causa raÃz
                  
                  java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence cannot be cast to javax.persistence.spi.PersistenceProvider
                   javax.persistence.Persistence.findAllProviders(Persistence.java:186)
                   javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:103)
                   javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
                   controller.usuariosC.<init>(usuariosC.java:29)
                   org.apache.jsp.principal_jsp._jspService(principal_jsp.java:112)
                   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
                   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
                   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
                   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
                   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
                   com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:410)
                   com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:468)
                   com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
                   org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
                   org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:196)
                   com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
                   com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
                   com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
                   javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
                   org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                  
                  nota La traza completa de la causa de este error se encuentra en los archivos de diario de JBoss Web/2.1.2.GA.
                  JBoss Web/2.1.2.GA


                  • 6. Re: how to configure jaas with jboss 5.0.1
                    peterj

                    I do not see anything obviously incorrect in your security configuration.

                    I have never tried to configure JBoss AS to use TopLink, so I cannot help you there.

                    • 7. Re: how to configure jaas with jboss 5.0.1
                      wolfgangknauf

                      Is there any chance that your app contains hibernate libraries, which conflict with the ones of JBoss?

                      This is suspicious:

                      java.lang.ClassCastException: org.hibernate.ejb.HibernatePersistence cannot be cast to javax.persistence.spi.PersistenceProvider
                       ...
                       controller.usuariosC.<init>(usuariosC.java:29)
                       ...

                      This cast should be possible, if the classloader is the same.

                      What is "controller.usuariosC", and what does it look like?

                      Wolfgang

                      • 8. Re: how to configure jaas with jboss 5.0.1
                        bjpenn

                        mmmm i am not using in any moment any class of Hibernate, all i am doing is to incorporate to the project a couple jars of TopLink.
                        the controler.UsuarioC is a class in my project here is the constructor:

                        package controller;
                        
                        import java.util.List;
                        import javax.persistence.EntityManager;
                        import javax.persistence.EntityManagerFactory;
                        import javax.persistence.PersistenceUnit;
                        import persistencia.EntidadesT;
                        import persistencia.UsuariosT;
                        
                        /**
                         *
                         * @author Administrador
                         */
                        public class usuariosC {
                        
                         private int usuariosK;
                         private int entidadK;
                         //@PersistenceUnit(unitName = "jtoolkitfwPU")
                         private EntityManagerFactory emf = null;
                        
                         private EntityManager em = null;
                        
                         public usuariosC() {
                         //Creamos el Factory en base a la Persistence Unit = JavaApplication1PU
                         emf = javax.persistence.Persistence.createEntityManagerFactory("jtoolkitfwPU");
                        
                         //Creamos en Entity
                         //em = new act.persistence.ControllerTK().getEntityManager();
                         em = emf.createEntityManager();
                         }
                        
                         /**
                         * @return the usuariosK
                         * Buscar objeto usuario por nomusuario
                         */
                         public UsuariosT getUsuarios(String usuario) {
                         List<UsuariosT> usuarios = em.createNamedQuery("UsuariosT.findByNomusuario").setParameter("nomusuario", usuario).getResultList();
                         UsuariosT user = usuarios.get(0);
                         return user;
                         }
                        
                        
                         /**
                         * @return the usuariosK
                         * Buscar usuarioK por nomusuario
                         */
                         public int getUsuariosK(String usuario) {
                         List<UsuariosT> usuarios = em.createNamedQuery("UsuariosT.findByNomusuario").setParameter("nomusuario", usuario).getResultList();
                         //UsuariosT user = usuarios.get(0);
                         int userk = usuarios.get(0).getUsuarioK();
                         return userk;
                         }
                        
                         /**
                         * @param usuariosK the usuariosK to set
                         */
                         public void setUsuariosK(int usuariosK) {
                         this.usuariosK = usuariosK;
                         }
                        
                         /**
                         * @return the entidadK
                         * Buscar el objeto Entidad por nomusuario
                         */
                        
                         public EntidadesT getEntidad(String usuario) {
                        
                        
                         List<UsuariosT> usuarios = em.createNamedQuery("UsuariosT.findByNomusuario").setParameter("nomusuario", usuario).getResultList();
                         UsuariosT user = usuarios.get(0);
                         EntidadesT ent = user.getEntidadK();
                         return ent;
                         }
                         public String getNomEntidad(String usuario) {
                        
                        
                         List<UsuariosT> usuarios = em.createNamedQuery("UsuariosT.findByNomusuario").setParameter("nomusuario", usuario).getResultList();
                         UsuariosT user = usuarios.get(0);
                         EntidadesT ent = user.getEntidadK();
                         return ent.getNomentidad();
                         }
                        
                         /**
                         * @return the entidadK
                         * Buscar EntidadK por nomusuario
                         */
                        
                         public int getEntidadK(String usuario) {
                        
                        
                         List<UsuariosT> usuarios = em.createNamedQuery("UsuariosT.findByNomusuario").setParameter("nomusuario", usuario).getResultList();
                         UsuariosT user = usuarios.get(0);
                         EntidadesT ent = user.getEntidadK();
                         return ent.getEntidadK();
                         }
                        
                         /**
                         * @param entidadK the entidadK to set
                         */
                         public void setEntidadK(int entidadK) {
                         this.entidadK = entidadK;
                         }
                         /**
                         * Cerrar el factory y el entity
                         */
                         public void cerrar(){
                         em.close();
                         emf.close();
                         }
                        }


                        my error was to not add the two TopLink jars to the project, but i still get the same error even after adding it.
                        so is there any XML file that i have to specify that the type of the persistence i am using is TopLink ? cause i think Jboss takes Hibernate by default.
                        thanks for your replies


                        • 9. Re: how to configure jaas with jboss 5.0.1
                          bjpenn

                          Ok well, i just realized that in my file "persistence.xml" there was no persistence provider defined, i am using netbeans. any way i added the line that specify my provider "TopLink"
                          :

                          <?xml version="1.0" encoding="UTF-8" ?>
                          - <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
                          - <persistence-unit name="jtoolkitfwPU">
                           <jta-data-source>java:/smsactjndi</jta-data-source>
                           <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
                           <exclude-unlisted-classes>false</exclude-unlisted-classes>
                           <properties />
                           </persistence-unit>
                           </persistence>


                          but i still getting another error "i know this is so deseperating" wich is:

                          12:21:08,718 ERROR [AbstractKernelController] Error installing to Parse: name=vfszip:/C:/java/jboss-5.0.1.GA-jdk6/jboss-5.0.1.GA/server/default/deploy/jtk_SENIC.war/ state=Not Installed mode=Manual requiredState=Parse
                          org.jboss.deployers.spi.DeploymentException: Error creating managed object for vfszip:/C:/java/jboss-5.0.1.GA-jdk6/jboss-5.0.1.GA/server/default/deploy/jtk_SENIC.war/
                           at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
                           at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:337)
                           at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:297)
                           at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:269)
                           at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.deploy(AbstractParsingDeployerWithOutput.java:230)
                           at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
                           at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
                           at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
                           at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
                           at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
                           at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
                           at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
                           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
                           at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
                           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
                           at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
                           at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
                           at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:698)
                           at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:304)
                           at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:205)
                           at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:405)
                           at org.jboss.Main.boot(Main.java:209)
                           at org.jboss.Main$1.run(Main.java:547)
                           at java.lang.Thread.run(Unknown Source)
                          Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: cvc-complex-type.2.4.a: Invalid content was found starting with element 'provider'. One of '{"http://java.sun.com/xml/ns/persistence":non-jta-data-source, "http://java.sun.com/xml/ns/persistence":mapping-file, "http://java.sun.com/xml/ns/persistence":jar-file, "http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected. @ vfszip:/C:/java/jboss-5.0.1.GA-jdk6/jboss-5.0.1.GA/server/default/deploy/jtk_SENIC.war/WEB-INF/classes/META-INF/persistence.xml[5,15]
                           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:203)
                           at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:168)
                           at org.jboss.deployers.vfs.spi.deployer.JBossXBDeployerHelper.parse(JBossXBDeployerHelper.java:199)
                           at org.jboss.deployers.vfs.spi.deployer.JBossXBDeployerHelper.parse(JBossXBDeployerHelper.java:170)
                           at org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer.parse(SchemaResolverDeployer.java:132)
                           at org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer.parse(SchemaResolverDeployer.java:118)
                           at org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer.parseAndInit(AbstractVFSParsingDeployer.java:256)
                           at org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer.parse(AbstractVFSParsingDeployer.java:188)
                           at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:323)
                           ... 22 more
                          Caused by: org.xml.sax.SAXException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'provider'. One of '{"http://java.sun.com/xml/ns/persistence":non-jta-data-source, "http://java.sun.com/xml/ns/persistence":mapping-file, "http://java.sun.com/xml/ns/persistence":jar-file, "http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected. @ vfszip:/C:/java/jboss-5.0.1.GA-jdk6/jboss-5.0.1.GA/server/default/deploy/jtk_SENIC.war/WEB-INF/classes/META-INF/persistence.xml[5,15]
                           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$MetaDataErrorHandler.error(SaxJBossXBParser.java:426)
                           at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
                           at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
                           at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
                           at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
                           at org.apache.xerces.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(Unknown Source)
                           at org.apache.xerces.impl.xs.XMLSchemaValidator.reportSchemaError(Unknown Source)
                           at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
                           at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
                           at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
                           at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
                           at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
                           at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
                           at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
                           at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
                           at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
                           at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
                           at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
                           at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:199)
                           ... 30 more




                          • 10. Re: how to configure jaas with jboss 5.0.1
                            wolfgangknauf

                            Swap the lines "provider" and "jta-data-source".

                            Do you use an IDE to develop your app? If the IDE provides XML validation, errors like this are detected much earlier ;-).

                            Best regards

                            Wolfgang