IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Java EE Discussion :

Problème acces EJB distants


Sujet :

Java EE

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Février 2009
    Messages
    25
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2009
    Messages : 25
    Points : 13
    Points
    13
    Par défaut Problème acces EJB distants
    Bonjour,

    J'ai un problème que je n'arrive pas à résoudre depuis 2 jours maintenant, je ne trouve pas réponse sur le web si ce n'est :

    Principal propagation: Cannot find principal information in subject
    Description : Cannot find principal information in the subject. The security mechanisms are trying to extract the principal from the subject.

    Action : Check client authentication token propagated. Also refer to security documentation for supported security mechanisms.
    Ma config est :
    2 serveurs glassfish V2, le premier est sur mon ordi local avec le conteneur d'EJB metier et l'autre est sur une machine virtuelle et contient me EJB-WebService qui font appel à mes EJB metiers.

    Lorsque je teste tout en déployant sur mon poste local, cela marche, mais lorsque je teste le WebService quand il est deployé sur la machine virtuelle, cela ne marche pas et dans les logs j'ai droit à l'erreur décrite ci-dessus.

    Voici mes EJB et fichiers de cfg :
    EJB-WS :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package ecml.tchat.ejb.ws;
     
    import ecml.tchat.ejb.interfaces.ISiteClient;
    import ecml.tchat.metier.SiteClient;
    import javax.annotation.Resource;
    import javax.ejb.EJB;
    import javax.ejb.Stateless;
    import javax.jws.WebMethod;
    import javax.jws.WebService;
    import javax.servlet.http.HttpServletRequest;
    import javax.xml.ws.WebServiceContext;
    import javax.xml.ws.handler.MessageContext;
     
    /**
     *
     * @author Denis
     */
    @Stateless
    @WebService(serviceName="SiteClientService")
    public class SiteClientWSBean {
     
        @Resource
        private WebServiceContext _wsContext;
     
        @EJB(name="ISiteClient")
        private ISiteClient _siteClientEJB;
     
        /**
         * 
         * @return
         */
        private String getIpClient() {
            MessageContext mc = _wsContext.getMessageContext();
            HttpServletRequest req = (HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST);
            return req.getRemoteAddr();
        }
     
        /**
         * 
         * @param dns
         * @return
         */
        @WebMethod
        public Long getIdSiteClient(String dns) {
            if(dns!=null && !dns.equals("")){
                SiteClient site = _siteClientEJB.getSiteByDns(dns);
     
                if(site != null && getIpClient().equals(site.getIp())) {
                    return site.getId();
                }
                else return null;
            }
            else return null;
        }
     
    }
    puis le sun-ejb-jar.xml de mon EJB-WS :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
    <sun-ejb-jar>
      <enterprise-beans>
        <name>TCHAT-EJB-WS</name>
        <ejb>
          <ejb-name>SiteClientWSBean</ejb-name>
          <ejb-ref>
            <ejb-ref-name>ISiteClient</ejb-ref-name>
            <jndi-name>corbaname:iiop:172.16.10.180:3700#ecml.tchat.ejb.interfaces.ISiteClient</jndi-name>
          </ejb-ref>
        </ejb>
      </enterprise-beans>
    </sun-ejb-jar>
    Puis mon EJB-Metier :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package ecml.tchat.ejb.dao;
     
    import ecml.tchat.ejb.interfaces.ISiteClient;
    import ecml.tchat.metier.SiteClient;
    import java.util.List;
    //import javax.annotation.security.RolesAllowed;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
     
    /**
     *
     * @author Denis
     */
    @Stateless
    public class SiteClientBean implements ISiteClient {
     
        @PersistenceContext
        private EntityManager _em;
     
        /**
         * 
         * @param ip
         * @param dns
         * @param nomdesc
         * @return
         */
    //    @RolesAllowed("admin")
        public Boolean createSite(String ip, String dns, String nomdesc) {
            // Si l'Ip et le dns ne sont pas déjà référencées
            try {
                SiteClient obj = new SiteClient(dns, ip, nomdesc);
                _em.persist(obj);
                return true;
            }catch (Exception ex){
                return false;
            }
        }
     
        /**
         * 
         * @param dns
         * @return
         */
        public SiteClient getSiteByDns(String dns) {
             try {
                 SiteClient site = (SiteClient) _em.createQuery("SELECT tab FROM SiteClient tab WHERE tab._dns=:dnsSite").setParameter("dnsSite", dns).getSingleResult();
                 return site;
            }catch (Exception ex){
                //NonUniqueResultException - if there is no result
                //NoResultException - if more than one result
                //IllegalStateException - if called for a Java Persistence query language UPDATE or DELETE statement
                System.err.println("getSiteByDns" + ex.getMessage() + "\n\n" + ex.getStackTrace());
                return null;
            }
        }
     
        /**
         * 
         * @param id
         * @param ip
         * @param dns
         * @param nomdesc
         * @return
         */
    //    @RolesAllowed("admin")
        public Boolean updateSite(Long id, String ip, String dns, String nomdesc) {
            if(id!=null){            
                try {
                    SiteClient obj = this.getSiteClient(id);
     
                    obj.setDns(dns);
     
                    obj.setDns(ip);
     
                    obj.setNomDesc(nomdesc);
                    return true;
                }catch (Exception ex) {
                    return false;
                }
            }else return false;
        }
     
        /**
         * 
         * @param id
         */
    //    @RolesAllowed("admin")
        public void deleteSite(Long id) {
            _em.remove(getSiteClient(id));
        }
     
        /**
         * 
         * @return
         */
    //    @RolesAllowed("admin")
        public List<SiteClient> getSites() {
            return _em.createQuery("SELECT tab FROM SiteClient tab ORDER BY tab._dns").getResultList();
        }
     
        /**
         * 
         * @param id
         * @return
         */
        public SiteClient getSiteClient(Long id) {
            return _em.find(SiteClient.class, id);
        }
     
    }
    Enfin mon sun-ejb-jar.xml partie metier :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
    <sun-ejb-jar>
      <enterprise-beans>
        <name>TCHAT-EJB</name>
        <ejb>
          <ejb-name>SiteClientBean</ejb-name>
        </ejb>
      </enterprise-beans>
    </sun-ejb-jar>

    J'ai vraiment besoin d'aide assez rapidement si possible.

    Merci d'avance

    PS: n'hesitez pas si vous avez besoins de precisions

  2. #2
    Membre à l'essai
    Profil pro
    Inscrit en
    Février 2009
    Messages
    25
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2009
    Messages : 25
    Points : 13
    Points
    13
    Par défaut Enfin trouvé
    J'ai trouvé la vrai origine du problème :
    plusieurs transactions avaient lieu en même temps cela n'avait rien avoir avec le problème cité dessus, pour le résoudre j'ai mis une annotation au dessus des mes fonctions des ejb metier :
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    Voila tout!

Discussions similaires

  1. problème accés distant
    Par Dragna_x dans le forum Développement
    Réponses: 6
    Dernier message: 18/05/2010, 18h03
  2. Réponses: 15
    Dernier message: 26/01/2010, 15h11
  3. Problèmes : accès distant Glassfish et Client autonome
    Par eclan dans le forum Glassfish et Payara
    Réponses: 9
    Dernier message: 27/08/2008, 00h22
  4. Réponses: 1
    Dernier message: 18/07/2008, 11h46
  5. [SQLServer2K][Administration] Problème accès distant
    Par 33Romain dans le forum MS SQL Server
    Réponses: 3
    Dernier message: 04/04/2008, 16h12

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo