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

Services Web Java Discussion :

Web Service et traitement d'exception


Sujet :

Services Web Java

  1. #1
    Membre du Club
    Femme Profil pro
    etudiante
    Inscrit en
    Octobre 2011
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : etudiante
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Octobre 2011
    Messages : 61
    Points : 46
    Points
    46
    Par défaut Web Service et traitement d'exception
    Bonjour,
    je suis entrain de développer un web service qui fait appel à une fonction. Cette fonction traite des exceptions.
    Le web service fonctionne très bien sans exception mais dés que je l'ajoute, une erreur à l'excution du projet s'affiche :
    "Le contexte [/CMS_GRM] n'a pas encore été démarré a été rencontrée
    D:\NetBeansProjects\CMS_GRM\nbproject\build-impl.xml:1055: The module has not been deployed.
    See the server log for details."


    voilà mon web service :
    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
    package WebService;
     
    import CMS.CMS_CardStatusException;
    import CMS.CMS_Exception;
    import javax.jws.WebService;
    import javax.jws.WebMethod;
    import javax.jws.WebParam;
    import javax.jws.WebResult;
     
    /**
     *
     * @author User
     */
    @WebService(targetNamespace = "http://WebService/")
    public class NEC_WS {
     
        /**
         * Web service operation
         */
        @WebMethod(operationName = "ChangeCardStatus")
        public int changeCardStatus(@WebParam(name = "ApplicationId") int applicationId, @WebParam(name = "CardNumber") String cardNumber, @WebParam(name = "CardStatusId") int cardStatusId) throws CMS_Exception, CMS_CardStatusException {
            CMS.Controller c = new CMS.Controller();
            int res = c.ChangeCardStatus(cardNumber, applicationId, cardStatusId);
            return res;
        }
    la fonction "ChangeCardStatus"
    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
       public int ChangeCardStatus(String CardNumber, int ApplicationId, int cardStatusId) throws CMS_Exception, CMS_CardStatusException {
            int result = 0;
            int res = 0;
             configFileURL = HibernateUtil.class.getResource("/hibernate.cfg.xml");
                Configuration config2 = (new Configuration()).configure(configFileURL);
                factory2 = config2.
                        addAnnotatedClass(GRM.ApplicationCardStatuses.class).
                        addAnnotatedClass(GRM.CardStatus.class).buildSessionFactory();
            Session session2 = factory2.openSession();
            Transaction tx2 = null;
            try {
                tx2 = session2.beginTransaction();
                GRM.CardStatus cardState = new GRM.CardStatus();
                GRM.CardStatus newCardState = new GRM.CardStatus(cardStatusId);
                Query query1 = session2.createQuery("From GRM.ApplicationCardStatuses st where st.applicationId= ?");
                query1.setParameter(0, ApplicationId);
                if (query1.list().isEmpty() == true) {
                    throw new CMS_Exception("ApplicationId does not exist in the DataBase!");
     
                } else {
     
                    List<GRM.ApplicationCardStatuses> cartesGRM = query1.list();
                    for (GRM.ApplicationCardStatuses carteGRM : cartesGRM) {
                        cardState = carteGRM.getCardStatus();
                        int PreviousStatusId = cardState.getCardStatusId();
                        res = CardStatusCompatibility(cardStatusId, PreviousStatusId);
                        if (res != 0) {
                            throw new CMS_CardStatusException(cardStatusId, PreviousStatusId, res);
                        } else {
                            carteGRM.setStatusDate(new Date());
                            carteGRM.setCardStatus(newCardState);
                        }
                    }
                    tx2.commit();
                    result = 0;
               }
            } catch (HibernateException e) {
                if (tx2 != null) {
                    tx2.rollback();
                }
                e.printStackTrace();
                result = 1;
            } catch (CMS_Exception ex) {
                System.out.println("Exception generated : " + ex.getMessage());
                result = 1;
            } catch (CMS_CardStatusException e) {
                e.printStackTrace();
                result = 1;
            } finally {
                session2.close();
            }
            return result;
        }

    et la classe CMS_Exception
    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
    /*
     * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package CMS;
     
    import javax.xml.ws.WebFault;
     
    /**
     *
     * @author aghazouani
     */
     
    @WebFault(name="WebServiceCMS_Exception",
            targetNamespace="http://WebService/")
    public class CMS_Exception extends Exception {
         private CMS_Exception faultInfo;
        public CMS_Exception (){
          // System.out.print("ApplicationId does not exist in the DataBase!");
        }
        public CMS_Exception( String msg) {
     
         super(msg); 
     
        }
    public CMS_Exception getFaultInfo() {
            return faultInfo;
        }
     
    }
    j'ai bien cherché ailleurs mais j'ai pas trouvé de solutions. Merci de m'aider

  2. #2
    Membre du Club
    Femme Profil pro
    etudiante
    Inscrit en
    Octobre 2011
    Messages
    61
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : etudiante
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Octobre 2011
    Messages : 61
    Points : 46
    Points
    46
    Par défaut
    Ci joint les erreurs au niveau d'apache tomcat log
    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
    Grave: Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) com.sun.xml.ws.transport.http.servlet.WSServletContextListener
    com.sun.xml.ws.transport.http.servlet.WSServletException: WSSERVLET11: failed to parse runtime descriptor: javax.xml.ws.WebServiceException: Unable to create JAXBContext
    	at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:139)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
    	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:670)
    	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1839)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    	at java.lang.Thread.run(Thread.java:744)
    Caused by: javax.xml.ws.WebServiceException: Unable to create JAXBContext
    	at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:166)
    	at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:94)
    	at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:258)
    	at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:338)
    	at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:201)
    	at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:505)
    	at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:253)
    	at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
    	at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:124)
    	... 13 more
    Caused by: java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    java.lang.StackTraceElement does not have a no-arg default constructor.
    	this problem is related to the following location:
    		at java.lang.StackTraceElement
    		at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
    		at java.lang.Throwable
    		at java.lang.Exception
    		at CMS.CMS_Exception
     
    	at java.security.AccessController.doPrivileged(Native Method)
    	at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:153)
    	... 21 more
    Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    java.lang.StackTraceElement does not have a no-arg default constructor.
    	this problem is related to the following location:
    		at java.lang.StackTraceElement
    		at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
    		at java.lang.Throwable
    		at java.lang.Exception
    		at CMS.CMS_Exception
     
    	at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
    	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:472)
    	at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
    	at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
    	at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
    	at com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:106)
    	at com.sun.xml.ws.developer.JAXBContextFactory$1.createJAXBContext(JAXBContextFactory.java:109)
    	at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:161)
    	at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:154)
    	... 23 more
     
    avr. 04, 2014 9:56:12 AM org.apache.catalina.core.ApplicationContext log
    Infos: ContextListener: contextInitialized()
    avr. 04, 2014 9:56:12 AM org.apache.catalina.core.ApplicationContext log
    Infos: SessionListener: contextInitialized()
    avr. 04, 2014 9:56:12 AM org.apache.catalina.core.ApplicationContext log
    Infos: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@6ffc266c')
    Merci de répondre c'est urgent

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. web service :A first chance exception..
    Par yan dans le forum Windows Mobile
    Réponses: 1
    Dernier message: 05/06/2009, 22h58
  2. Réponses: 9
    Dernier message: 02/02/2009, 00h54
  3. exception a l'appel du client d'un web service
    Par afrold dans le forum Services Web
    Réponses: 3
    Dernier message: 07/05/2008, 21h41
  4. Spring remoting / Web services / Exceptions handling
    Par bidi dans le forum Services Web
    Réponses: 2
    Dernier message: 04/07/2006, 11h07
  5. [vb.net]Gestion des exceptions avec les web services
    Par mvr dans le forum Windows Forms
    Réponses: 2
    Dernier message: 05/12/2005, 22h41

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